Fix review system: display real names and check approval status

Changes:
- ProductReviews.tsx: Use LEFT JOIN and fetch reviewer_name field
- ReviewModal.tsx: Store reviewer_name at submission time
- ProductDetail.tsx: Check is_approved=true in checkUserReview()
- Add migration for reviewer_name column and approval index

This fixes two issues:
1. Reviews now show real account names instead of "Anonymous"
2. Members no longer see "menunggu moderasi" after approval

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
dwindown
2025-12-25 22:29:48 +07:00
parent 466cca5cb4
commit e347a780f8
4 changed files with 31 additions and 5 deletions

View File

@@ -0,0 +1,7 @@
-- Add reviewer_name column to store display name at submission time
-- This ensures reviews always show the author's name even if profile is deleted later
ALTER TABLE reviews
ADD COLUMN reviewer_name TEXT;
-- Create index for efficient approval status queries
CREATE INDEX idx_reviews_is_approved ON reviews(is_approved);