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

feat: add library favorites #519

Merged
merged 2 commits into from
Nov 25, 2024
Merged

Conversation

CK-7vn
Copy link
Contributor

@CK-7vn CK-7vn commented Nov 21, 2024

Description of the change

This feature adds the ability for users to favorite libraries. A user clicks the star icon in the right hand corner of the LibraryCard component located in the Libraries tab of Open Content, and that Library is added to the library_favorites table. This also opens up two endpoints in handlers/open_content.go, GET /api/open-content/favorites and PUT /api/open-content/{id}/save. The GET requests returns a users favorites in the order of most recently favorited. The PUT handler checks the database and either adds a favorite row in the library_favorites table for that library and that user, and or soft-deletes the favorite from the library_favorites table if an entry for that user, and that library is already present. The favorites tab combined Video favorites and Library favorites into one cumulative page so that a user can view all of their open content favorites.

Screenshot(s)

Screenshot from 2024-11-21 16-17-35
Screenshot from 2024-11-21 16-17-51
Screenshot from 2024-11-21 16-18-06
Screenshot from 2024-11-21 16-18-16
Screenshot from 2024-11-21 16-19-05

Additional context

A couple unrelated changes were changing the videos favoriting icon from a bookmark to a star, and also adding an explicit favorite route for videos because the prior implementation checked an {action} which required admin privileges with the new feature flagging, this made it impossible for users to favorite a video, so that was changed and added as well.

@CK-7vn CK-7vn closed this Nov 21, 2024
@CK-7vn CK-7vn added the HAS MIGRATION This PR has a migration added. Please collaborate with the author to resolve the ordering label Nov 21, 2024
@CK-7vn CK-7vn reopened this Nov 21, 2024
@CK-7vn
Copy link
Contributor Author

CK-7vn commented Nov 23, 2024

Screenshot from 2024-11-22 17-31-54
Screenshot from 2024-11-22 17-32-14
Screenshot from 2024-11-22 17-32-30

ALSO
I fixed the routing when an Admin switches from student view back to admin view while on the favorites page.

@CK-7vn
Copy link
Contributor Author

CK-7vn commented Nov 23, 2024

Couple more things I need to figure out, just involving moving the Unfavoriting to the Favorites Card. I'm tapping out tonight. Sorry. I'll make sure its done tomorrow. ASAP.

@CK-7vn
Copy link
Contributor Author

CK-7vn commented Nov 23, 2024

Screenshot from 2024-11-23 10-24-41
Screenshot from 2024-11-23 10-25-05
Screenshot from 2024-11-23 10-32-52
Screenshot from 2024-11-23 10-34-59

Ok Ok @calisio <- I switched the unfavoriting into the card, sorry, it should have been that way in the first place. The payload is necessary because of the way that the unfavoriting works on the backend...but I did switch change as much as I could...the bug with the Admin switching back to student view was fixed, double checked and the favorites are still being returned to you in order of most recently favorited, but that handler did change slightly to add the pagination.

@calisio
Copy link
Contributor

calisio commented Nov 25, 2024

I think besides those comments, everything else is looking good (as long as @PThorpe92 thinks the backend looks good!)

Copy link
Member

@PThorpe92 PThorpe92 left a comment

Choose a reason for hiding this comment

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

backend looks good 👍

@CK-7vn
Copy link
Contributor Author

CK-7vn commented Nov 25, 2024

Sweeet! I just force pushed those updates @calisio

@calisio calisio merged commit 5509a87 into UnlockedLabs:main Nov 25, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
HAS MIGRATION This PR has a migration added. Please collaborate with the author to resolve the ordering
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow Residents to Favorite Libraries
3 participants