diff --git a/app/complete-profile/page.tsx b/app/complete-profile/page.tsx index 4478f289..808a8eac 100644 --- a/app/complete-profile/page.tsx +++ b/app/complete-profile/page.tsx @@ -71,6 +71,8 @@ export default function CompleteProfile() { } } catch (profileError) { console.error('Error checking profile:', profileError); + // Show a more user-friendly error message + toast.error('Unable to load profile data. Please refresh the page and try again.'); // Continue with the form - profileService will handle creation if needed } @@ -351,15 +353,15 @@ export default function CompleteProfile() { - {/* Username Preview */} - {username && ( -
- Preview: - - @{username.toLowerCase()} - -
- )} + {/* Username Preview */} + {username && ( +
+ Preview: + + @{username.toLowerCase()} + +
+ )} {/* Username Status Messages */} {isCheckingUsername && ( @@ -369,45 +371,45 @@ export default function CompleteProfile() { )} - {!isCheckingUsername && usernameAvailable === true && ( -
- -

Username is available!

-
- )} + {!isCheckingUsername && usernameAvailable === true && ( +
+ +

Username is available!

+
+ )} - {!isCheckingUsername && usernameAvailable === false && !usernameError && ( -
- -

Username is already taken

-
- )} + {!isCheckingUsername && usernameAvailable === false && !usernameError && ( +
+ +

Username is already taken

+
+ )} - {usernameError && ( -
- -

{usernameError}

-
- )} + {usernameError && ( +
+ +

{usernameError}

+
+ )} - {/* Username Requirements */} -
-

Username Requirements:

- -
+ {/* Username Requirements */} +
+

Username Requirements:

+ +
@@ -435,15 +437,15 @@ export default function CompleteProfile() { - {/* Footer */} -
-

- By continuing, you agree to CodeUnia's{' '} - Terms of Service - {' '}and{' '} - Privacy Policy -

-
+ {/* Footer */} +
+

+ By continuing, you agree to CodeUnia's{' '} + Terms of Service + {' '}and{' '} + Privacy Policy +

+
); diff --git a/lib/services/profile.ts b/lib/services/profile.ts index aaeff03d..1756b78f 100644 --- a/lib/services/profile.ts +++ b/lib/services/profile.ts @@ -31,13 +31,17 @@ export class ProfileService { async createProfile(userId: string): Promise { const { data: user } = await this.getSupabaseClient().auth.getUser() + // Generate a simple codeunia_id if needed + const codeuniaId = `CU-${userId.slice(-8).toUpperCase()}-${Date.now().toString(36).toUpperCase()}` + const profileData = { id: userId, first_name: user.user?.user_metadata?.first_name || '', last_name: user.user?.user_metadata?.last_name || '', is_public: true, email_notifications: true, - profile_completion_percentage: 0 + profile_completion_percentage: 0, + codeunia_id: codeuniaId } const supabase = this.getSupabaseClient();