Skip to content

feat(app): Add guide vote functionality on guide page - #210

Draft
kevin8999 wants to merge 31 commits into
bluelearn-org:mainfrom
kevin8999:feat/guide-vote
Draft

feat(app): Add guide vote functionality on guide page#210
kevin8999 wants to merge 31 commits into
bluelearn-org:mainfrom
kevin8999:feat/guide-vote

Conversation

@kevin8999

@kevin8999 kevin8999 commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #175.

This PR lets users upvote and downvote guides. If the user downvotes, a popup will ask them for why they downvoted the guide.

Type of change

  • Bug fix
  • Feature
  • Refactor (no behavior change)
  • Documentation
  • Build / tooling / CI
  • Other: _________

Verification

  • pnpm -r typecheck passes
  • pnpm -r build passes
  • Manually verified in a browser (for UI / behavior changes)
  • Followed the app layout conventions
  • No new dependencies, or new dependencies are justified and AGPL-compatible
  • Change does not violate any non-negotiable principle
  • Documentation only, no changes to the codebase, so no tests required

…tion

This refactor makes `toggleVote()` easier to understand.

The submitted vote will later be used to update the database.

Signed-off-by: Kevin Duong <kevin.duong306@gmail.com>
@andyrodrigues30 andyrodrigues30 added the area:frontend Tasks related to frontend (app) label Jul 27, 2026
kevin8999 and others added 5 commits July 31, 2026 16:45
Adds function to fetch variant ID from
`GET /guides/{slug}/{variantSlug}`

This function only works in development environments because it relies on an `.env` variable.

Signed-off-by: Kevin Duong <kevin.duong306@gmail.com>
Signed-off-by: Kevin Duong <kevinduong306@gmail.com>
This commit adds several changes

- Users can upvote. Upvotes will be saved to the `votes` table
- `getAuthToken()` function that returns the user session token

TODO: Add user error popups (see changes for details)
Signed-off-by: Kevin Duong <kevinduong306@gmail.com>
@kevin8999

Copy link
Copy Markdown
Contributor Author

Upvotes currently work. I still need to implement the following:

  • Downvotes (i.e. stating a reason for the downvote)
  • Popups for errors and downvoting

Signed-off-by: Kevin Duong <kevinduong306@gmail.com>
NOTE: `modal={true}` is required in `combobox.tsx`. Without it,
scrolling would not be possible

TODO: Update database after a reason and note is added
Signed-off-by: Kevin Duong <kevinduong306@gmail.com>
Comment thread app/src/components/ui/combobox.tsx
This is a large commit adds the following changes:

- Splits `toggleVote()` into `toggleVote()` (UI logic) and `submitVote()` (submits vote to backend)
- Uploads reason and note to backend after downvote submission
- Deselects downvote when closing out of dialog

Signed-off-by: Kevin Duong <kevinduong306@gmail.com>
@kevin8999

kevin8999 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

The video below shows the guide vote functionality. My changes should work as intended now. Please let me know if you have any issues 😁!

The only things I am going to add from this point forward are refactors to make the code easier to read.

79058922-4f3c-43b6-bc62-843f4c6209c6.webm

Signed-off-by: Kevin Duong <kevinduong306@gmail.com>
@kevin8999
kevin8999 marked this pull request as ready for review August 6, 2026 02:59
@kevin8999 kevin8999 mentioned this pull request Aug 6, 2026
1 task
Signed-off-by: Kevin Duong <kevinduong306@gmail.com>
Signed-off-by: Kevin Duong <kevinduong306@gmail.com>
WIP: when user presses downvote after it is already selected, pressing it again will "de-select" it. This still needs to be fixed
Signed-off-by: Kevin Duong <kevinduong306@gmail.com>
`GET /variants/:id/vote` will return the user's vote if a user ID is specified

Signed-off-by: Kevin Duong <kevinduong306@gmail.com>
`GET /variants/:id/vote` will return the user's vote if a user ID is specified

Signed-off-by: Kevin Duong <kevinduong306@gmail.com>
This commit forces the downvote to be selected at all times until the user cancels or deletes their vote from the database

Signed-off-by: Kevin Duong <kevinduong306@gmail.com>
Signed-off-by: Kevin Duong <kevinduong306@gmail.com>
Signed-off-by: Kevin Duong <kevinduong306@gmail.com>

@andyrodrigues30 andyrodrigues30 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

See other comment.

Also the vote button colors don't persist after the page is refreshed

Comment thread app/src/routes/guides/$slug/index.tsx Outdated
};
}

function DownvoteDialog({ isOpen, setIsOpen, setVote, vote }) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

rename to DownvoteModal and move to separate file DownvoteModal.tsx under @/components/modals/DownvoteModal.tsx.

Also change to an export arrow function see GuideSubmitModal.tsx as an example.

This commit also replaces `toggleVote()` with `setVote()`. This change may need to be reverted in the future

Signed-off-by: Kevin Duong <kevinduong306@gmail.com>
 into feat/guide-vote

Signed-off-by: Kevin Duong <kevinduong306@gmail.com>
Signed-off-by: Kevin Duong <kevinduong306@gmail.com>
@kevin8999
kevin8999 marked this pull request as draft August 9, 2026 21:09
Signed-off-by: Kevin Duong <kevinduong306@gmail.com>
`API_BASE` is also moved outside its function

Signed-off-by: Kevin Duong <kevinduong306@gmail.com>
Signed-off-by: Kevin Duong <kevinduong306@gmail.com>
Signed-off-by: Kevin Duong <kevinduong306@gmail.com>
Signed-off-by: Kevin Duong <kevinduong306@gmail.com>
Signed-off-by: Kevin Duong <kevinduong306@gmail.com>
Signed-off-by: Kevin Duong <kevinduong306@gmail.com>
Signed-off-by: Kevin Duong <kevinduong306@gmail.com>
Signed-off-by: Kevin Duong <kevinduong306@gmail.com>
Signed-off-by: Kevin Duong <kevinduong306@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:frontend Tasks related to frontend (app)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Implement guide vote functionality on the guide page

2 participants