feat: add upvote functionality for learning paths#193
feat: add upvote functionality for learning paths#193sebmuehlbauer wants to merge 1 commit intofnplus:masterfrom
Conversation
3bc4efd to
290e943
Compare
290e943 to
c9efaab
Compare
|
@codex Review this PR |
There was a problem hiding this comment.
π‘ Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c9efaab966
βΉοΈ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with π.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| const UPVOTE_PATH = gql` | ||
| mutation UpvotePath($pathId: Int!, $userId: String!) { | ||
| update_learning_path_by_pk(pk_columns: {id: $pathId}, _append: {voted_by: [ $userId ]}) { |
There was a problem hiding this comment.
Target the correct Hasura mutation and vote storage model
This mutation uses update_learning_path_by_pk with _append on voted_by, but the rest of this codebase consistently targets Learning_Paths plus a separate votes relation (for example, src/components/EditPath/editPath.js mutates update_Learning_Paths and src/pages/search.js reads votes/votes_aggregate), so this operation does not match the existing schema shape and upvote requests will fail at runtime when invoked.
Useful? React with πΒ / π.
| if (votedBy.includes(userId)) { | ||
| message.info('You have already upvoted this path!'); |
There was a problem hiding this comment.
Block repeated upvotes until local vote state is refreshed
The duplicate guard checks only the incoming votedBy prop, but this component never updates local state after a successful mutation; if the user clicks again before parent data refreshes, the check still passes and another upvote mutation is sent, which can record duplicate votes for the same user and inflate counts.
Useful? React with πΒ / π.
|
@sebmuehlbauer Please check these review comments and see if the PR needs any changes |
Fixes #20
This PR introduces an
UpvoteButtoncomponent that allows authenticated users to upvote learning paths.upvoted_byfield (JSON/Array storage) in the database.This PR was autonomously generated by Pangea 3 β an AI-powered development system.