This commit is contained in:
hamid zarghami
2025-02-23 16:58:51 +03:30
parent bc3d068dfd
commit 158da6ce8a
16 changed files with 138 additions and 53 deletions
+9
View File
@@ -82,6 +82,15 @@ const LoginStep2: FC = () => {
})
}
useEffect(() => {
if (formik.values.code.length === 5) {
formik.handleSubmit()
}
}, [formik.values.code])
return (
<div>
<div className='mt-5'>
+18 -18
View File
@@ -194,24 +194,24 @@ const Legal: FC = () => {
<div>{t('financial.notice_cannot_edit_legal')}</div>
</div>
{
!isReadOnly &&
<div className='mt-8 flex justify-end'>
<Button
className='w-fit px-7'
onClick={() => formik.handleSubmit()}
isLoading={createLegalUser.isPending}
>
<div className='flex gap-2 items-center'>
<TickCircle
size={24}
color='white'
/>
<div>{t('save')}</div>
</div>
</Button>
</div>
}
<div className='mt-8 flex justify-end'>
<Button
disabled={isReadOnly}
className='w-fit px-7'
onClick={() => formik.handleSubmit()}
isLoading={createLegalUser.isPending}
>
<div className='flex gap-2 items-center'>
<TickCircle
size={24}
color='white'
/>
<div>{t('save')}</div>
</div>
</Button>
</div>
</div>
</div>
@@ -113,12 +113,14 @@ const Personal: FC = () => {
]}
{...formik.getFieldProps('gender')}
error_text={formik.touched.gender && formik.errors.gender ? formik.errors.gender : ''}
readOnly={isReadOnly}
/>
<Input
label={t('financial.father_name')}
{...formik.getFieldProps('fatherName')}
error_text={formik.touched.fatherName && formik.errors.fatherName ? formik.errors.fatherName : ''}
readOnly={isReadOnly}
/>
</div>
@@ -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}
/>
</div>
@@ -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}
/>
</div>
@@ -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}
/>
</div>
@@ -228,6 +233,7 @@ const Personal: FC = () => {
className='w-fit px-7'
onClick={() => formik.handleSubmit()}
isLoading={createRealUser.isPending}
disabled={isReadOnly}
>
<div className='flex gap-2 items-center'>
<TickCircle
+5
View File
@@ -9,6 +9,7 @@ import DanakLearning from './components/DanakLearning'
import { Carousel } from "@material-tailwind/react";
import { useGetAds } from '../ads/hooks/useAdsData'
import { AdsDisplayLocation, AdsItemType } from '../ads/types/AdsTypes'
import { Pages } from '../../config/Pages'
const Home: FC = () => {
@@ -63,6 +64,7 @@ const Home: FC = () => {
color='#00D16C'
count={4}
description={t('home.active_service')}
link={Pages.services.mine}
/>
<ItemDashboard
@@ -71,6 +73,7 @@ const Home: FC = () => {
color='#FF7B00'
count={4}
description={t('home.unread_messages')}
link={Pages.ticket.list}
/>
<ItemDashboard
@@ -79,6 +82,7 @@ const Home: FC = () => {
color='#0047FF'
count={4}
description={t('home.receip')}
link={Pages.receipts.index}
/>
<ItemDashboard
@@ -87,6 +91,7 @@ const Home: FC = () => {
color='#FF0000'
count={4}
description={t('home.unread_announcement')}
link={Pages.announcement.list}
/>
</div>
+5 -3
View File
@@ -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: Props) => {
return (
<div className='p-6 min-w-[40%] xl:min-w-[20%] flex flex-col items-center xl:items-start flex-1 h-[178px] bg-white rounded-3xl'>
<Link to={props.link} className='p-6 min-w-[40%] xl:min-w-[20%] flex flex-col items-center xl:items-start flex-1 h-[178px] bg-white rounded-3xl'>
<div className='size-10 rounded-full bg-[#EEF0F7] flex justify-center items-center'>
{props.icon}
</div>
@@ -28,7 +30,7 @@ const ItemDashboard: FC<Props> = (props: Props) => {
</div>
</div>
</div>
</div>
</Link>
)
}
+27 -7
View File
@@ -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<boolean>(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 (
<div ref={ref}>
@@ -38,6 +44,8 @@ const Notifications: FC = () => {
</div>
</div>
<div className="mt-6 flex h-8 border border-white border-opacity-35 text-xs rounded-lg overflow-hidden">
<div
onClick={() => setActiveTab('all')}
@@ -68,6 +76,18 @@ const Notifications: FC = () => {
</div>
</div>
<div className='flex mt-4 justify-end'>
<Button
isLoading={readAll.isPending}
onClick={handleAllRead}
className={clx(
'flex-1 border bg-transparent text-xs h-7 rounded-md cursor-pointer text-white border-white border-opacity-70 flex justify-center items-center',
)}
>
{t('notif.all_read')}
</Button>
</div>
<div className="mt-6 flex flex-col gap-4 text-xs overflow-auto">
<InfiniteScroll
dataLength={posts.length}
@@ -1,5 +1,5 @@
import * as api from "../service/NotificationService";
import { useInfiniteQuery } from "@tanstack/react-query";
import { useInfiniteQuery, useMutation } from "@tanstack/react-query";
export const useGetNotification = () => {
return useInfiniteQuery({
@@ -15,3 +15,9 @@ export const useGetNotification = () => {
},
});
};
export const useReadAll = () => {
return useMutation({
mutationFn: (_) => api.readAll(),
});
};
@@ -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;
};
+7 -7
View File
@@ -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 = () => {
<Tabs
active={activeTab}
items={[
{
icon: <Messages1 color={activeTab === '' ? 'black' : '#8C90A3'} size={22} />,
label: t('ticket.all'),
value: ''
},
{
icon: <MessageTime color={activeTab === 'PENDING' ? 'black' : '#8C90A3'} size={22} />,
label: t('ticket.checking'),
@@ -50,11 +55,6 @@ const TicketList: FC = () => {
label: t('ticket.answered'),
value: 'ANSWERED'
},
// {
// icon: <Message2 color={activeTab === 'wating' ? 'black' : '#8C90A3'} size={22} />,
// label: t('ticket.wait_answered'),
// value: 'wating'
// },
{
icon: <MessageRemove color={activeTab === 'CLOSED' ? 'black' : '#8C90A3'} size={22} />,
label: t('ticket.closed'),
+5 -1
View File
@@ -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;
};
+10 -2
View File
@@ -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 = () => {
<div className='mt-10 flex justify-end'>
<Button
label={t('wallet.submit_slip')}
className='w-[180px]'
onClick={() => formik.handleSubmit()}
isLoading={depositTransfer.isPending || upload.isPending}
/>
>
<div className='flex gap-2 items-center'>
<TickCircle
size={24}
color='white'
/>
<div>{t('wallet.submit_slip')}</div>
</div>
</Button>
</div>
</Fragment>
+14 -4
View File
@@ -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 = () => {
<div className='mt-10 flex justify-end'>
<Button
label={t('wallet.pay')}
className='w-[180px]'
onClick={handlePay}
isLoading={payment.isPending}
/>
>
<div className='flex gap-2 items-center'>
<TickCircle
size={24}
color='white'
/>
<div>{t('wallet.pay')}</div>
</div>
</Button>
</div>
</div>
</div>
+10 -2
View File
@@ -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 = () => {
<div className='mt-10 flex justify-end'>
<Button
label={t('wallet.submit_slip')}
className='w-[180px]'
onClick={() => formik.handleSubmit()}
isLoading={depositTransfer.isPending || upload.isPending}
/>
>
<div className='flex gap-2 items-center'>
<TickCircle
size={24}
color='white'
/>
<div>{t('wallet.submit_slip')}</div>
</div>
</Button>
</div>
</Fragment>