kyc delete member approve reject
This commit is contained in:
@ -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