From 2c7431245871142b169a4372841846932b0677bd Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Wed, 1 Oct 2025 00:01:00 +0000 Subject: [PATCH] =?UTF-8?q?Fallback=20when=20user=5Fprofiles=20missing=20?= =?UTF-8?q?=E2=80=94=20return=20local=20demo=20profile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cgen-d54ed16ecf0843a1ba1e24976359c079 --- client/lib/aethex-database-adapter.ts | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/client/lib/aethex-database-adapter.ts b/client/lib/aethex-database-adapter.ts index d6e587b4..a12595a0 100644 --- a/client/lib/aethex-database-adapter.ts +++ b/client/lib/aethex-database-adapter.ts @@ -130,9 +130,26 @@ export const aethexUserService = { } if (isTableMissing(error)) { - throw new Error( - 'Supabase table "user_profiles" is missing. Please run the required migrations.', + console.warn( + 'Supabase table "user_profiles" is missing. Falling back to local demo profile.', ); + const fallback: AethexUserProfile = { + id: user.id, + username: user.email?.split("@")[0] || `user_${Date.now()}`, + full_name: user.email?.split("@")[0] || "user", + email: user.email, + user_type: "community_member" as any, + experience_level: "beginner" as any, + level: 1, + total_xp: 0, + loyalty_points: 0, + created_at: new Date().toISOString(), + updated_at: new Date().toISOString(), + } as AethexUserProfile; + try { + localStorage.setItem(`demo_profile_${user.id}`, JSON.stringify(fallback)); + } catch {} + return fallback; } throw error;