diff --git a/src/pages/disbursement/history-transaction/blocks/DetailTransaction.tsx b/src/pages/disbursement/history-transaction/blocks/DetailTransaction.tsx index c3ded68..5f5ff7b 100644 --- a/src/pages/disbursement/history-transaction/blocks/DetailTransaction.tsx +++ b/src/pages/disbursement/history-transaction/blocks/DetailTransaction.tsx @@ -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}`, { diff --git a/src/pages/disbursement/history-transaction/blocks/DetailTransactionLog.tsx b/src/pages/disbursement/history-transaction/blocks/DetailTransactionLog.tsx index b2a668f..3c24c1a 100644 --- a/src/pages/disbursement/history-transaction/blocks/DetailTransactionLog.tsx +++ b/src/pages/disbursement/history-transaction/blocks/DetailTransactionLog.tsx @@ -54,10 +54,6 @@ const TransactionLogViewer = () => { detailLogData } = useTransactionContext(); - console.log('detailLogData: ', detailLogData) - - - return ( diff --git a/src/pages/members/kyc-delete-member/blocks/DetailDialog.tsx b/src/pages/members/kyc-delete-member/blocks/DetailDialog.tsx index 7875949..4ba5dfc 100644 --- a/src/pages/members/kyc-delete-member/blocks/DetailDialog.tsx +++ b/src/pages/members/kyc-delete-member/blocks/DetailDialog.tsx @@ -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 ( @@ -38,8 +38,8 @@ const DetailDialog = () => {
- - + +
) : (
)} diff --git a/src/pages/members/kyc-delete-member/hooks/ManageKycDeletionContext.tsx b/src/pages/members/kyc-delete-member/hooks/ManageKycDeletionContext.tsx index bf5e46f..c0742fd 100644 --- a/src/pages/members/kyc-delete-member/hooks/ManageKycDeletionContext.tsx +++ b/src/pages/members/kyc-delete-member/hooks/ManageKycDeletionContext.tsx @@ -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>; + 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(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(null); const [detailKyc, setDetailKyc] = useState(); const [manageKyc, setManageKyc] = useState([]); - 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[]>( () => [ { @@ -242,7 +266,8 @@ const ManageKycDeletionContextProvider = ({ children }: { children: React.ReactN selectedIdCustomer, setShowDetailDialog, setDetailKyc, - detailKyc + detailKyc, + handleApproveReject, }} > diff --git a/src/pages/transaction/approval-transaction/blocks/DetailApprovalTransaction.tsx b/src/pages/transaction/approval-transaction/blocks/DetailApprovalTransaction.tsx index e032a94..848eb7c 100644 --- a/src/pages/transaction/approval-transaction/blocks/DetailApprovalTransaction.tsx +++ b/src/pages/transaction/approval-transaction/blocks/DetailApprovalTransaction.tsx @@ -30,7 +30,7 @@ const DetailApprovalTransaction = () => { const response = await GetData(`${API_URL}/transaction/history/detail/${selectedTransactionId}`, { id: selectedTransactionId }); - // console.log(response?.data); + console.log(response?.data); setTransactionDetails(response?.data); } catch (error) { console.error('Error fetching transaction', error); @@ -190,7 +190,7 @@ const DetailApprovalTransaction = () => {

Name

-

{transactionDetails?.type.name}

+

{transactionDetails?.type?.name || '-'}

@@ -346,9 +346,11 @@ const DetailApprovalTransaction = () => {

Description

{transactionDetails?.description}

+

Name

-

{transactionDetails?.type.name}

+

{transactionDetails?.type?.name || '-'}

+

Reference

diff --git a/src/pages/transaction/history-transaction/blocks/DetailTransaction.tsx b/src/pages/transaction/history-transaction/blocks/DetailTransaction.tsx index 55db0a0..6d774d7 100644 --- a/src/pages/transaction/history-transaction/blocks/DetailTransaction.tsx +++ b/src/pages/transaction/history-transaction/blocks/DetailTransaction.tsx @@ -189,7 +189,7 @@ const DetailTransaction = () => {

Name

-

{transactionDetails?.type.name}

+

{transactionDetails?.type?.name || '-'}

@@ -347,7 +347,7 @@ const DetailTransaction = () => {

Name

-

{transactionDetails?.type.name}

+

{transactionDetails?.type?.name || '-'}

Reference

diff --git a/src/pages/transfer/transferfee/blocks/AddDialog.tsx b/src/pages/transfer/transferfee/blocks/AddDialog.tsx index 0860010..6b73eed 100644 --- a/src/pages/transfer/transferfee/blocks/AddDialog.tsx +++ b/src/pages/transfer/transferfee/blocks/AddDialog.tsx @@ -70,6 +70,8 @@ const AddFeeDialog = () => { selectedTransferFee, transactionTypeId } = useManageTransferFeeContext(); + const [customerSearchTerm, setCustomerSearchTerm] = useState(''); + const [open, setOpen] = useState(false); const [alert, setAlert] = useState({ show: false, @@ -111,6 +113,7 @@ const AddFeeDialog = () => { credit_destination_account: '' }; + const [formField, setFormField] = useState(initialState); const resetForm = () => { @@ -151,6 +154,13 @@ const AddFeeDialog = () => { } }, [showAddFeeDialog, transactionTypeId, GetData]); + useEffect(() => { + if (!showAddFeeDialog) { + setCustomerSearchTerm(''); + setOpen(false); + } + }, [showAddFeeDialog]); + useEffect(() => { const created_time = new Date(); const formattedTime = created_time.toISOString().slice(0, 19).replace('T', ' '); @@ -619,13 +629,72 @@ const AddFeeDialog = () => { - {renderSelectWithLoading( - formField.credit_destination, - (value) => setFormField({ ...formField, credit_destination: value }), - customersWithNames, - 'Select Customer', - isLoadingCustomers - )} +
+
setOpen(!open)} + > + + {customers.find( + (customer) => customer.id === formField.credit_destination + )?.username || 'Search customer...'} + + +
+ + {open && ( +
+
+ setCustomerSearchTerm(e.target.value)} + autoComplete="off" + onClick={(e) => e.stopPropagation()} + autoFocus + /> +
+
+ {customers + .filter( + (customer) => + customer.username + .toLowerCase() + .includes(customerSearchTerm.toLowerCase()) || + customer.msisdn.includes(customerSearchTerm) + ) + .map((customer) => ( +
{ + setFormField({ + ...formField, + credit_destination: customer.id + }); + setOpen(false); + }} + > + {customer.username} +
+ ))} + {customers.filter( + (customer) => + customer.username + .toLowerCase() + .includes(customerSearchTerm.toLowerCase()) || + customer.msisdn.includes(customerSearchTerm) + ).length === 0 && ( +
+ No customer found +
+ )} +
+
+ )} +
)}
diff --git a/src/pages/transfer/transferfee/blocks/EditDialog.tsx b/src/pages/transfer/transferfee/blocks/EditDialog.tsx index b8077b5..3d6b0ce 100644 --- a/src/pages/transfer/transferfee/blocks/EditDialog.tsx +++ b/src/pages/transfer/transferfee/blocks/EditDialog.tsx @@ -72,7 +72,6 @@ const EditFeeDialog = () => { message: '' }); - // Loading states const [isLoadingTransferFee, setIsLoadingTransferFee] = useState(false); const [isLoadingTransactionType, setIsLoadingTransactionType] = useState(false); const [isLoadingWallets, setIsLoadingWallets] = useState(false); @@ -687,9 +686,7 @@ const EditFeeDialog = () => { {customers.find(customer => customer.id === formField.credit_destination)?.username || 'Search customer...'} - -
{open && ( @@ -702,9 +699,7 @@ const EditFeeDialog = () => { value={customerSearchTerm} onChange={(e) => setCustomerSearchTerm(e.target.value)} autoComplete="off" - // Prevent clicks from closing the dropdown onClick={(e) => e.stopPropagation()} - // Auto focus the input when opened autoFocus />