From bc3d068dfd28012fb2be56383b3a06d8d6a63ff8 Mon Sep 17 00:00:00 2001 From: hamid zarghami Date: Sun, 23 Feb 2025 15:43:04 +0330 Subject: [PATCH] part 1 --- src/App.tsx | 2 + src/components/DefaulModal.tsx | 2 +- src/components/ServiceItem.tsx | 5 +- src/components/ServiceSection.tsx | 2 +- src/config/Pages.ts | 1 + src/hooks/useConvertNumbers.ts | 34 +++++ src/langs/fa.json | 26 +++- src/pages/auth/components/LoginStep2.tsx | 37 +++++- src/pages/financial/Financial.tsx | 2 +- src/pages/home/Home.tsx | 18 +-- .../home/components/BoxNewAccessbility.tsx | 120 ++++++++---------- src/pages/service/DetailService.tsx | 2 +- src/pages/service/MyServices.tsx | 2 +- src/pages/service/OtherServices.tsx | 2 +- .../service/components/OtherServices.tsx | 4 +- src/pages/ticket/Detail.tsx | 7 +- src/pages/ticket/TicketList.tsx | 12 +- src/pages/ticket/hooks/useTicketData.ts | 9 ++ src/pages/transaction/List.tsx | 2 +- src/pages/wallet/CallBack.tsx | 61 +++++++++ src/pages/wallet/components/CardtoCard.tsx | 4 + src/pages/wallet/components/Sheba.tsx | 4 + src/router/Main.tsx | 4 +- src/shared/Header.tsx | 37 ++++-- 24 files changed, 278 insertions(+), 121 deletions(-) create mode 100644 src/hooks/useConvertNumbers.ts create mode 100644 src/pages/wallet/CallBack.tsx diff --git a/src/App.tsx b/src/App.tsx index 5b1b59a..f5aa5fb 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -12,6 +12,7 @@ import { IApiErrorRepsonse } from './types/error.types' import MainRouter from './router/Main' import AuthRouter from './router/Auth' import { Pages } from './config/Pages' +import useConvertNumbers from './hooks/useConvertNumbers'; i18next.init({ interpolation: { escapeValue: false }, @@ -43,6 +44,7 @@ const queryClient = new QueryClient({ const App: FC = () => { // useNumberFont() + useConvertNumbers() const [isLogin, setIsLogin] = useState<'checking' | 'isLogin' | 'isNotLogin'>('checking') useEffect(() => { diff --git a/src/components/DefaulModal.tsx b/src/components/DefaulModal.tsx index 0344049..51d25d8 100644 --- a/src/components/DefaulModal.tsx +++ b/src/components/DefaulModal.tsx @@ -27,7 +27,7 @@ const DefaulModal: FC = (props: Props) => { props.open && (
-
+
diff --git a/src/components/ServiceItem.tsx b/src/components/ServiceItem.tsx index 873a66e..325fe05 100644 --- a/src/components/ServiceItem.tsx +++ b/src/components/ServiceItem.tsx @@ -27,9 +27,6 @@ const ServiceItem: FC = (props: Props) => {
{item.description}
-

- -

@@ -38,7 +35,7 @@ const ServiceItem: FC = (props: Props) => { className='h-8 w-fit px-5 text-xs text-black bg-description bg-opacity-20 rounded-xl' >
-
{t('service.buy')}
+
{t('service.detail')}
diff --git a/src/components/ServiceSection.tsx b/src/components/ServiceSection.tsx index 5231922..e0713c0 100644 --- a/src/components/ServiceSection.tsx +++ b/src/components/ServiceSection.tsx @@ -9,7 +9,7 @@ const ServiceSection: FC = (props: Props) => { const { item } = props return (
-
+
{item.name}
diff --git a/src/config/Pages.ts b/src/config/Pages.ts index 505c980..684021e 100644 --- a/src/config/Pages.ts +++ b/src/config/Pages.ts @@ -28,6 +28,7 @@ export const Pages = { learning: "/learning", setting: "/setting", wallet: "/wallet", + callback: "/wallet/callback/", profile: "/profile", discounts: "/discounts", financial: "/financial", diff --git a/src/hooks/useConvertNumbers.ts b/src/hooks/useConvertNumbers.ts new file mode 100644 index 0000000..981bbad --- /dev/null +++ b/src/hooks/useConvertNumbers.ts @@ -0,0 +1,34 @@ +import { useEffect } from "react"; + +const toPersianDigits = (text: string): string => { + return text.replace(/\d/g, (d) => "۰۱۲۳۴۵۶۷۸۹"[parseInt(d, 10)]); +}; + +const convertNumbersInDOM = (node: Node): void => { + if (node.nodeType === Node.TEXT_NODE) { + node.nodeValue = toPersianDigits(node.nodeValue || ""); + } else if (node.nodeType === Node.ELEMENT_NODE) { + node.childNodes.forEach(convertNumbersInDOM); + } +}; + +const useConvertNumbers = (): void => { + useEffect(() => { + const observer = new MutationObserver((mutations) => { + mutations.forEach((mutation) => { + if (mutation.type === "childList") { + mutation.addedNodes.forEach(convertNumbersInDOM); + } + }); + }); + + observer.observe(document.body, { childList: true, subtree: true }); + + // اجرای اولیه روی کل صفحه + convertNumbersInDOM(document.body); + + return () => observer.disconnect(); + }, []); +}; + +export default useConvertNumbers; diff --git a/src/langs/fa.json b/src/langs/fa.json index 85a12d7..1d94b86 100644 --- a/src/langs/fa.json +++ b/src/langs/fa.json @@ -39,7 +39,9 @@ "login_with_otp": "ورود با رمز عبور یکبار مصرف", "otp_sent": "کد تایید ارسال شد", "mobile_number": "شماره موبایل", - "enter_mobile_number": "شماره موبایل خود را وارد کنید" + "enter_mobile_number": "شماره موبایل خود را وارد کنید", + "try_again": "ارسال مجدد", + "toast_resend_code": "کد جدیدی برای شما ارسال شد" }, "errors": { "required": "این فیلد اجباری می باشد", @@ -85,13 +87,17 @@ "add_access": "دسترسی سریع تازه ایجاد کنید.", "danak_learning": "آموزش داناک", "see_all": "دیدن همه", - "create_new_access": "ایجاد دسترسی سریع" + "create_new_access": "ایجاد دسترسی سریع", + "receip": "صورتحساب پرداخت نشده دارید", + "balance": "موجودی", + "cannot_find_service": "سرویسی پیدا نشد", + "not_active_service": "شما هنوز سرویس فعالی ندارید" }, "all": "همه", "service": { "my_service": "سرویس های من", "search": "جستجو در سرویس ها", - "active_menu": "منو فعال", + "active_menu": "سرویس فعال", "selected_danak": "انتخاب داناک", "buy": "خرید", "other_services": "سایر سرویس ها", @@ -115,7 +121,8 @@ "enter_title_comment": "عنوان نظر خود را وارد کنید", "your_comment": "نظر شما", "write_your_comment": "نظر خود را راجع به این سرویس بنویسید", - "users_comments": "نظرات کاربران" + "users_comments": "نظرات کاربران", + "detail": "جزییات بیشتر" }, "loading": "در حال بارگذاری", "footer": { @@ -173,6 +180,7 @@ }, "date": "تاریخ", "receip": { + "receip": "صورتحساب", "receip_list": "لیست صورتحساب ها", "dont_pay": "پرداخت نشده", "dont_confrim": "تایید نشده", @@ -400,5 +408,13 @@ }, "man": "مرد", "woman": "زن", - "success": "عملیات با موفقیت انجام شد" + "success": "عملیات با موفقیت انجام شد", + "callback": { + "title_success": "پرداخت موفق بود!", + "desc_success": "پرداخت شما با موفقیت انجام شد. از خرید شما متشکریم!", + "order_number": "شماره سفارش", + "amount": "مبلغ پرداختی", + "date": "تاریخ", + "back": "بازگشت" + } } diff --git a/src/pages/auth/components/LoginStep2.tsx b/src/pages/auth/components/LoginStep2.tsx index 96bb7b4..b2c0e63 100644 --- a/src/pages/auth/components/LoginStep2.tsx +++ b/src/pages/auth/components/LoginStep2.tsx @@ -9,7 +9,7 @@ import OTPInput from 'react-otp-input' import { useCountDown } from '../../../hooks/useCountDown' // import ArrowLeftIcon from '../../../assets/images/arrow-left.svg' import { Pages } from '../../../config/Pages' -import { useOtpVerify } from '../hooks/useAuthData' +import { useLoginWithOtp, useOtpVerify } from '../hooks/useAuthData' import { ErrorType } from '../../../helpers/types' import { toast } from 'react-toastify' @@ -17,8 +17,9 @@ const LoginStep2: FC = () => { const { t } = useTranslation('global') const { phone, setStepLogin } = useAuthStore() - const { value } = useCountDown(2, true) + const { value, reset } = useCountDown(2, true) const otpVerify = useOtpVerify() + const loginWithOtp = useLoginWithOtp() const formik = useFormik({ initialValues: { @@ -69,6 +70,18 @@ const LoginStep2: FC = () => { return () => ac.abort(); }, []); + const reSend = () => { + loginWithOtp.mutate({ phone: phone }, { + onSuccess: () => { + reset() + toast.success(t('auth.toast_resend_code')) + }, + onError: (error: ErrorType) => { + toast.error(error.response?.data?.error.message[0]) + } + }) + } + return (
@@ -103,6 +116,7 @@ const LoginStep2: FC = () => { renderInput={(props) => @@ -116,10 +130,21 @@ const LoginStep2: FC = () => { }
-
-
{value}
-
{t('auth.counter_otp')}
-
+ { + value !== '00:00' ? +
+
{value}
+
{t('auth.counter_otp')}
+
+ : +
+
+ {t('auth.try_again')} +
+
+ + } +
diff --git a/src/pages/financial/Financial.tsx b/src/pages/financial/Financial.tsx index 5ef84ce..8eb3f04 100644 --- a/src/pages/financial/Financial.tsx +++ b/src/pages/financial/Financial.tsx @@ -26,7 +26,7 @@ const Financial: FC = () => { }, { icon: , - label: t('financial.legal'), + label: t('financial.personal'), value: 'personal' }, ]} diff --git a/src/pages/home/Home.tsx b/src/pages/home/Home.tsx index 393bfd0..6962fe8 100644 --- a/src/pages/home/Home.tsx +++ b/src/pages/home/Home.tsx @@ -1,6 +1,6 @@ import { FC } from 'react' import { useTranslation } from 'react-i18next' -import { ArrowLeft, Element3, Messages3, NotificationStatus, Teacher } from 'iconsax-react' +import { ArrowLeft, Element3, Messages3, NotificationStatus, Receipt21 } from 'iconsax-react' import ItemDashboard from './components/ItemDashboard' import TitleLine from '../../components/TitleLine' import AccessbilityImage from '../../assets/images/accessbility.jpg' @@ -73,6 +73,14 @@ const Home: FC = () => { description={t('home.unread_messages')} /> + } + color='#0047FF' + count={4} + description={t('home.receip')} + /> + } @@ -81,14 +89,6 @@ const Home: FC = () => { description={t('home.unread_announcement')} /> - } - color='#0047FF' - count={4} - description={t('home.learning')} - /> -
diff --git a/src/pages/home/components/BoxNewAccessbility.tsx b/src/pages/home/components/BoxNewAccessbility.tsx index d98efeb..24290c5 100644 --- a/src/pages/home/components/BoxNewAccessbility.tsx +++ b/src/pages/home/components/BoxNewAccessbility.tsx @@ -3,13 +3,17 @@ import { FC, useState } from 'react' import DefaulModal from '../../../components/DefaulModal' import { useTranslation } from 'react-i18next' import Input from '../../../components/Input' -import Select from '../../../components/Select' import SwitchComponent from '../../../components/Switch' +import { useGetMyServices } from '../../service/hooks/useServiceData' +import { MyServicesItem } from '../../service/types/ServiecTypes' +import PageLoading from '../../../components/PageLoading' const BoxNewAccessbility: FC = () => { + const [search, setSearch] = useState('') const [open, setOpen] = useState(false) const { t } = useTranslation('global') + const getMyservices = useGetMyServices(search) return ( <> @@ -63,80 +67,58 @@ const BoxNewAccessbility: FC = () => {
- -