fix: login result handle changed to a singular function

This commit is contained in:
2025-08-21 14:36:07 +03:30
parent 4d84a29bda
commit 74fa41c1c0
6 changed files with 33 additions and 30 deletions

View File

@@ -5,7 +5,7 @@ import { OtpVerifyForm } from './OtpVerifyForm';
import { isNumeric } from '@/utils/regexes/isNumeric';
import { CompleteSignUp } from './CompleteSignUp';
import { EnterPasswordForm } from './EnterPasswordForm';
import { UserStatus } from '../../types/userTypes';
import { UserStatus, type LoginResult } from '../../types/userTypes';
import type { CountryCode } from '@/types/commonTypes';
import { VerifyPhoneNumber } from './VerifyPhoneNumber';
import { useNavigate, useSearchParams } from 'react-router-dom';
@@ -49,12 +49,22 @@ export const AuthenticationSteps = (): JSX.Element => {
}
};
const handleUserLoggedIn = () => {
redirectToReturnUrl();
};
const handleUserLoggedIn = (loginResult: LoginResult) => {
if (loginResult.registeredWithOutPhoneNumber) {
setCurrentStep('addPhoneNumber');
return;
}
const handleConfrimPhoneNumber = () => {
setCurrentStep('addPhoneNumber');
if (!loginResult.completedUserInformation) {
if (authReturnUrl) {
navigate(`/signup?returnUrl=${authReturnUrl}`);
} else {
navigate(`/signup`);
}
return;
}
redirectToReturnUrl();
};
const handlePhoneNumberVerified = () => {
@@ -95,7 +105,6 @@ export const AuthenticationSteps = (): JSX.Element => {
{currentStep === 'verify' && (
<OtpVerifyForm
onVerifyPhoneNumber={handleConfrimPhoneNumber}
authReturnUrl={authReturnUrlOrDefault}
countryCode={countryCode}
onOTPVerified={handleUserLoggedIn}