Use live profile data for reviews instead of frozen reviewer_name

Changes:
- Revert to using profiles!user_id (name, avatar_url) JOIN for reviews
- Remove reviewer_name storage from ReviewModal (no longer needed)
- Add avatar display to ReviewCard component
- Reviews now sync automatically with profile changes
- Public queries safely expose only name + avatar via RLS

This ensures:
- Name/avatar changes update across all reviews automatically
- No frozen/outdated reviewer data
- Only public profile fields exposed (secure)
- Reviews serve as live, credible social proof

🤖 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-26 15:39:58 +07:00
parent 74b7dd09ea
commit a824e101ed
4 changed files with 20 additions and 41 deletions

View File

@@ -8,8 +8,7 @@ interface Review {
title: string;
body: string;
created_at: string;
reviewer_name: string | null;
profiles: { name: string | null } | null;
profiles: { name: string | null; avatar_url: string | null } | null;
}
export function TestimonialsSection() {
@@ -23,7 +22,7 @@ export function TestimonialsSection() {
const fetchReviews = async () => {
const { data } = await supabase
.from('reviews')
.select('id, rating, title, body, created_at, reviewer_name, profiles!user_id (name)')
.select('id, rating, title, body, created_at, profiles!user_id (name, avatar_url)')
.eq('is_approved', true)
.order('created_at', { ascending: false })
.limit(6);
@@ -46,7 +45,8 @@ export function TestimonialsSection() {
rating={review.rating}
title={review.title}
body={review.body}
authorName={review.profiles?.name || review.reviewer_name || 'Anonymous'}
authorName={review.profiles?.name || 'Anonymous'}
authorAvatar={review.profiles?.avatar_url}
date={review.created_at}
/>
))}