remove hard reload
deploy to danak / build_and_deploy (push) Has been cancelled

This commit is contained in:
2026-07-03 17:16:11 +03:30
parent c22c37894c
commit 8cab9d04c8
13 changed files with 111 additions and 37 deletions
@@ -8,6 +8,7 @@ import { useGetMe, useUpdateProfile } from '@/pages/user/hooks/useUserData'
import { toast } from '@/shared/toast'
import { extractErrorMessage } from '@/config/func'
import { Paths } from '@/config/Paths'
import { appNavigate } from '@/config/navigation'
import type { UpdateProfileType } from '@/pages/user/types/Types'
const CompleteProfileForm: FC = () => {
@@ -37,7 +38,7 @@ const CompleteProfileForm: FC = () => {
{
onSuccess() {
toast('اطلاعات شما با موفقیت ثبت شد', 'success')
window.location.href = Paths.home
appNavigate(Paths.home, { replace: true })
},
onError(error) {
toast(extractErrorMessage(error), 'error')
+5 -2
View File
@@ -12,7 +12,7 @@ import { extractErrorMessage } from '@/config/func'
const LoginStep1: FC = () => {
const { phone, setPhone, setStepLogin } = useAuthStore()
const { phone, setPhone, setStepLogin, setDevOtpCode } = useAuthStore()
const loginWithOtp = useLoginWithOtp()
const checkHasAccount = useCheckHasAccount()
@@ -27,7 +27,10 @@ const LoginStep1: FC = () => {
onSubmit(values) {
setPhone(values.phone_email)
loginWithOtp.mutate({ phone: values.phone_email }, {
onSuccess() {
onSuccess(data) {
// TODO: remove before production — dev-only OTP autofill
const code = data?.data?.code
if (code) setDevOtpCode(String(code))
setStepLogin(2)
toast('کد تایید ارسال شد', 'success')
},
+20 -6
View File
@@ -13,10 +13,12 @@ import { setToken } from '../../../config/func'
import { toast } from '@/shared/toast'
import { Paths } from '@/config/Paths'
import { needsProfileCompletion } from '@/pages/user/utils/profileUtils'
import { useSessionAuth } from '@/config/sessionAuth'
import { appNavigate } from '@/config/navigation'
const LoginStep2: FC = () => {
const { phone, setStepLogin } = useAuthStore()
const { phone, setStepLogin, devOtpCode, setDevOtpCode } = useAuthStore()
const { value, reset } = useCountDown(2, true)
const otpVerify = useOtpVerify()
const loginWithOtp = useLoginWithOtp()
@@ -25,7 +27,8 @@ const LoginStep2: FC = () => {
const formik = useFormik<OtpVerifyType>({
initialValues: {
phone: phone,
otp: ''
// TODO: remove before production — dev-only OTP autofill
otp: devOtpCode,
},
validationSchema: Yup.object({
otp: Yup.string()
@@ -40,10 +43,14 @@ const LoginStep2: FC = () => {
onSuccess(data) {
setToken(data?.data?.tokens?.accessToken?.token)
setRefreshToken(data?.data?.tokens?.refreshToken?.token)
useSessionAuth.getState().setAuthenticated(true)
const user = data?.data?.user
window.location.href = needsProfileCompletion(user)
? Paths.auth.completeProfile
: Paths.home
appNavigate(
needsProfileCompletion(user)
? Paths.auth.completeProfile
: Paths.home,
{ replace: true },
)
},
onError(error) {
toast(extractErrorMessage(error), 'error')
@@ -84,7 +91,14 @@ const LoginStep2: FC = () => {
const reSend = () => {
loginWithOtp.mutate({ phone: phone }, {
onSuccess: () => {
onSuccess: (data) => {
// TODO: remove before production — dev-only OTP autofill
const code = data?.data?.code
if (code) {
const otp = String(code)
setDevOtpCode(otp)
formik.setFieldValue('otp', otp)
}
reset()
toast('کد مجدد ارسال شد', 'success')
},
+4
View File
@@ -14,4 +14,8 @@ export const useAuthStore = create<AuthStoreType>((set) => ({
setStepLogin(value) {
set({ stepLogin: value });
},
devOtpCode: "",
setDevOtpCode(value) {
set({ devOtpCode: value });
},
}));
+3
View File
@@ -12,6 +12,9 @@ export type AuthStoreType = {
setEmail: (value: string) => void;
stepLogin: number;
setStepLogin: (value: number) => void;
/** TODO: remove before production — dev-only OTP from API response */
devOtpCode: string;
setDevOtpCode: (value: string) => void;
};
export type LoginWithPasswordType = {