diff --git a/src/pages/reseller/Withdraw.tsx b/src/pages/reseller/Withdraw.tsx
index dafaed6..5736a3c 100644
--- a/src/pages/reseller/Withdraw.tsx
+++ b/src/pages/reseller/Withdraw.tsx
@@ -6,10 +6,10 @@ 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'
+import Payment from './components/Payment'
const Withdraw: FC = () => {
@@ -49,10 +49,12 @@ const Withdraw: FC = () => {
|
|
-
+ {
+ !item.paidAt ?
+
+ :
+ پرداخت شده
+ }
|
)
diff --git a/src/pages/reseller/components/Payment.tsx b/src/pages/reseller/components/Payment.tsx
index 606824d..99dec7e 100644
--- a/src/pages/reseller/components/Payment.tsx
+++ b/src/pages/reseller/components/Payment.tsx
@@ -1,8 +1,71 @@
-import { type FC } from 'react'
+import { useState, type FC } from 'react'
+import Button from '../../../components/Button'
+import DefaulModal from '../../../components/DefaulModal'
+import { usePayment } from '../hooks/useResellerData'
+import Input from '../../../components/Input'
+import { toast } from 'react-toastify'
+import { ErrorType } from '../../../helpers/types'
+
+type Props = {
+ id: string,
+ refetch: () => void,
+}
+
+const Payment: FC = ({ id, refetch }) => {
+
+ const payment = usePayment()
+ const [showModal, setShowModal] = useState(false)
+ const [transactionId, setTransactionId] = useState('')
+
+ const handleSubmit = () => {
+ if (transactionId.length > 0) {
+ payment.mutate({ id: id, transactionId: transactionId }, {
+ onSuccess: () => {
+ toast('با موفقت ثبت شد')
+ setTransactionId('')
+ refetch()
+ },
+ onError: (error: ErrorType) => {
+ toast.error(error.response?.data?.error.message[0])
+ }
+ })
+ } else {
+ toast.error('شماره تراکنش رو پر کنید')
+ }
+ }
-const Payment: FC = () => {
return (
- Payment
+
+
)
}
diff --git a/src/pages/reseller/hooks/useResellerData.ts b/src/pages/reseller/hooks/useResellerData.ts
index 76751f7..549901f 100644
--- a/src/pages/reseller/hooks/useResellerData.ts
+++ b/src/pages/reseller/hooks/useResellerData.ts
@@ -20,3 +20,9 @@ export const useGetWithdraws = (page: number) => {
queryFn: () => api.getWithDraws(page),
});
};
+
+export const usePayment = () => {
+ return useMutation({
+ mutationFn: api.payment,
+ });
+};
diff --git a/src/pages/reseller/service/ResellerService.ts b/src/pages/reseller/service/ResellerService.ts
index 8e1460a..b8702af 100644
--- a/src/pages/reseller/service/ResellerService.ts
+++ b/src/pages/reseller/service/ResellerService.ts
@@ -1,5 +1,5 @@
import axios from "../../../config/axios";
-import { CreateResellerType } from "../types/Types";
+import { CreateResellerType, PaymentType } from "../types/Types";
export const getResellers = async () => {
const { data } = await axios.get(`/reseller`);
@@ -17,3 +17,11 @@ export const getWithDraws = async (page: number) => {
);
return data;
};
+
+export const payment = async (params: PaymentType) => {
+ const { data } = await axios.patch(
+ `/reseller/withdraw-request/${params.id}`,
+ params,
+ );
+ return data;
+};
diff --git a/src/pages/reseller/types/Types.ts b/src/pages/reseller/types/Types.ts
index a24e3cb..f14cf10 100644
--- a/src/pages/reseller/types/Types.ts
+++ b/src/pages/reseller/types/Types.ts
@@ -18,3 +18,8 @@ export type WithDrawItemType = {
requestedAmount: string;
paidAt: string;
};
+
+export type PaymentType = {
+ transactionId: string;
+ id: string;
+};