Add enhanced debugging for review API response

Added console logging to track:
- When fetchReviews is called
- Raw API response data
- Any errors from Supabase

This will help debug why reviewer_name is not appearing
in the API response.

🤖 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 00:10:07 +07:00
parent 196d3e9211
commit a412baad53

View File

@@ -28,6 +28,8 @@ export function ProductReviews({ productId, type }: ProductReviewsProps) {
}, [productId, type]); }, [productId, type]);
const fetchReviews = async () => { const fetchReviews = async () => {
console.log('fetchReviews called - productId:', productId, 'type:', type);
let query = supabase let query = supabase
.from('reviews') .from('reviews')
.select('id, rating, title, body, created_at, reviewer_name, profiles!user_id (name)') .select('id, rating, title, body, created_at, reviewer_name, profiles!user_id (name)')
@@ -39,9 +41,10 @@ export function ProductReviews({ productId, type }: ProductReviewsProps) {
query = query.eq('type', type); query = query.eq('type', type);
} }
const { data } = await query.order('created_at', { ascending: false }).limit(3); const { data, error } = await query.order('created_at', { ascending: false }).limit(3);
console.log('Raw reviews data:', data); console.log('Raw reviews data:', data);
console.log('Error:', error);
if (data && data.length > 0) { if (data && data.length > 0) {
const typedData = data as unknown as Review[]; const typedData = data as unknown as Review[];