diff --git a/src/config/Pages.ts b/src/config/Pages.ts index 90f9eef..1289a9f 100644 --- a/src/config/Pages.ts +++ b/src/config/Pages.ts @@ -159,5 +159,6 @@ export const Pages = { reseller: { list: "/reseller/list", create: "/reseller/create", + withdraw: "/reseller/withdraw", }, }; diff --git a/src/langs/fa.json b/src/langs/fa.json index f1bc561..9f822a9 100644 --- a/src/langs/fa.json +++ b/src/langs/fa.json @@ -87,7 +87,8 @@ "dmail": "دی میل", "domain": "دامنه", "reseller": "نماینده", - "resellers": "نمایندگان" + "resellers": "نمایندگان", + "withdraw": "درخواست های برداشت" }, "reseller": { "list": "لیست نمایندکان", @@ -95,7 +96,10 @@ "name": "نام نمایندگی", "user": "کاربر", "submit": "ساخت", - "phone": "شماره" + "phone": "شماره", + "withdraws": "درخواست های برداشت", + "requestedAmount": "مبلغ درخواستی", + "paitAt": "تاریخ پرداخت" }, "dmail": { "domain": "لیست دامنه ها" diff --git a/src/pages/reseller/Withdraw.tsx b/src/pages/reseller/Withdraw.tsx new file mode 100644 index 0000000..dafaed6 --- /dev/null +++ b/src/pages/reseller/Withdraw.tsx @@ -0,0 +1,91 @@ +import { useState, type FC } from 'react' +import { useGetWithdraws } from './hooks/useResellerData' +import { useTranslation } from 'react-i18next' +import PageLoading from '../../components/PageLoading' +import Td from '../../components/Td' +import { WithDrawItemType } from './types/Types' +import { NumberFormat } from '../../config/func' +import moment from 'moment-jalaali' +import Button from '../../components/Button' +import Pagination from '../../components/Pagination' +import DefaulModal from '../../components/DefaulModal' +import Input from '../../components/Input' + +const Withdraw: FC = () => { + + const { t } = useTranslation('global') + const [page, setPage] = useState(1) + const [showModal, setShowModal] = useState(false) + const getWithdraw = useGetWithdraws(page) + + return ( +
+
+
+ {t('reseller.withdraws')} +
+
+ + { + getWithdraw.isPending ? + + : +
+ + + + + + + { + getWithdraw?.data?.data?.requests?.map((item: WithDrawItemType) => { + return ( + + + + ) + }) + } + +
+ + + +
+ + + +
+
+ } + + + + setShowModal(false)} + isHeader + title_header='پرداخت' + > + +
+ +
+ +
+ +
+ ) +} + +export default Withdraw \ No newline at end of file diff --git a/src/pages/reseller/components/Payment.tsx b/src/pages/reseller/components/Payment.tsx new file mode 100644 index 0000000..606824d --- /dev/null +++ b/src/pages/reseller/components/Payment.tsx @@ -0,0 +1,9 @@ +import { type FC } from 'react' + +const Payment: FC = () => { + return ( +
Payment
+ ) +} + +export default Payment \ No newline at end of file diff --git a/src/pages/reseller/hooks/useResellerData.ts b/src/pages/reseller/hooks/useResellerData.ts index daccab7..76751f7 100644 --- a/src/pages/reseller/hooks/useResellerData.ts +++ b/src/pages/reseller/hooks/useResellerData.ts @@ -13,3 +13,10 @@ export const useCreateResellers = () => { mutationFn: api.createReseller, }); }; + +export const useGetWithdraws = (page: number) => { + return useQuery({ + queryKey: ["withdraw", page], + queryFn: () => api.getWithDraws(page), + }); +}; diff --git a/src/pages/reseller/service/ResellerService.ts b/src/pages/reseller/service/ResellerService.ts index 3dafae8..8e1460a 100644 --- a/src/pages/reseller/service/ResellerService.ts +++ b/src/pages/reseller/service/ResellerService.ts @@ -10,3 +10,10 @@ export const createReseller = async (params: CreateResellerType) => { const { data } = await axios.post(`/reseller`, params); return data; }; + +export const getWithDraws = async (page: number) => { + const { data } = await axios.get( + `/reseller/withdraw-request/admin?page=${page}`, + ); + return data; +}; diff --git a/src/pages/reseller/types/Types.ts b/src/pages/reseller/types/Types.ts index 0ccdb97..a24e3cb 100644 --- a/src/pages/reseller/types/Types.ts +++ b/src/pages/reseller/types/Types.ts @@ -11,3 +11,10 @@ export type CreateResellerType = { name: string; phone: string; }; + +export type WithDrawItemType = { + id: string; + user: UserItemType; + requestedAmount: string; + paidAt: string; +}; diff --git a/src/router/Main.tsx b/src/router/Main.tsx index fb3abfd..9ceda7c 100644 --- a/src/router/Main.tsx +++ b/src/router/Main.tsx @@ -93,6 +93,7 @@ import SubscriptionsList from '../pages/subscriptions/List.tsx' import Domains from '../pages/dmail/Domains.tsx' import ResellerList from '../pages/reseller/List.tsx' import CreateReseller from '../pages/reseller/Create.tsx' +import Withdraw from '../pages/reseller/Withdraw.tsx' // import WarningsList from '../pages/dmenu/reports/List' // TODO: Create this component const MainRouter: FC = () => { @@ -203,6 +204,7 @@ const MainRouter: FC = () => { } /> } /> + } /> diff --git a/src/shared/SideBar.tsx b/src/shared/SideBar.tsx index 5863623..2d705e3 100644 --- a/src/shared/SideBar.tsx +++ b/src/shared/SideBar.tsx @@ -2,7 +2,7 @@ import { FC, useEffect, useState } from 'react' import LogoImage from '../assets/images/logo.svg' import LogoSmall from '../assets/images/logo-small.svg' import { useTranslation } from 'react-i18next' -import { Card, Code, CodeCircle, DocumentLike, DocumentText, Element3, Gallery, Headphone, Home2, Logout, Messages3, Money3, NotificationStatus, People, Profile, Receipt21, Setting2, SmsTracking, Teacher, TicketDiscount, UserSquare, Activity, Icon, Category, Warning2, Building, Sms, Chart21, ArrowDown2, Global, UserTick } from 'iconsax-react' +import { Card, Code, CodeCircle, DocumentLike, DocumentText, Element3, Gallery, Headphone, Home2, Logout, Messages3, Money3, NotificationStatus, People, Profile, Receipt21, Setting2, SmsTracking, Teacher, TicketDiscount, UserSquare, Activity, Icon, Category, Warning2, Building, Sms, Chart21, ArrowDown2, Global, UserTick, Money } from 'iconsax-react' import SideBarItem from './SideBarItem' import { useLocation } from 'react-router-dom' import { Pages } from '../config/Pages' @@ -359,6 +359,16 @@ const SideBar: FC = () => { activeName='reseller' /> + +
+ } + title={t('sidebar.withdraw')} + isActive={isActive('reseller/withdraw')} + link={Pages.reseller.withdraw} + activeName='reseller' + /> +
}