Skip to content

[#81] Rating UI on story page#85

Merged
realproject7 merged 2 commits intomainfrom
task/81-rating-ui
Mar 15, 2026
Merged

[#81] Rating UI on story page#85
realproject7 merged 2 commits intomainfrom
task/81-rating-ui

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Summary

  • New RatingWidget client component with star selector (1-5), optional comment textarea, and wallet signature flow
  • Token-gated: checks balanceOf() on storyline token — non-holders see "Hold storyline tokens to rate" prompt
  • Pre-fills existing rating if user already rated (supports re-rating/update)
  • Displays average rating + count in widget header
  • Lists recent ratings with truncated addresses and comments
  • Signs message via wagmi signMessageAsync() with canonical format "Rate storyline {id} with rating {n}"
  • Added to story page below DonateWidget

Test plan

  • npm run lint passes
  • npm run typecheck passes
  • Token holders see star selector + comment form
  • Non-holders see "Hold tokens to rate" prompt
  • Disconnected wallets see no rating form
  • Submitting rating signs message and POSTs to /api/ratings
  • Existing rating pre-fills form
  • Average + count display updates after submission
  • Recent ratings list shows truncated addresses

Fixes #81

🤖 Generated with Claude Code

- RatingWidget: star selector (1-5), optional comment, wallet signing
- Token-gated: checks balanceOf() before showing form
- Shows existing rating pre-filled for re-rating
- Displays average rating + count in header area
- Lists recent ratings with truncated addresses
- Non-holders see "Hold tokens to rate" prompt

Fixes #81

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

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

Verdict: REQUEST CHANGES

Summary

The widget covers most of the rating flow, but there are two user-visible regressions: stale prefill state when the connected wallet changes, and the average/count were not added to the story header as required by issue #81.

Findings

  • [high] The prefill effect only sets local state when the new wallet already has a rating; it never clears selectedRating/comment when the address changes to a wallet that has not rated yet, or when the wallet disconnects. That means wallet B can inherit wallet A's previous rating in the form and accidentally submit an unintended re-rating.
    • File: src/components/RatingWidget.tsx:88
    • Suggestion: in the same effect, add an else path that resets the local form state when no existing rating is found, and also clear state when address becomes undefined.
  • [medium] Issue #81 explicitly asks for the average rating and count on the story page header, but this PR renders that summary only inside the RatingWidget section below DonateWidget. The story header component remains unchanged.
    • File: src/app/story/[storylineId]/page.tsx:58
    • Suggestion: fetch/pass rating summary into StoryHeader and render the average/count there, keeping the widget for submission and recent ratings below.

Decision

Requesting changes because the stale-wallet prefill is a correctness bug and the current placement does not satisfy the issue's header requirement.

- Reset selectedRating/comment when wallet changes and no existing rating
- Added RatingSummary client component to story header (average + count)
- Uses shared react-query key so header and widget stay in sync

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

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

Verdict: APPROVE

Summary

The follow-up resolves the stale-wallet form state and adds the rating summary to the story header as requested by issue #81. The UI flow now matches the API contract and the issue requirements.

Findings

  • No blocking findings.

Decision

Approving because the rating widget and header summary now satisfy the token-gated UI requirements for #81.

@realproject7 realproject7 merged commit 9d6131c into main Mar 15, 2026
1 check passed
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.

[P5-R4] Rating UI on story page

2 participants