mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-06-17 06:31:04 +00:00
debug: Add comprehensive logging to profile save/fetch operations
Added detailed console logging to track data flow: - ProfileSettings: Log data being saved and save responses - ProfileSettings: Log data being loaded when page opens - Dashboard: Log profile data being fetched and set to state This will help identify where profile data is being lost between save in ProfileSettings and display in Dashboard. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -32,6 +32,8 @@ export default function Dashboard() {
|
|||||||
const fetchProfile = async () => {
|
const fetchProfile = async () => {
|
||||||
if (!user) return;
|
if (!user) return;
|
||||||
|
|
||||||
|
console.log('📥 FETCHING PROFILE for user:', user.id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { data, error } = await supabase
|
const { data, error } = await supabase
|
||||||
.from('profiles')
|
.from('profiles')
|
||||||
@@ -39,6 +41,9 @@ export default function Dashboard() {
|
|||||||
.eq('id', user.id)
|
.eq('id', user.id)
|
||||||
.single();
|
.single();
|
||||||
|
|
||||||
|
console.log('📊 FETCHED PROFILE DATA:', data);
|
||||||
|
console.log('❌ Fetch error:', error);
|
||||||
|
|
||||||
if (error) throw error;
|
if (error) throw error;
|
||||||
|
|
||||||
// Auto-sync user metadata from Auth to profiles if missing
|
// Auto-sync user metadata from Auth to profiles if missing
|
||||||
@@ -78,9 +83,10 @@ export default function Dashboard() {
|
|||||||
// Note: Email verification is handled by Supabase Auth (user.email_confirmed_at)
|
// Note: Email verification is handled by Supabase Auth (user.email_confirmed_at)
|
||||||
// We don't store it in profiles table to avoid duplication
|
// We don't store it in profiles table to avoid duplication
|
||||||
|
|
||||||
|
console.log('✅ SETTING PROFILE STATE TO:', data);
|
||||||
setProfile(data);
|
setProfile(data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching profile:', error);
|
console.error('❌ Error fetching profile:', error);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,14 +42,19 @@ export default function ProfileSettings() {
|
|||||||
|
|
||||||
const loadProfile = async () => {
|
const loadProfile = async () => {
|
||||||
try {
|
try {
|
||||||
const { data } = await supabase
|
console.log('📥 LOADING PROFILE in ProfileSettings for user:', user?.id);
|
||||||
|
|
||||||
|
const { data, error } = await supabase
|
||||||
.from('profiles')
|
.from('profiles')
|
||||||
.select('*')
|
.select('*')
|
||||||
.eq('id', user?.id)
|
.eq('id', user?.id)
|
||||||
.single();
|
.single();
|
||||||
|
|
||||||
|
console.log('📊 LOADED PROFILE DATA:', data);
|
||||||
|
console.log('❌ Load error:', error);
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
setProfile({
|
const profileState = {
|
||||||
username: data.username || '',
|
username: data.username || '',
|
||||||
full_name: data.full_name || '',
|
full_name: data.full_name || '',
|
||||||
bio: data.bio || '',
|
bio: data.bio || '',
|
||||||
@@ -62,30 +67,42 @@ export default function ProfileSettings() {
|
|||||||
notifications_push: data.notifications_push ?? false,
|
notifications_push: data.notifications_push ?? false,
|
||||||
notifications_sms: data.notifications_sms ?? false,
|
notifications_sms: data.notifications_sms ?? false,
|
||||||
two_factor_enabled: data.two_factor_enabled ?? false
|
two_factor_enabled: data.two_factor_enabled ?? false
|
||||||
});
|
};
|
||||||
|
|
||||||
|
console.log('✅ SETTING PROFILE STATE TO:', profileState);
|
||||||
|
setProfile(profileState);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error loading profile:', error);
|
console.error('❌ Error loading profile:', error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateProfile = async () => {
|
const updateProfile = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
const { error } = await supabase
|
const updateData = {
|
||||||
|
username: profile.username,
|
||||||
|
full_name: profile.full_name,
|
||||||
|
bio: profile.bio,
|
||||||
|
phone_number: profile.phone_number,
|
||||||
|
location: profile.location,
|
||||||
|
website: profile.website,
|
||||||
|
language: profile.language,
|
||||||
|
theme: profile.theme,
|
||||||
|
updated_at: new Date().toISOString()
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log('💾 SAVING PROFILE DATA:', updateData);
|
||||||
|
console.log('👤 User ID:', user?.id);
|
||||||
|
|
||||||
|
const { data, error } = await supabase
|
||||||
.from('profiles')
|
.from('profiles')
|
||||||
.update({
|
.update(updateData)
|
||||||
username: profile.username,
|
.eq('id', user?.id)
|
||||||
full_name: profile.full_name,
|
.select();
|
||||||
bio: profile.bio,
|
|
||||||
phone_number: profile.phone_number,
|
console.log('✅ Save response data:', data);
|
||||||
location: profile.location,
|
console.log('❌ Save error:', error);
|
||||||
website: profile.website,
|
|
||||||
language: profile.language,
|
|
||||||
theme: profile.theme,
|
|
||||||
updated_at: new Date().toISOString()
|
|
||||||
})
|
|
||||||
.eq('id', user?.id);
|
|
||||||
|
|
||||||
if (error) throw error;
|
if (error) throw error;
|
||||||
|
|
||||||
@@ -94,6 +111,7 @@ export default function ProfileSettings() {
|
|||||||
description: 'Profile updated successfully',
|
description: 'Profile updated successfully',
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.error('❌ Profile update failed:', error);
|
||||||
toast({
|
toast({
|
||||||
title: 'Error',
|
title: 'Error',
|
||||||
description: 'Failed to update profile',
|
description: 'Failed to update profile',
|
||||||
|
|||||||
Reference in New Issue
Block a user