Fix reviewer name display in TestimonialsSection
- 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 <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,7 @@ interface Review {
|
|||||||
title: string;
|
title: string;
|
||||||
body: string;
|
body: string;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
|
reviewer_name: string | null;
|
||||||
profiles: { name: string | null } | null;
|
profiles: { name: string | null } | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,13 +21,18 @@ export function TestimonialsSection() {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const fetchReviews = async () => {
|
const fetchReviews = async () => {
|
||||||
const { data } = await supabase
|
console.log('TestimonialsSection fetchReviews called');
|
||||||
|
|
||||||
|
const { data, error } = await supabase
|
||||||
.from('reviews')
|
.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)
|
.eq('is_approved', true)
|
||||||
.order('created_at', { ascending: false })
|
.order('created_at', { ascending: false })
|
||||||
.limit(6);
|
.limit(6);
|
||||||
|
|
||||||
|
console.log('TestimonialsSection - Raw data:', data);
|
||||||
|
console.log('TestimonialsSection - Error:', error);
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
setReviews(data as unknown as Review[]);
|
setReviews(data as unknown as Review[]);
|
||||||
}
|
}
|
||||||
@@ -45,7 +51,7 @@ export function TestimonialsSection() {
|
|||||||
rating={review.rating}
|
rating={review.rating}
|
||||||
title={review.title}
|
title={review.title}
|
||||||
body={review.body}
|
body={review.body}
|
||||||
authorName={review.profiles?.name || 'Anonymous'}
|
authorName={review.reviewer_name || review.profiles?.name || 'Anonymous'}
|
||||||
date={review.created_at}
|
date={review.created_at}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
|||||||
Reference in New Issue
Block a user