-
Notifications
You must be signed in to change notification settings - Fork 21
Created new component to display users starred papers #217
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
Created new component to display users starred papers #217
Conversation
src/app/api/user-papers/route.ts
Outdated
let transformedPapers = usersPapers.map((paper) => ({ | ||
subject: paper.subject, | ||
slots: [paper.slot], | ||
})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a single paper can have multiple slots right
src/app/api/user-papers/route.ts
Outdated
transformedPapers = Array.from( | ||
new Map(transformedPapers.map((item) => [item.subject, item])).values(), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rather interesting way of checking duplicates
}); | ||
return response.data.papers.length; // Assuming the API returns an array of papers | ||
} catch (error) { | ||
return 0; // Return 0 if there's no papers found or an error occurs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the state that notifies of an error and the state that means 0 papers found should be different. Preferably the error should be printed or toasted
const fetchPaperQuantityByName = async (subjectName: string) => { | ||
try { | ||
const response = await axios.get("/api/papers", { | ||
params: { subject: subjectName }, | ||
}); | ||
return response.data.papers.length; // Assuming the API returns an array of papers | ||
} catch (error) { | ||
return 0; // Return 0 if there's no papers found or an error occurs | ||
} | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this function being used somewhere?
src/components/UsersPapers.tsx
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are gonna change it later we'll let this copy paste slider, otherwise making a simple template and then using it in both the upcoming papers and user Paper components would have been better. See if you can refactor it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work
No description provided.