Skip to content

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

Merged

Conversation

Advik-Gupta
Copy link

No description provided.

Comment on lines 18 to 21
let transformedPapers = usersPapers.map((paper) => ({
subject: paper.subject,
slots: [paper.slot],
}));
Copy link
Collaborator

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

Comment on lines 24 to 26
transformedPapers = Array.from(
new Map(transformedPapers.map((item) => [item.subject, item])).values(),
);
Copy link
Collaborator

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
Copy link
Collaborator

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

Comment on lines 23 to 33
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
}
};

Copy link
Collaborator

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?

Copy link
Collaborator

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.

Copy link
Collaborator

@abhitrueprogrammer abhitrueprogrammer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work

@abhitrueprogrammer abhitrueprogrammer merged commit a6baf37 into CodeChefVIT:starredPapers Jun 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants