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