From 50a642b07bd3fa5cd84a5e1ecae95598f24ad807 Mon Sep 17 00:00:00 2001 From: dwindown Date: Fri, 26 Dec 2025 00:29:39 +0700 Subject: [PATCH] Fix reviewer name display in TestimonialsSection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Change from INNER JOIN to LEFT JOIN (profiles:user_id → profiles!user_id) - Add reviewer_name to SELECT clause - Update fallback logic to prioritize reviewer_name over profiles.name - Add debug console logging This fixes the "Anonymous" reviewer name issue on homepage. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- src/components/reviews/TestimonialsSection.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/reviews/TestimonialsSection.tsx b/src/components/reviews/TestimonialsSection.tsx index 571600d..6513e64 100644 --- a/src/components/reviews/TestimonialsSection.tsx +++ b/src/components/reviews/TestimonialsSection.tsx @@ -8,6 +8,7 @@ interface Review { title: string; body: string; created_at: string; + reviewer_name: string | null; profiles: { name: string | null } | null; } @@ -20,13 +21,18 @@ export function TestimonialsSection() { }, []); const fetchReviews = async () => { - const { data } = await supabase + console.log('TestimonialsSection fetchReviews called'); + + const { data, error } = await supabase .from('reviews') - .select('id, rating, title, body, created_at, profiles:user_id (name)') + .select('id, rating, title, body, created_at, reviewer_name, profiles!user_id (name)') .eq('is_approved', true) .order('created_at', { ascending: false }) .limit(6); + console.log('TestimonialsSection - Raw data:', data); + console.log('TestimonialsSection - Error:', error); + if (data) { setReviews(data as unknown as Review[]); } @@ -45,7 +51,7 @@ export function TestimonialsSection() { rating={review.rating} title={review.title} body={review.body} - authorName={review.profiles?.name || 'Anonymous'} + authorName={review.reviewer_name || review.profiles?.name || 'Anonymous'} date={review.created_at} /> ))}