kyc delete member approve reject
This commit is contained in:
@ -61,7 +61,6 @@ const DetailTransaction = () => {
|
||||
|
||||
useEffect(() => {
|
||||
const fetchTransactionDetails = async () => {
|
||||
console.log(selectedTransactionId)
|
||||
if (selectedTransactionId) {
|
||||
try {
|
||||
const response = await GetData(`${API_URL}/transaction/history/${selectedTransactionId}`, {
|
||||
|
||||
@ -54,10 +54,6 @@ const TransactionLogViewer = () => {
|
||||
detailLogData
|
||||
} = useTransactionContext();
|
||||
|
||||
console.log('detailLogData: ', detailLogData)
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<Dialog open={showDetailLogDialog} onOpenChange={setShowDetailLogDialog}>
|
||||
<DialogContent className="container-fixed max-w-[1280px] w-full h-[90vh] flex flex-col p-6 overflow-hidden">
|
||||
|
||||
@ -13,7 +13,7 @@ import axios from 'axios';
|
||||
|
||||
const API_URL = apiConfig.service_customer;
|
||||
const DetailDialog = () => {
|
||||
const { showDetailDialog, setShowDetailDialog, detailKyc } = useManageKycDeletionContext();
|
||||
const { showDetailDialog, setShowDetailDialog, detailKyc, handleApproveReject } = useManageKycDeletionContext();
|
||||
|
||||
return (
|
||||
<Dialog open={showDetailDialog} onOpenChange={setShowDetailDialog}>
|
||||
@ -38,8 +38,8 @@ const DetailDialog = () => {
|
||||
|
||||
<div className="flex justify-end gap-2 mt-3">
|
||||
<Button type="button" variant="outline" onClick={() => setShowDetailDialog(false)}>Cancel</Button>
|
||||
<Button onClick={()=>{}} variant="destructive" color="warning">Reject</Button>
|
||||
<Button onClick={()=>{}} variant="default" color="primary">Approve</Button>
|
||||
<Button onClick={()=>handleApproveReject(detailKyc.id, 'N')} variant="destructive" color="warning">Reject</Button>
|
||||
<Button onClick={()=>handleApproveReject(detailKyc.id, 'Y')} variant="default" color="primary">Approve</Button>
|
||||
</div>
|
||||
</div>
|
||||
) : (<div></div>)}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { DataGridColumnHeader, DataGridProvider, KeenIcon } from '@/components';
|
||||
import { Toaster } from '@/components/ui/sonner';
|
||||
import { toast } from 'sonner';
|
||||
import { apiConfig } from '@/config/api.config';
|
||||
import { ColumnDef } from '@tanstack/react-table';
|
||||
import { createContext, useCallback, useMemo, useState } from 'react';
|
||||
@ -36,6 +37,7 @@ interface ContextProps {
|
||||
selectedIdCustomer: string | null;
|
||||
detailKyc: any | null;
|
||||
setDetailKyc: React.Dispatch<React.SetStateAction<any>>;
|
||||
handleApproveReject: (customerDeletionId: string, status_approve: string) => {};
|
||||
}
|
||||
|
||||
const initialProps: ContextProps = {
|
||||
@ -48,6 +50,7 @@ const initialProps: ContextProps = {
|
||||
setShowDetailDialog: () => { },
|
||||
detailKyc: async () => {},
|
||||
setDetailKyc: () => { },
|
||||
handleApproveReject: () => ({customerDeletionId: '0', status_approve: 'Y'}),
|
||||
};
|
||||
|
||||
const ManageKycDeletionContext = createContext<ContextProps>(initialProps);
|
||||
@ -83,13 +86,15 @@ export const renderStatusBadge = (statusRaw: string | null | undefined) => {
|
||||
);
|
||||
};
|
||||
|
||||
// const { reload } = useDataGrid();
|
||||
|
||||
const ManageKycDeletionContextProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
const [showDetailDialog, setShowDetailDialog] = useState(false);
|
||||
const [showAddDialog, setShowAddDialog] = useState(false);
|
||||
const [selectedIdCustomer, setSelectedIdCustomer] = useState<string | null>(null);
|
||||
const [detailKyc, setDetailKyc] = useState<any>();
|
||||
const [manageKyc, setManageKyc] = useState<ManageKycDeletionProps[]>([]);
|
||||
const { GetData } = useCallApi();
|
||||
const { GetData, PostData } = useCallApi();
|
||||
|
||||
const getKycDeletionList = async (page: number, limit: number, sorting: any, filter: any) => {
|
||||
try {
|
||||
@ -130,12 +135,11 @@ const ManageKycDeletionContextProvider = ({ children }: { children: React.ReactN
|
||||
};
|
||||
|
||||
const handleDetailDialog = useCallback(async (show: boolean, selected_id_customer: string | null) => {
|
||||
setSelectedIdCustomer(show ? selected_id_customer : null);
|
||||
let detailCustomer = await GetData(`${API_URL}/customer_deletion/detail/${selected_id_customer}`, {})
|
||||
setDetailKyc(detailCustomer?.data)
|
||||
console.log('detailCustomer: ',detailCustomer)
|
||||
console.log('detailCustomer2: ',detailCustomer?.data)
|
||||
console.log('detailKyc: ', detailKyc)
|
||||
if (show == true) {
|
||||
setSelectedIdCustomer(show ? selected_id_customer : null);
|
||||
let detailCustomer = await GetData(`${API_URL}/customer_deletion/detail/${selected_id_customer}`, {})
|
||||
setDetailKyc(detailCustomer?.data)
|
||||
}
|
||||
setShowDetailDialog(show);
|
||||
}, []);
|
||||
|
||||
@ -143,6 +147,26 @@ const ManageKycDeletionContextProvider = ({ children }: { children: React.ReactN
|
||||
setShowAddDialog(show);
|
||||
}, []);
|
||||
|
||||
const handleApproveReject = useCallback(async (customerDeletionId: string, status_approve: string) => {
|
||||
console.log(customerDeletionId, status_approve)
|
||||
try {
|
||||
let approveReject = await PostData(`${API_URL}/customer_deletion/update_status/${customerDeletionId}`, {
|
||||
status_approve
|
||||
})
|
||||
|
||||
if (approveReject?.status == true) {
|
||||
toast.success('Success update status approval')
|
||||
handleDetailDialog(false, null)
|
||||
} else {
|
||||
toast.warning(`${approveReject?.message}`)
|
||||
handleDetailDialog(false, null)
|
||||
}
|
||||
} catch (error) {
|
||||
toast.warning('Failed to approve/reject')
|
||||
handleDetailDialog(false, null)
|
||||
}
|
||||
}, [])
|
||||
|
||||
const columns = useMemo<ColumnDef<any>[]>(
|
||||
() => [
|
||||
{
|
||||
@ -242,7 +266,8 @@ const ManageKycDeletionContextProvider = ({ children }: { children: React.ReactN
|
||||
selectedIdCustomer,
|
||||
setShowDetailDialog,
|
||||
setDetailKyc,
|
||||
detailKyc
|
||||
detailKyc,
|
||||
handleApproveReject,
|
||||
}}
|
||||
>
|
||||
<Toaster expand visibleToasts={9} duration={3000} />
|
||||
|
||||
Reference in New Issue
Block a user