Compare commits

..

3 Commits

Author SHA1 Message Date
hamid zarghami 0e429fbbc1 docker file to mirror
deploy to danak / build_and_deploy (push) Has been cancelled
2026-07-07 11:14:28 +03:30
hamid zarghami 470204c686 pull
deploy to danak / build_and_deploy (push) Has been cancelled
2026-07-07 10:58:32 +03:30
hamid zarghami 4bc6168246 conditioins in login 2026-07-07 10:55:46 +03:30
2 changed files with 99 additions and 102 deletions
+3 -3
View File
@@ -1,11 +1,11 @@
FROM node:22-alpine AS builder FROM node:22-alpine AS builder
# Change Alpine repo # Change Alpine repo
# RUN sed -i 's|https://dl-cdn.alpinelinux.org/alpine|https://mirror.de.velop.ir/alpine|g' /etc/apk/repositories RUN sed -i 's|https://dl-cdn.alpinelinux.org/alpine|https://mirror.de.velop.ir/alpine|g' /etc/apk/repositories
# Configure npm registry mirror (Liara) # Configure npm registry mirror (Liara)
# ENV NPM_CONFIG_REGISTRY=https://package-mirror.liara.ir/repository/npm/ ENV NPM_CONFIG_REGISTRY=https://package-mirror.liara.ir/repository/npm/
# RUN npm config set registry https://package-mirror.liara.ir/repository/npm/ RUN npm config set registry https://package-mirror.liara.ir/repository/npm/
# Install tzdata to support timezone settings # Install tzdata to support timezone settings
# RUN apk add --no-cache tzdata # RUN apk add --no-cache tzdata
+66 -69
View File
@@ -1,98 +1,97 @@
import { FC } from 'react' import { useFormik } from "formik";
import Input from '../../../components/Input' import { ArrowLeft } from "iconsax-react";
import { useTranslation } from 'react-i18next' import { FC } from "react";
import { LoginType } from '../types/AuthTypes' import { useTranslation } from "react-i18next";
import { useFormik } from 'formik' import { Link } from "react-router-dom";
import * as Yup from 'yup' import * as Yup from "yup";
import { useAuthStore } from '../store/AuthStore' import Button from "../../../components/Button";
import Error from '../../../components/Error' import Error from "../../../components/Error";
import Button from '../../../components/Button' import Input from "../../../components/Input";
import { isEmail } from '../../../config/func' import { toast } from "../../../components/Toast";
import { useCheckHasAccount, useLoginWithOtp } from '../hooks/useAuthData' import { isEmail } from "../../../config/func";
import { ErrorType } from '../../../helpers/types' import { Pages } from "../../../config/Pages";
import { toast } from '../../../components/Toast' import { ErrorType } from "../../../helpers/types";
import { ArrowLeft } from 'iconsax-react' import { useCheckHasAccount, useLoginWithOtp } from "../hooks/useAuthData";
import { Link } from 'react-router-dom' import { useAuthStore } from "../store/AuthStore";
import { Pages } from '../../../config/Pages' import { LoginType } from "../types/AuthTypes";
const LoginStep1: FC = () => { const LoginStep1: FC = () => {
const { t } = useTranslation("global");
const { t } = useTranslation('global') const { setPhone, phone, setStepLogin, setEmail } = useAuthStore();
const { setPhone, phone, setStepLogin, setEmail } = useAuthStore() const loginWithOtp = useLoginWithOtp();
const loginWithOtp = useLoginWithOtp() const checkHasAccount = useCheckHasAccount();
const checkHasAccount = useCheckHasAccount()
const formik = useFormik<LoginType>({ const formik = useFormik<LoginType>({
initialValues: { initialValues: {
phone_email: phone, phone_email: phone,
}, },
validationSchema: Yup.object({ validationSchema: Yup.object({
phone_email: Yup.string() phone_email: Yup.string().required(t("errors.required")),
.required(t('errors.required'))
}), }),
onSubmit(values) { onSubmit(values) {
if (isEmail(values.phone_email)) { if (isEmail(values.phone_email)) {
setEmail(values.phone_email) setEmail(values.phone_email);
checkHasAccount.mutate({ email: values.phone_email }, { checkHasAccount.mutate(
{ email: values.phone_email },
{
onSuccess() { onSuccess() {
setStepLogin(2) setStepLogin(2);
}, },
onError(error: ErrorType) { onError(error: ErrorType) {
toast(error.response?.data?.error.message?.[0], 'error') toast(error.response?.data?.error.message?.[0], "error");
}, },
}) },
);
} else { } else {
setPhone(values.phone_email) setPhone(values.phone_email);
loginWithOtp.mutate({ phone: values.phone_email }, { loginWithOtp.mutate(
{ phone: values.phone_email },
{
onSuccess() { onSuccess() {
setStepLogin(2) setStepLogin(2);
toast(t('auth.otp_sent'), 'success') toast(t("auth.otp_sent"), "success");
}, },
onError(error: ErrorType) { onError(error: ErrorType) {
toast(error?.response?.data?.error?.message[0], 'error') toast(error?.response?.data?.error?.message[0], "error");
}, },
}) },
);
} }
}, },
}) });
return ( return (
<div> <div>
<div className='mt-5'> <div className="mt-5">
<h2 className='text-2xl font-bold'> <h2 className="text-2xl font-bold">{t("auth.welcome")}</h2>
{t('auth.welcome')} <p className="text-description text-sm mt-2">{t("auth.enter_info_login")}</p>
</h2>
<p className='text-description text-sm mt-2'>
{t('auth.enter_info_login')}
</p>
</div> </div>
<div className='mt-16'> <div className="mt-16">
<Input <Input
label={t('auth.mobile_or_email')} label={t("auth.mobile_or_email")}
placeholder={t('auth.enter_mobile_or_email')} placeholder={t("auth.enter_mobile_or_email")}
type='text' type="text"
className='text-right' className="text-right"
name='phone_email' name="phone_email"
onChange={formik.handleChange} onChange={formik.handleChange}
value={formik.values.phone_email} value={formik.values.phone_email}
/> />
{ {formik.touched.phone_email && formik.errors.phone_email && <Error errorText={formik.errors.phone_email} />}
formik.touched.phone_email && formik.errors.phone_email &&
<Error
errorText={formik.errors.phone_email}
/>
}
</div> </div>
<label className="mt-4 flex items-center gap-2 text-sm text-description cursor-pointer">
<input type="checkbox" checked readOnly className="mt-1 h-4 w-4 accent-primary" />
<span className="text-xs mt-1">
شما با ثبتنام، تمامی{" "}
<a href="https://danakcorp.com/conditions" target="_blank" rel="noopener noreferrer" className="text-primary">
قوانین و مقررات داناک
</a>{" "}
را میپذیرید.
</span>
</label>
<Button <Button label={t("auth.next")} className="mt-8" onClick={() => formik.handleSubmit()} isLoading={loginWithOtp.isPending || checkHasAccount.isPending} />
label={t('auth.next')}
className='mt-8'
onClick={() => formik.handleSubmit()}
isLoading={loginWithOtp.isPending || checkHasAccount.isPending}
/>
{/* <div className='mt-6 flex justify-center gap-2 items-center text-sm'> {/* <div className='mt-6 flex justify-center gap-2 items-center text-sm'>
<p className='text-description'> <p className='text-description'>
@@ -103,14 +102,12 @@ const LoginStep1: FC = () => {
</Link> </Link>
</div> */} </div> */}
<Link to={Pages.auth.forgotPassword} className='mt-6 flex gap-1 text-sm justify-center text-description'> <Link to={Pages.auth.forgotPassword} className="mt-6 flex gap-1 text-sm justify-center text-description">
<div> <div>{t("auth.forgot_password")}</div>
{t('auth.forgot_password')} <ArrowLeft size={20} color="black" />
</div>
<ArrowLeft size={20} color='black' />
</Link> </Link>
</div> </div>
) );
} };
export default LoginStep1 export default LoginStep1;