Improve updateProfile to create row when missing; include banner_url in profile creation
cgen-b9fe2367200f495684300fd4a7ef38cb
This commit is contained in:
parent
a4a0c0329b
commit
a50af29ccb
1 changed files with 10 additions and 0 deletions
|
|
@ -135,6 +135,15 @@ export const aethexUserService = {
|
||||||
const mock = await mockAuth.updateProfile(userId as any, updates as any);
|
const mock = await mockAuth.updateProfile(userId as any, updates as any);
|
||||||
return mock as unknown as AethexUserProfile;
|
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;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -160,6 +169,7 @@ export const aethexUserService = {
|
||||||
github_url: profileData.github_url,
|
github_url: profileData.github_url,
|
||||||
twitter_url: profileData.twitter_url,
|
twitter_url: profileData.twitter_url,
|
||||||
linkedin_url: profileData.linkedin_url,
|
linkedin_url: profileData.linkedin_url,
|
||||||
|
banner_url: (profileData as any).banner_url,
|
||||||
level: 1,
|
level: 1,
|
||||||
total_xp: 0,
|
total_xp: 0,
|
||||||
created_at: new Date().toISOString(),
|
created_at: new Date().toISOString(),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue