From a50af29ccb5b658df69dfe6e31252e8269b63be2 Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Sat, 27 Sep 2025 22:34:28 +0000 Subject: [PATCH] Improve updateProfile to create row when missing; include banner_url in profile creation cgen-b9fe2367200f495684300fd4a7ef38cb --- client/lib/aethex-database-adapter.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/client/lib/aethex-database-adapter.ts b/client/lib/aethex-database-adapter.ts index fd8a635b..5ac1f5d4 100644 --- a/client/lib/aethex-database-adapter.ts +++ b/client/lib/aethex-database-adapter.ts @@ -135,6 +135,15 @@ export const aethexUserService = { const mock = await mockAuth.updateProfile(userId as any, updates as any); return mock as unknown as AethexUserProfile; } + if ((error as any)?.code === "PGRST116") { + const { data: upserted, error: upsertError } = await supabase + .from("user_profiles") + .upsert({ id: userId, user_type: "community_member", ...updates } as any, { onConflict: "id" }) + .select() + .single(); + if (upsertError) throw upsertError; + return upserted as AethexUserProfile; + } throw error; } @@ -160,6 +169,7 @@ export const aethexUserService = { github_url: profileData.github_url, twitter_url: profileData.twitter_url, linkedin_url: profileData.linkedin_url, + banner_url: (profileData as any).banner_url, level: 1, total_xp: 0, created_at: new Date().toISOString(),