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

Toggle bookmark hook #52

Open
wants to merge 31 commits into
base: dev
Choose a base branch
from
Open

Toggle bookmark hook #52

wants to merge 31 commits into from

Conversation

davidgit3000
Copy link
Collaborator

@davidgit3000 davidgit3000 commented Jun 13, 2024

I created a custom hook called useBookmark.jsx (located inside src/hooks).

  • For now, the only component I modified is Article.jsx
  • My task is combining both CREATE and DELETE functionality as stated in task updates on Monday. I am not completely sure about API fetch link (need to confirm from backend whether it is /api/users/bookmarks or /api/bookmarks).
  • This hook returns 3 things: loading state, an error message, and a function that takes in 3 parameters (article id, bookmark status (boolean), and a function for bookmark toggling). The third parameter servers as a function that will be defined in each component itself.
  • The function toggleBookmark on the client side is only called when there is a successful response from the server defined in useBookmark hook.
  • Two dependencies I added to this branch are react-hot-toast (to show error/success message as a Toaster component) and react-icons (to display Loading icon in loading state returned from useBookmark)

Issue

There arises an issue that I got two toast messages at the same time rather than displaying once

image

image

plexin123 and others added 30 commits May 30, 2024 15:53
add image Storage file
Make some changes about .env and connection refused
fix some issues
small change
Creates conflict when converting to a JSON object
…intital state of isBookmarked field in Article.jsx
fix: added auth token to request in article results page
will ONLY CHECK if user is logged in, but wont throw error if they are not logged in
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.

4 participants