mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-04-27 16:17:55 +00:00
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:
@@ -32,8 +32,6 @@ export default function Dashboard() {
|
||||
const fetchProfile = async () => {
|
||||
if (!user) return;
|
||||
|
||||
console.log('📥 FETCHING PROFILE for user:', user.id);
|
||||
|
||||
try {
|
||||
const { data, error } = await supabase
|
||||
.from('profiles')
|
||||
@@ -41,9 +39,6 @@ export default function Dashboard() {
|
||||
.eq('id', user.id)
|
||||
.single();
|
||||
|
||||
console.log('📊 FETCHED PROFILE DATA:', data);
|
||||
console.log('❌ Fetch error:', error);
|
||||
|
||||
if (error) throw error;
|
||||
|
||||
// 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 (Object.keys(needsUpdate).length > 0) {
|
||||
console.log('🔄 Syncing profile from Auth metadata:', needsUpdate);
|
||||
const { error: updateError } = await supabase
|
||||
.from('profiles')
|
||||
.update(needsUpdate)
|
||||
@@ -83,10 +77,9 @@ export default function Dashboard() {
|
||||
// Note: Email verification is handled by Supabase Auth (user.email_confirmed_at)
|
||||
// We don't store it in profiles table to avoid duplication
|
||||
|
||||
console.log('✅ SETTING PROFILE STATE TO:', data);
|
||||
setProfile(data);
|
||||
} catch (error) {
|
||||
console.error('❌ Error fetching profile:', error);
|
||||
console.error('Error fetching profile:', error);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
@@ -42,19 +42,19 @@ export default function ProfileSettings() {
|
||||
|
||||
const loadProfile = async () => {
|
||||
try {
|
||||
console.log('📥 LOADING PROFILE in ProfileSettings for user:', user?.id);
|
||||
|
||||
const { data, error } = await supabase
|
||||
.from('profiles')
|
||||
.select('*')
|
||||
.eq('id', user?.id)
|
||||
.single();
|
||||
|
||||
console.log('📊 LOADED PROFILE DATA:', data);
|
||||
console.log('❌ Load error:', error);
|
||||
if (error) {
|
||||
console.error('Error loading profile:', error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (data) {
|
||||
const profileState = {
|
||||
setProfile({
|
||||
username: data.username || '',
|
||||
full_name: data.full_name || '',
|
||||
bio: data.bio || '',
|
||||
@@ -67,31 +67,16 @@ export default function ProfileSettings() {
|
||||
notifications_push: data.notifications_push ?? false,
|
||||
notifications_sms: data.notifications_sms ?? false,
|
||||
two_factor_enabled: data.two_factor_enabled ?? false
|
||||
};
|
||||
|
||||
console.log('✅ SETTING PROFILE STATE TO:', profileState);
|
||||
setProfile(profileState);
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('❌ Error loading profile:', error);
|
||||
console.error('Error loading profile:', error);
|
||||
}
|
||||
};
|
||||
|
||||
const updateProfile = async () => {
|
||||
setLoading(true);
|
||||
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
|
||||
const { data, error } = await supabase.rpc('upsert_user_profile', {
|
||||
p_username: profile.username || '',
|
||||
@@ -107,9 +92,6 @@ export default function ProfileSettings() {
|
||||
p_notifications_sms: profile.notifications_sms ?? false
|
||||
});
|
||||
|
||||
console.log('✅ Function response data:', data);
|
||||
console.log('❌ Function error:', error);
|
||||
|
||||
if (error) throw error;
|
||||
|
||||
toast({
|
||||
@@ -120,7 +102,7 @@ export default function ProfileSettings() {
|
||||
// Reload profile to ensure state is in sync
|
||||
await loadProfile();
|
||||
} catch (error: any) {
|
||||
console.error('❌ Profile update failed:', error);
|
||||
console.error('Profile update failed:', error);
|
||||
toast({
|
||||
title: 'Error',
|
||||
description: error?.message || 'Failed to update profile',
|
||||
|
||||
Reference in New Issue
Block a user