chore: Remove debug logging from profile operations

Cleaned up console.log statements added during debugging:
- Removed verbose logging from ProfileSettings loadProfile
- Removed verbose logging from ProfileSettings updateProfile
- Removed verbose logging from Dashboard fetchProfile

Kept only essential error logging for production.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-29 05:26:43 +03:00
parent 205e22e083
commit 82ff3fd283
2 changed files with 9 additions and 34 deletions
+1 -8
View File
@@ -32,8 +32,6 @@ 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')
@@ -41,9 +39,6 @@ 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
@@ -67,7 +62,6 @@ export default function Dashboard() {
// If there are fields to update, update the profile // If there are fields to update, update the profile
if (Object.keys(needsUpdate).length > 0) { if (Object.keys(needsUpdate).length > 0) {
console.log('🔄 Syncing profile from Auth metadata:', needsUpdate);
const { error: updateError } = await supabase const { error: updateError } = await supabase
.from('profiles') .from('profiles')
.update(needsUpdate) .update(needsUpdate)
@@ -83,10 +77,9 @@ 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);
} }
+8 -26
View File
@@ -42,19 +42,19 @@ export default function ProfileSettings() {
const loadProfile = async () => { const loadProfile = async () => {
try { try {
console.log('📥 LOADING PROFILE in ProfileSettings for user:', user?.id);
const { data, error } = await supabase 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); if (error) {
console.log('❌ Load error:', error); console.error('Error loading profile:', error);
return;
}
if (data) { if (data) {
const profileState = { setProfile({
username: data.username || '', username: data.username || '',
full_name: data.full_name || '', full_name: data.full_name || '',
bio: data.bio || '', bio: data.bio || '',
@@ -67,31 +67,16 @@ 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 {
console.log('💾 CALLING UPSERT FUNCTION with data:', {
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
});
console.log('👤 User ID:', user?.id);
// Call the secure upsert function // Call the secure upsert function
const { data, error } = await supabase.rpc('upsert_user_profile', { const { data, error } = await supabase.rpc('upsert_user_profile', {
p_username: profile.username || '', p_username: profile.username || '',
@@ -107,9 +92,6 @@ export default function ProfileSettings() {
p_notifications_sms: profile.notifications_sms ?? false p_notifications_sms: profile.notifications_sms ?? false
}); });
console.log('✅ Function response data:', data);
console.log('❌ Function error:', error);
if (error) throw error; if (error) throw error;
toast({ toast({
@@ -120,7 +102,7 @@ export default function ProfileSettings() {
// Reload profile to ensure state is in sync // Reload profile to ensure state is in sync
await loadProfile(); await loadProfile();
} catch (error: any) { } catch (error: any) {
console.error('Profile update failed:', error); console.error('Profile update failed:', error);
toast({ toast({
title: 'Error', title: 'Error',
description: error?.message || 'Failed to update profile', description: error?.message || 'Failed to update profile',