From d02bb61fa97597d0a623d04db270785c4b346dab Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Sat, 4 Oct 2025 21:35:25 +0000 Subject: [PATCH] Add offline fallback for updateProfile cgen-b516934ae3f149039e5c5ad234ef11bb --- client/lib/aethex-database-adapter.ts | 39 +++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/client/lib/aethex-database-adapter.ts b/client/lib/aethex-database-adapter.ts index db32a588..694ad8b8 100644 --- a/client/lib/aethex-database-adapter.ts +++ b/client/lib/aethex-database-adapter.ts @@ -376,6 +376,45 @@ export const aethexUserService = { userId: string, updates: Partial, ): Promise { + if (!isSupabaseConfigured) { + const nowIso = new Date().toISOString(); + const stored = await mockAuth.updateProfile( + userId, + { + ...updates, + onboarded: true, + user_type: (updates as any)?.user_type ?? "game_developer", + experience_level: (updates as any)?.experience_level ?? "beginner", + updated_at: nowIso, + } as any, + ); + + const normalized = normalizeProfile( + { + ...stored, + user_type: + (stored as any)?.user_type ?? (updates as any)?.user_type ?? "game_developer", + experience_level: + (stored as any)?.experience_level ?? + (updates as any)?.experience_level ?? + "beginner", + total_xp: (stored as any)?.total_xp ?? 0, + level: (stored as any)?.level ?? 1, + loyalty_points: (stored as any)?.loyalty_points ?? 0, + current_streak: (stored as any)?.current_streak ?? 1, + longest_streak: + (stored as any)?.longest_streak ?? + Math.max((stored as any)?.current_streak ?? 1, 1), + last_streak_at: (stored as any)?.last_streak_at ?? null, + updated_at: (stored as any)?.updated_at ?? nowIso, + created_at: (stored as any)?.created_at ?? nowIso, + }, + stored.email ?? (updates as any)?.email ?? null, + ); + + return normalized; + } + ensureSupabase(); const { data, error } = await supabase