Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Develop in Main #40

Merged
merged 2 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ yarn-debug.log*
yarn-error.log*

# coverage testing
/coverage
coverage/
54 changes: 54 additions & 0 deletions frontend/src/pages/LandingPage.css
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,62 @@ p {
align-items: center;
justify-content: center;
cursor: pointer; /* Indicate that it's clickable */
transition: none;
}

@keyframes swipe-left {
0% {
transform: translateX(0) translateY(0) rotate(0deg);
opacity: 1;
}
20% {
transform: translateX(-150%) translateY(65%) rotate(-80deg);
opacity: 1;
}
40% {
transform: translateX(-200%) translateY(70%) rotate(-90deg);
opacity: 0.7;
}
85% {
transform: translateY(50%) ;
opacity: 0.7;
}
100% {
opacity: 0.5;
}
}

@keyframes swipe-right {
0% {
transform: translateX(0) translateY(0) rotate(0deg);
opacity: 1;
}
20% {
transform: translateX(150%) translateY(65%) rotate(80deg);
opacity: 1;
}
40% {
transform: translateX(300%) translateY(70%) rotate(90deg);
opacity: 0.7;
}
85% {
transform: translateY(50%);
opacity: 0.7;
}
100% {
opacity: 0;
}
}

.swipe-left {
animation: swipe-left 2s;
}

.swipe-right {
animation: swipe-right 2s;
}


.swiping-pdf-item embed {
width: 100%;
height: 100%;
Expand Down
58 changes: 36 additions & 22 deletions frontend/src/pages/LandingPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const LandingPage = () => {

const [swipingResumes, setSwipingResumes] = useState([]);
const [currentIndex, setCurrentIndex] = useState(0);
const [swipeDirection, setSwipeDirection] = useState(null); // 'left' or 'right'
const [isSwiping, setIsSwiping] = useState(false);

const [openZoomModal, ZoomModal] = useZoomModal();

Expand Down Expand Up @@ -59,30 +61,40 @@ const LandingPage = () => {

console.log('Current Resume:', JSON.stringify(currentResume, null, 2)); // Log current resume

if (!currentResume || !currentResume._id || !currentResume.uploader_id) {
console.error('Invalid current resume structure:', currentResume);
return;
}
if (!currentResume || !currentResume._id || !currentResume.uploader_id) {
console.error('Invalid current resume structure:', currentResume);
return;
}

setSwipeDirection(accept ? 'right' : 'left');
setIsSwiping(true);

try {
let axiosConfig = {
headers: {
'Content-Type': 'application/json'
}
};
setTimeout( async () => {
try {
let axiosConfig = {
headers: {
'Content-Type': 'application/json'
}
};

await axios.post(`http://localhost:3001/api/swipes/${userId}`, {
user_id: userId,
resume_id: currentResume._id,
uploader_id: currentResume.uploader_id,
accept: accept
}, axiosConfig);
await axios.post(`http://localhost:3001/api/swipes/${userId}`, {
user_id: userId,
resume_id: currentResume._id,
uploader_id: currentResume.uploader_id,
accept: accept
}, axiosConfig);

setCurrentIndex(prevIndex => prevIndex + 1);
await checkMatches(userId, currentResume.uploader_id._id, currentResume._id);
} catch (error) {
console.error('Failed to swipe resume', error);
} finally {
// Reset the animation state to prepare for the next swipe
setIsSwiping(false);
setSwipeDirection(null);
}
}, 400);

setCurrentIndex(prevIndex => prevIndex + 1);
await checkMatches(userId, currentResume.uploader_id._id, currentResume._id);
} catch (error) {
console.error('Failed to swipe resume', error);
}
};

const checkMatches = async (currentUserId, swipedResumeUploaderId, swipedResumeId) => {
Expand Down Expand Up @@ -142,7 +154,9 @@ const LandingPage = () => {
</button>
</div>
</div>
<div className="swiping-pdf-item" onClick={() => openZoomModal(currentResume)}>
<div className={`swiping-pdf-item ${isSwiping ? `swipe-${swipeDirection}` : ''}`}
onClick={() => openZoomModal(currentResume)}
>
<Worker workerUrl="https://unpkg.com/[email protected]/build/pdf.worker.min.js">
<Viewer
fileUrl={`http://localhost:3001/bucket/files/${currentResume.file_path}`}
Expand Down
Loading