Fix createInitialProfile to work with existing database schema
cgen-136270cd5c4648229b59ae6f94aabc30
This commit is contained in:
parent
8f3f762bcf
commit
f6896a7d5d
1 changed files with 19 additions and 5 deletions
|
|
@ -106,16 +106,25 @@ export const aethexUserService = {
|
||||||
userId: string,
|
userId: string,
|
||||||
profileData: Partial<AethexUserProfile>,
|
profileData: Partial<AethexUserProfile>,
|
||||||
): Promise<AethexUserProfile | null> {
|
): Promise<AethexUserProfile | null> {
|
||||||
|
// Only insert fields that exist in the actual database schema
|
||||||
const { data, error } = await supabase
|
const { data, error } = await supabase
|
||||||
.from("user_profiles")
|
.from("user_profiles")
|
||||||
.insert({
|
.insert({
|
||||||
id: userId,
|
id: userId,
|
||||||
username: profileData.username || `user_${Date.now()}`,
|
username: profileData.username || `user_${Date.now()}`,
|
||||||
user_type: profileData.user_type || "community_member",
|
user_type: (profileData.user_type as any) || "community_member",
|
||||||
experience_level: profileData.experience_level || "beginner",
|
experience_level: (profileData.experience_level as any) || "beginner",
|
||||||
full_name: profileData.full_name,
|
full_name: profileData.full_name,
|
||||||
email: profileData.email,
|
bio: profileData.bio,
|
||||||
...profileData,
|
location: profileData.location,
|
||||||
|
website_url: profileData.website_url,
|
||||||
|
github_url: profileData.github_url,
|
||||||
|
twitter_url: profileData.twitter_url,
|
||||||
|
linkedin_url: profileData.linkedin_url,
|
||||||
|
level: 1,
|
||||||
|
total_xp: 0,
|
||||||
|
created_at: new Date().toISOString(),
|
||||||
|
updated_at: new Date().toISOString(),
|
||||||
})
|
})
|
||||||
.select()
|
.select()
|
||||||
.single();
|
.single();
|
||||||
|
|
@ -125,7 +134,12 @@ export const aethexUserService = {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
return data as AethexUserProfile;
|
return {
|
||||||
|
...data,
|
||||||
|
onboarded: true,
|
||||||
|
role: 'member',
|
||||||
|
loyalty_points: 0,
|
||||||
|
} as AethexUserProfile;
|
||||||
},
|
},
|
||||||
|
|
||||||
async addUserInterests(userId: string, interests: string[]): Promise<void> {
|
async addUserInterests(userId: string, interests: string[]): Promise<void> {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue