Compare commits

..

5 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
danak 7709c5a01f Update Dockerfile
deploy to danak / build_and_deploy (push) Has been cancelled
docker
2026-06-13 07:17:59 +00:00
hamid zarghami 1ce6f3387a dpage login
deploy to danak / build_and_deploy (push) Has been cancelled
2026-06-13 09:39:12 +03:30
5 changed files with 120 additions and 104 deletions
+2 -2
View File
@@ -8,10 +8,10 @@ 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
# Set the timezone to Asia/Tehran # Set the timezone to Asia/Tehran
RUN cp /usr/share/zoneinfo/Asia/Tehran /etc/localtime && echo "Asia/Tehran" > /etc/timezone # RUN cp /usr/share/zoneinfo/Asia/Tehran /etc/localtime && echo "Asia/Tehran" > /etc/timezone
WORKDIR /build WORKDIR /build
+6 -3
View File
@@ -7,7 +7,7 @@ import { useTranslation } from 'react-i18next'
import { ItemServiceType } from '../pages/service/types/ServiecTypes' import { ItemServiceType } from '../pages/service/types/ServiecTypes'
import moment from 'moment-jalaali' import moment from 'moment-jalaali'
import { NumberFormat } from '../config/func' import { NumberFormat } from '../config/func'
import { useDirectLogin, useDirectLoginDkala, useGetDmenuSubscription, useGetDkalaSubscription } from '../pages/service/hooks/useServiceData' import { useDirectLogin, useDirectLoginDkala, useDirectLoginDpage, useGetDmenuSubscription, useGetDkalaSubscription } from '../pages/service/hooks/useServiceData'
import { toast } from './Toast' import { toast } from './Toast'
import { ErrorType } from '../helpers/types' import { ErrorType } from '../helpers/types'
@@ -32,7 +32,9 @@ const ServiceItem: FC<Props> = (props: Props) => {
const isDmenu = item?.slug === 'Dmenu' const isDmenu = item?.slug === 'Dmenu'
const isDkala = item?.slug === 'Dkala' const isDkala = item?.slug === 'Dkala'
const isDpage = item?.slug === 'Dpage'
const isDmenuOrDkala = isDmenu || isDkala const isDmenuOrDkala = isDmenu || isDkala
const needsDirectLogin = isDmenuOrDkala || isDpage
const { data: dmenuSubscription, isPending: isDmenuPending, isError: isDmenuError } = useGetDmenuSubscription(isChecked && isDmenu && props.isLinkPanel ? props.subscriptionId! : '') const { data: dmenuSubscription, isPending: isDmenuPending, isError: isDmenuError } = useGetDmenuSubscription(isChecked && isDmenu && props.isLinkPanel ? props.subscriptionId! : '')
const { data: dkalaSubscription, isPending: isDkalaPending, isError: isDkalaError } = useGetDkalaSubscription(isChecked && isDkala && props.isLinkPanel ? props.subscriptionId! : '') const { data: dkalaSubscription, isPending: isDkalaPending, isError: isDkalaError } = useGetDkalaSubscription(isChecked && isDkala && props.isLinkPanel ? props.subscriptionId! : '')
const subscription = isDmenu ? dmenuSubscription : dkalaSubscription const subscription = isDmenu ? dmenuSubscription : dkalaSubscription
@@ -40,6 +42,7 @@ const ServiceItem: FC<Props> = (props: Props) => {
const isError = isDmenu ? isDmenuError : isDkalaError const isError = isDmenu ? isDmenuError : isDkalaError
const { mutate: directLogin } = useDirectLogin() const { mutate: directLogin } = useDirectLogin()
const { mutate: directLoginDkala } = useDirectLoginDkala() const { mutate: directLoginDkala } = useDirectLoginDkala()
const { mutate: directLoginDpage } = useDirectLoginDpage()
const getRemainingDays = (endDate: string): number => { const getRemainingDays = (endDate: string): number => {
const now = moment() const now = moment()
@@ -70,14 +73,14 @@ const ServiceItem: FC<Props> = (props: Props) => {
} }
const handleDirectLogin = () => { const handleDirectLogin = () => {
if (!isDmenuOrDkala) { if (!needsDirectLogin) {
window.open(item.link, '_blank') window.open(item.link, '_blank')
return return
} }
if (!props.subscriptionId) { if (!props.subscriptionId) {
return return
} }
const doLogin = isDkala ? directLoginDkala : directLogin const doLogin = isDkala ? directLoginDkala : isDpage ? directLoginDpage : directLogin
doLogin(props.subscriptionId, { doLogin(props.subscriptionId, {
onSuccess: (data) => { onSuccess: (data) => {
window.open(item.link + `?token=${data?.data?.tokens?.accessToken?.token}&refreshToken=${data?.data?.tokens?.refreshToken?.token}`, '_blank') window.open(item.link + `?token=${data?.data?.tokens?.accessToken?.token}&refreshToken=${data?.data?.tokens?.refreshToken?.token}`, '_blank')
+96 -99
View File
@@ -1,100 +1,99 @@
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 { setPhone, phone, setStepLogin, setEmail } = useAuthStore();
const loginWithOtp = useLoginWithOtp();
const checkHasAccount = useCheckHasAccount();
const { t } = useTranslation('global') const formik = useFormik<LoginType>({
const { setPhone, phone, setStepLogin, setEmail } = useAuthStore() initialValues: {
const loginWithOtp = useLoginWithOtp() phone_email: phone,
const checkHasAccount = useCheckHasAccount() },
validationSchema: Yup.object({
phone_email: Yup.string().required(t("errors.required")),
}),
onSubmit(values) {
if (isEmail(values.phone_email)) {
setEmail(values.phone_email);
checkHasAccount.mutate(
{ email: values.phone_email },
{
onSuccess() {
setStepLogin(2);
},
onError(error: ErrorType) {
toast(error.response?.data?.error.message?.[0], "error");
},
},
);
} else {
setPhone(values.phone_email);
loginWithOtp.mutate(
{ phone: values.phone_email },
{
onSuccess() {
setStepLogin(2);
toast(t("auth.otp_sent"), "success");
},
onError(error: ErrorType) {
toast(error?.response?.data?.error?.message[0], "error");
},
},
);
}
},
});
const formik = useFormik<LoginType>({ return (
initialValues: { <div>
phone_email: phone, <div className="mt-5">
}, <h2 className="text-2xl font-bold">{t("auth.welcome")}</h2>
validationSchema: Yup.object({ <p className="text-description text-sm mt-2">{t("auth.enter_info_login")}</p>
phone_email: Yup.string() </div>
.required(t('errors.required'))
}),
onSubmit(values) {
if (isEmail(values.phone_email)) {
setEmail(values.phone_email)
checkHasAccount.mutate({ email: values.phone_email }, {
onSuccess() {
setStepLogin(2)
},
onError(error: ErrorType) {
toast(error.response?.data?.error.message?.[0], 'error')
},
})
} else {
setPhone(values.phone_email)
loginWithOtp.mutate({ phone: values.phone_email }, {
onSuccess() {
setStepLogin(2)
toast(t('auth.otp_sent'), 'success')
},
onError(error: ErrorType) {
toast(error?.response?.data?.error?.message[0], 'error')
},
})
}
},
})
return ( <div className="mt-16">
<div> <Input
<div className='mt-5'> label={t("auth.mobile_or_email")}
<h2 className='text-2xl font-bold'> placeholder={t("auth.enter_mobile_or_email")}
{t('auth.welcome')} type="text"
</h2> className="text-right"
<p className='text-description text-sm mt-2'> name="phone_email"
{t('auth.enter_info_login')} onChange={formik.handleChange}
</p> value={formik.values.phone_email}
</div> />
<div className='mt-16'> {formik.touched.phone_email && formik.errors.phone_email && <Error errorText={formik.errors.phone_email} />}
<Input </div>
label={t('auth.mobile_or_email')}
placeholder={t('auth.enter_mobile_or_email')}
type='text'
className='text-right'
name='phone_email'
onChange={formik.handleChange}
value={formik.values.phone_email}
/>
{ <label className="mt-4 flex items-center gap-2 text-sm text-description cursor-pointer">
formik.touched.phone_email && formik.errors.phone_email && <input type="checkbox" checked readOnly className="mt-1 h-4 w-4 accent-primary" />
<Error <span className="text-xs mt-1">
errorText={formik.errors.phone_email} شما با ثبتنام، تمامی{" "}
/> <a href="https://danakcorp.com/conditions" target="_blank" rel="noopener noreferrer" className="text-primary">
} قوانین و مقررات داناک
</a>{" "}
را میپذیرید.
</span>
</label>
</div> <Button 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'>
<Button
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'>
<p className='text-description'> <p className='text-description'>
{t('auth.have_account')} {t('auth.have_account')}
</p> </p>
@@ -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> </Link>
<ArrowLeft size={20} color='black' /> </div>
</Link> );
</div> };
)
}
export default LoginStep1 export default LoginStep1;
@@ -131,3 +131,10 @@ export const useDirectLogin = () => {
mutationKey: ["direct-login"], mutationKey: ["direct-login"],
}); });
}; };
export const useDirectLoginDpage = () => {
return useMutation({
mutationFn: api.directLoginDpage,
mutationKey: ["direct-login-dpage"],
});
};
@@ -126,3 +126,12 @@ export const directLogin = async (
); );
return data; return data;
}; };
export const directLoginDpage = async (
subscriptionId: string,
): Promise<DirectLoginResponseType> => {
const { data } = await axios.post(`/dpage/login`, {
userSubscriptionId: subscriptionId,
});
return data;
};