fix: login result handle changed to a singular function
This commit is contained in:
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user