Pulastya B commited on
Commit
8dcc270
·
1 Parent(s): a5bd6df

Fix OAuth onboarding: change button text to 'Complete Profile' and add timeout to prevent infinite loop

Browse files
Files changed (1) hide show
  1. FRRONTEEEND/components/AuthPage.tsx +25 -8
FRRONTEEEND/components/AuthPage.tsx CHANGED
@@ -213,12 +213,29 @@ export const AuthPage: React.FC<AuthPageProps> = ({ onSuccess, onSkip }) => {
213
  };
214
 
215
  console.log('Saving profile data:', profileData);
216
- const savedProfile = await saveUserProfile(profileData);
217
- if (!savedProfile) {
218
- console.warn('Failed to save profile data, but auth succeeded');
219
- setError('Profile saved with warnings. You can continue.');
220
- } else {
221
- console.log('Profile saved successfully:', savedProfile);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
222
  }
223
 
224
  setSuccess(isOAuthUser ? 'Profile completed! Redirecting...' : 'Account created successfully! Redirecting...');
@@ -877,11 +894,11 @@ export const AuthPage: React.FC<AuthPageProps> = ({ onSuccess, onSkip }) => {
877
  >
878
  {isSubmitting ? (
879
  <>
880
- <Loader2 className="h-4 w-4 animate-spin" /> Creating...
881
  </>
882
  ) : (
883
  <>
884
- {currentStep === steps.length - 1 ? "Create Account" : "Next"}
885
  {currentStep === steps.length - 1 ? (
886
  <Check className="h-4 w-4" />
887
  ) : (
 
213
  };
214
 
215
  console.log('Saving profile data:', profileData);
216
+
217
+ // Add timeout to prevent infinite hanging
218
+ const saveProfileWithTimeout = Promise.race([
219
+ saveUserProfile(profileData),
220
+ new Promise((_, reject) =>
221
+ setTimeout(() => reject(new Error('Profile save timeout')), 10000)
222
+ )
223
+ ]);
224
+
225
+ try {
226
+ const savedProfile = await saveProfileWithTimeout;
227
+ if (!savedProfile) {
228
+ console.warn('Failed to save profile data, but auth succeeded');
229
+ // Don't block the user, just warn
230
+ } else {
231
+ console.log('Profile saved successfully:', savedProfile);
232
+ }
233
+ } catch (saveError: any) {
234
+ console.error('Profile save error:', saveError);
235
+ if (saveError.message === 'Profile save timeout') {
236
+ setError('Profile save is taking too long. You can continue and update your profile later.');
237
+ }
238
+ // Don't block OAuth users from proceeding even if profile save fails
239
  }
240
 
241
  setSuccess(isOAuthUser ? 'Profile completed! Redirecting...' : 'Account created successfully! Redirecting...');
 
894
  >
895
  {isSubmitting ? (
896
  <>
897
+ <Loader2 className="h-4 w-4 animate-spin" /> {user ? 'Saving...' : 'Creating...'}
898
  </>
899
  ) : (
900
  <>
901
+ {currentStep === steps.length - 1 ? (user ? "Complete Profile" : "Create Account") : "Next"}
902
  {currentStep === steps.length - 1 ? (
903
  <Check className="h-4 w-4" />
904
  ) : (