From 3deac45466c8c2f7a980064f9c4e29a42aca908c Mon Sep 17 00:00:00 2001 From: Mahyar Khanbolooki Date: Wed, 2 Jul 2025 20:00:58 +0330 Subject: [PATCH] feat: temp disable api calls for serverless testing --- src/app/auth/page.tsx | 53 +++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/src/app/auth/page.tsx b/src/app/auth/page.tsx index bbc64af..4856d8a 100644 --- a/src/app/auth/page.tsx +++ b/src/app/auth/page.tsx @@ -30,12 +30,12 @@ function AuthIndex({ }: Props) { const { timerRunning, secondsLeft, restart, stop } = useCountdown(step === AUTH_STEP.ENTER_OTP); const isAuthenticated = useAuthStore((state) => state.isAuthenticated) - const loginMutation = useLogin() - const signupMutation = useSignup() - const { run: runUserExistCheck } = useCheckUserExistsLazy() - const { run: runOtpRequest } = useOtpRequest(); - const { run: runOtpValidation } = useOtpValidation(); - const { run: runResetPassword } = useResetPassword(); + // const loginMutation = useLogin() + // const signupMutation = useSignup() + // const { run: runUserExistCheck } = useCheckUserExistsLazy() + // const { run: runOtpRequest } = useOtpRequest(); + // const { run: runOtpValidation } = useOtpValidation(); + // const { run: runResetPassword } = useResetPassword(); const resetStates = () => { setNumber(''); @@ -57,7 +57,7 @@ function AuthIndex({ }: Props) { useEffect(() => { if (step === AUTH_STEP.ENTER_OTP) { console.log("REQUEST OTP") - runOtpRequest(number); + // runOtpRequest(number); } }, [step]); @@ -100,7 +100,7 @@ function AuthIndex({ }: Props) { else if (target.id === AUTH_PAGE_ELEMENT.RESEND_OTP) { if (!timerRunning) { try { - await runOtpRequest(number); + // await runOtpRequest(number); restart(); } catch { @@ -113,7 +113,7 @@ function AuthIndex({ }: Props) { e.preventDefault(); if (step == AUTH_STEP.ENTER_NUMBER) { - if (await runUserExistCheck(number)) { + if (false) { setStep(AUTH_STEP.ENTER_PASSWORD) } else { setStep(AUTH_STEP.ENTER_OTP); @@ -121,7 +121,7 @@ function AuthIndex({ }: Props) { } else if (step == AUTH_STEP.ENTER_PASSWORD) { try { - await loginMutation.mutateAsync({ phone: number, password }) + // await loginMutation.mutateAsync({ phone: number, password }) console.log("Logged in") } catch (e) { @@ -129,25 +129,27 @@ function AuthIndex({ }: Props) { } } else if (step == AUTH_STEP.ENTER_OTP) { - if (!await runOtpValidation({ phone: number, otp })) { - setOtp(''); - console.log('Wrong otp'); - } + // if (!await runOtpValidation({ phone: number, otp })) { + // setOtp(''); + // console.log('Wrong otp'); + // } + setOtp(''); stop(); - if (await runUserExistCheck(number)) { - setStep(AUTH_STEP.ENTER_RESET_PASSWORD) - } else { - setStep(AUTH_STEP.ENTER_NEW_PASSWORD) - } + // if (await runUserExistCheck(number)) { + // setStep(AUTH_STEP.ENTER_RESET_PASSWORD) + // } else { + // setStep(AUTH_STEP.ENTER_NEW_PASSWORD) + // } + setStep(AUTH_STEP.ENTER_NEW_PASSWORD) } else if (step == AUTH_STEP.ENTER_RESET_PASSWORD) { console.log("Password changed") try { - await runResetPassword({ - phone: number, - newPassword: password, - otp - }) + // await runResetPassword({ + // phone: number, + // newPassword: password, + // otp + // }) resetStates(); setStep(AUTH_STEP.ENTER_NUMBER) } catch (ex) { @@ -156,7 +158,8 @@ function AuthIndex({ }: Props) { } else if (step == AUTH_STEP.ENTER_NEW_PASSWORD) { try { - await signupMutation.mutateAsync({ phone: number, password }) + // await signupMutation.mutateAsync({ phone: number, password }) + useAuthStore.getState().isAuthenticated = true; console.log("Signed up") redirect("/") }