Fix review name capture with auth metadata fallback
Changes:
- ReviewModal now fetches name from profiles, auth metadata, or email
- Added console logging to debug review data
- Falls back to email username if no name found
- This ensures reviewer_name is always populated
For existing reviews without names, run:
UPDATE reviews r
SET reviewer_name = (
SELECT COALESCE(
raw_user_meta_data->>'name',
SPLIT_PART(email, '@', 1)
)
FROM auth.users WHERE id = r.user_id
)
WHERE reviewer_name IS NULL;
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -41,6 +41,8 @@ export function ProductReviews({ productId, type }: ProductReviewsProps) {
|
||||
|
||||
const { data } = await query.order('created_at', { ascending: false }).limit(3);
|
||||
|
||||
console.log('Raw reviews data:', data);
|
||||
|
||||
if (data && data.length > 0) {
|
||||
const typedData = data as unknown as Review[];
|
||||
setReviews(typedData);
|
||||
|
||||
Reference in New Issue
Block a user