From 158da6ce8a015f0c003bd69ca017929b33942790 Mon Sep 17 00:00:00 2001 From: hamid zarghami Date: Sun, 23 Feb 2025 16:58:51 +0330 Subject: [PATCH] part 2 --- src/components/DefaulModal.tsx | 2 +- src/langs/fa.json | 14 ++++---- src/pages/auth/components/LoginStep2.tsx | 9 +++++ src/pages/financial/components/Legal.tsx | 36 +++++++++---------- src/pages/financial/components/Personal.tsx | 6 ++++ src/pages/home/Home.tsx | 5 +++ src/pages/home/components/ItemDashboard.tsx | 8 +++-- src/pages/notification/Notification.tsx | 34 ++++++++++++++---- .../notification/hooks/useNotificationData.ts | 8 ++++- .../service/NotificationService.ts | 5 +++ src/pages/ticket/TicketList.tsx | 14 ++++---- src/pages/ticket/service/TicketService.ts | 6 +++- src/pages/wallet/components/CardtoCard.tsx | 12 +++++-- src/pages/wallet/components/Online.tsx | 18 +++++++--- src/pages/wallet/components/Sheba.tsx | 12 +++++-- src/shared/Header.tsx | 2 +- 16 files changed, 138 insertions(+), 53 deletions(-) diff --git a/src/components/DefaulModal.tsx b/src/components/DefaulModal.tsx index 51d25d8..bc298d1 100644 --- a/src/components/DefaulModal.tsx +++ b/src/components/DefaulModal.tsx @@ -33,7 +33,7 @@ const DefaulModal: FC = (props: Props) => { { props.isHeader && props.title_header && -
+
diff --git a/src/langs/fa.json b/src/langs/fa.json index 1d94b86..a64d29d 100644 --- a/src/langs/fa.json +++ b/src/langs/fa.json @@ -78,9 +78,9 @@ "myservice": "سرویس های من", "active_service": "سرویس های فعال", "ticket": "تیکت ها", - "unread_messages": "پیام خوانده نشده دارید ", + "unread_messages": "پیام خوانده نشده ", "announcement": "اطلاعیه ها", - "unread_announcement": "اطلاعیه خوانده نشده دارید", + "unread_announcement": "اطلاعیه خوانده نشده", "learnings": "آموزش ها", "learning": "آموزش", "access": "دسترسی سریع", @@ -88,7 +88,7 @@ "danak_learning": "آموزش داناک", "see_all": "دیدن همه", "create_new_access": "ایجاد دسترسی سریع", - "receip": "صورتحساب پرداخت نشده دارید", + "receip": "صورتحساب پرداخت نشده ", "balance": "موجودی", "cannot_find_service": "سرویسی پیدا نشد", "not_active_service": "شما هنوز سرویس فعالی ندارید" @@ -176,7 +176,8 @@ "PENDING": "در انتظار", "ANSWERED": "پاسخ داده شده", "CLOSED": "بسته شده", - "service": "سرویس" + "service": "سرویس", + "all": "همه" }, "date": "تاریخ", "receip": { @@ -336,14 +337,15 @@ "enter_sheba_deposit": "مبلغ شبا شده شده را وارد کنید", "all_cards": "تمام کارت های عضو شتاب", "error_select_price": "لطفا مبلغ مورد نظر خود را انتخاب کنید", - "error_min_price": "حداقل مبلغ ۱۰۰ هزار تومان می باشد", + "error_min_price": "حداقل مبلغ ۵۰۰ هزار تومان می باشد", "transfer_to_getway": "در حال انتقال به درگاه پرداخت", "select_bank_account": "انتخاب کارت", "successful_transfer": "درخواست انتقال وجه با موفقیت انجام شد", "balance": "اعتبار فعلی شما " }, "notif": { - "natification": "اعلان ها" + "natification": "اعلان ها", + "all_read": "پاک کردن همه" }, "profile": { "account_user": "حساب کاربری", diff --git a/src/pages/auth/components/LoginStep2.tsx b/src/pages/auth/components/LoginStep2.tsx index b2c0e63..b1978af 100644 --- a/src/pages/auth/components/LoginStep2.tsx +++ b/src/pages/auth/components/LoginStep2.tsx @@ -82,6 +82,15 @@ const LoginStep2: FC = () => { }) } + useEffect(() => { + + if (formik.values.code.length === 5) { + formik.handleSubmit() + } + + }, [formik.values.code]) + + return (
diff --git a/src/pages/financial/components/Legal.tsx b/src/pages/financial/components/Legal.tsx index e233b2a..ece2ed0 100644 --- a/src/pages/financial/components/Legal.tsx +++ b/src/pages/financial/components/Legal.tsx @@ -194,24 +194,24 @@ const Legal: FC = () => {
{t('financial.notice_cannot_edit_legal')}
- { - !isReadOnly && -
- -
- } + +
+ +
+
diff --git a/src/pages/financial/components/Personal.tsx b/src/pages/financial/components/Personal.tsx index 094bfaa..d80917d 100644 --- a/src/pages/financial/components/Personal.tsx +++ b/src/pages/financial/components/Personal.tsx @@ -113,12 +113,14 @@ const Personal: FC = () => { ]} {...formik.getFieldProps('gender')} error_text={formik.touched.gender && formik.errors.gender ? formik.errors.gender : ''} + readOnly={isReadOnly} /> @@ -148,6 +150,7 @@ const Personal: FC = () => { label={t('financial.nationality')} {...formik.getFieldProps('nationality')} error_text={formik.touched.nationality && formik.errors.nationality ? formik.errors.nationality : ''} + readOnly={isReadOnly} /> @@ -204,6 +207,7 @@ const Personal: FC = () => { label={t('financial.company_postal_code')} {...formik.getFieldProps('postalCode')} error_text={formik.touched.postalCode && formik.errors.postalCode ? formik.errors.postalCode : ''} + readOnly={isReadOnly} /> @@ -212,6 +216,7 @@ const Personal: FC = () => { {...formik.getFieldProps('address')} error_text={formik.touched.address && formik.errors.address ? formik.errors.address : ''} label={t('financial.address')} + readOnly={isReadOnly} /> @@ -228,6 +233,7 @@ const Personal: FC = () => { className='w-fit px-7' onClick={() => formik.handleSubmit()} isLoading={createRealUser.isPending} + disabled={isReadOnly} >
{ @@ -63,6 +64,7 @@ const Home: FC = () => { color='#00D16C' count={4} description={t('home.active_service')} + link={Pages.services.mine} /> { color='#FF7B00' count={4} description={t('home.unread_messages')} + link={Pages.ticket.list} /> { color='#0047FF' count={4} description={t('home.receip')} + link={Pages.receipts.index} /> { color='#FF0000' count={4} description={t('home.unread_announcement')} + link={Pages.announcement.list} />
diff --git a/src/pages/home/components/ItemDashboard.tsx b/src/pages/home/components/ItemDashboard.tsx index f83b6ab..70e763c 100644 --- a/src/pages/home/components/ItemDashboard.tsx +++ b/src/pages/home/components/ItemDashboard.tsx @@ -1,17 +1,19 @@ import { FC, ReactNode } from 'react' +import { Link } from 'react-router-dom' type Props = { title: string icon: ReactNode, color: string, count: number, - description: string + description: string, + link: string } const ItemDashboard: FC = (props: Props) => { return ( -
+
{props.icon}
@@ -28,7 +30,7 @@ const ItemDashboard: FC = (props: Props) => {
- + ) } diff --git a/src/pages/notification/Notification.tsx b/src/pages/notification/Notification.tsx index 3d6664b..b810aa1 100644 --- a/src/pages/notification/Notification.tsx +++ b/src/pages/notification/Notification.tsx @@ -5,25 +5,31 @@ import { useTranslation } from 'react-i18next'; import { clx } from '../../helpers/utils'; import StatusCircle from '../../components/StatusCircle'; import { useOutsideClick } from '../../hooks/useOutSideClick'; -import { useGetNotification } from './hooks/useNotificationData'; +import { useGetNotification, useReadAll } from './hooks/useNotificationData'; import { NotificationItemType } from './types/NotificationTypes'; import { timeAgo } from '../../config/func'; import InfiniteScroll from 'react-infinite-scroll-component'; import MoonLoader from "react-spinners/MoonLoader" +import Button from '../../components/Button'; +import { toast } from 'react-toastify'; const Notifications: FC = () => { const { t } = useTranslation('global'); const ref = useOutsideClick(() => setShowModal(false)); const [activeTab, setActiveTab] = useState<'all' | 'read' | 'unread'>('all'); const [showModal, setShowModal] = useState(false); - const { data, fetchNextPage, hasNextPage, isFetching, isLoading } = useGetNotification(); - + const { data, fetchNextPage, hasNextPage, refetch } = useGetNotification(); + const readAll = useReadAll() const posts = data?.pages.flatMap((page) => page.data?.notifications) || []; - console.log('posts:', posts); - console.log('hasNextPage:', hasNextPage); - console.log('isFetching:', isFetching); - console.log('isLoading:', isLoading); + const handleAllRead = () => { + readAll.mutate(undefined, { + onSuccess: () => { + refetch() + toast.success(t('success')) + } + }) + } return (
@@ -38,6 +44,8 @@ const Notifications: FC = () => {
+ +
setActiveTab('all')} @@ -68,6 +76,18 @@ const Notifications: FC = () => {
+
+ +
+
{ return useInfiniteQuery({ @@ -15,3 +15,9 @@ export const useGetNotification = () => { }, }); }; + +export const useReadAll = () => { + return useMutation({ + mutationFn: (_) => api.readAll(), + }); +}; diff --git a/src/pages/notification/service/NotificationService.ts b/src/pages/notification/service/NotificationService.ts index a6b1388..17bab36 100644 --- a/src/pages/notification/service/NotificationService.ts +++ b/src/pages/notification/service/NotificationService.ts @@ -4,3 +4,8 @@ export const getNotifications = async (page: number) => { const { data } = await axios.get(`/notifications?page=${page}`); return data; }; + +export const readAll = async () => { + const { data } = await axios.patch(`/notifications/read-all`); + return data; +}; diff --git a/src/pages/ticket/TicketList.tsx b/src/pages/ticket/TicketList.tsx index d042d7c..c83ad34 100644 --- a/src/pages/ticket/TicketList.tsx +++ b/src/pages/ticket/TicketList.tsx @@ -1,7 +1,7 @@ import { FC, useState } from 'react' import { useTranslation } from 'react-i18next' import Button from '../../components/Button' -import { Add, Eye, MessageRemove, MessageTick, MessageTime } from 'iconsax-react' +import { Add, Eye, MessageRemove, Messages1, MessageTick, MessageTime } from 'iconsax-react' import Tabs from '../../components/Tabs' import Td from '../../components/Td' import { Link } from 'react-router-dom' @@ -12,7 +12,7 @@ import moment from 'moment-jalaali' const TicketList: FC = () => { const { t } = useTranslation('global') - const [activeTab, setActiveTab] = useState<'ANSWERED' | 'PENDING' | 'CLOSED'>('PENDING') + const [activeTab, setActiveTab] = useState<'ANSWERED' | 'PENDING' | 'CLOSED' | ''>('') const getTickets = useGetTickets(activeTab) return ( @@ -40,6 +40,11 @@ const TicketList: FC = () => { , + label: t('ticket.all'), + value: '' + }, { icon: , label: t('ticket.checking'), @@ -50,11 +55,6 @@ const TicketList: FC = () => { label: t('ticket.answered'), value: 'ANSWERED' }, - // { - // icon: , - // label: t('ticket.wait_answered'), - // value: 'wating' - // }, { icon: , label: t('ticket.closed'), diff --git a/src/pages/ticket/service/TicketService.ts b/src/pages/ticket/service/TicketService.ts index 440f759..80d0044 100644 --- a/src/pages/ticket/service/TicketService.ts +++ b/src/pages/ticket/service/TicketService.ts @@ -2,7 +2,11 @@ import axios from "../../../config/axios"; import { AddMessageTicketType, CreateTicketType } from "../types/TicketTypes"; export const getTickets = async (status: string) => { - const { data } = await axios.get(`/tickets?status=${status}`); + let query = ``; + if (status) { + query = `?status=${status}`; + } + const { data } = await axios.get(`/tickets${query}`); return data; }; diff --git a/src/pages/wallet/components/CardtoCard.tsx b/src/pages/wallet/components/CardtoCard.tsx index 5a8c18a..d2866ac 100644 --- a/src/pages/wallet/components/CardtoCard.tsx +++ b/src/pages/wallet/components/CardtoCard.tsx @@ -12,6 +12,7 @@ import * as Yup from 'yup' import { useSingleUpload } from '../../ticket/hooks/useTicketData' import { toast } from 'react-toastify' import { ErrorType } from '../../../helpers/types' +import { TickCircle } from 'iconsax-react' const CardtoCard: FC = () => { @@ -98,11 +99,18 @@ const CardtoCard: FC = () => {
diff --git a/src/pages/wallet/components/Online.tsx b/src/pages/wallet/components/Online.tsx index 797bdb0..d5f0cec 100644 --- a/src/pages/wallet/components/Online.tsx +++ b/src/pages/wallet/components/Online.tsx @@ -7,8 +7,9 @@ import { useGetGetWays, usePayment } from '../hooks/useWalletData' import { toast } from 'react-toastify' import { ErrorType } from '../../../helpers/types' import { GatewayItemType } from '../types/WalletTypes' +import { TickCircle } from 'iconsax-react' -const defaultAmounts = [100000, 200000, 500000, 1000000, 2000000, 5000000, 10000000] +const defaultAmounts = [500000, 1000000, 3000000, 5000000, 8000000, 10000000]; const Online: FC = () => { @@ -24,7 +25,7 @@ const Online: FC = () => { toast.error(t('wallet.error_select_price')) } else { const amout = desiredAmount === 0 ? amountSelected : desiredAmount - if (amout < 100000) { + if (amout < 500000) { toast.error(t('wallet.error_min_price')) return } else { @@ -103,11 +104,20 @@ const Online: FC = () => {
+ +
diff --git a/src/pages/wallet/components/Sheba.tsx b/src/pages/wallet/components/Sheba.tsx index 018456a..d34090b 100644 --- a/src/pages/wallet/components/Sheba.tsx +++ b/src/pages/wallet/components/Sheba.tsx @@ -12,6 +12,7 @@ import * as Yup from 'yup' import { useSingleUpload } from '../../ticket/hooks/useTicketData' import { toast } from 'react-toastify' import { ErrorType } from '../../../helpers/types' +import { TickCircle } from 'iconsax-react' const CardtoCard: FC = () => { @@ -99,11 +100,18 @@ const CardtoCard: FC = () => {
diff --git a/src/shared/Header.tsx b/src/shared/Header.tsx index 7355572..bdfc7aa 100644 --- a/src/shared/Header.tsx +++ b/src/shared/Header.tsx @@ -101,7 +101,7 @@ const Header: FC = () => { isActive isWithoutLine /> -
+
{t('home.balance')}
{NumberFormat(getWalletBalance.data?.data?.balance) + ' ' + t('toman')}