diff --git a/src/pages/transfer/transfertype/blocks/ListToolBar.tsx b/src/pages/transfer/transfertype/blocks/ListToolBar.tsx index c1c116c..d57d2a4 100644 --- a/src/pages/transfer/transfertype/blocks/ListToolBar.tsx +++ b/src/pages/transfer/transfertype/blocks/ListToolBar.tsx @@ -23,6 +23,31 @@ interface TransferType { const API_URL = apiConfig.service_transaction; +const typeLabelMap: Record = { + D: 'Disbursement', + O: 'Other', + CA: 'Change Group Emoney Customer to Agent', + AC: 'Change Group Emoney Agent to Customer', + PC: 'Change Group Point Agent to Customer', + PA: 'Change Group Point Customer to Agent', + CE: 'Return Customer Emoney', + AD: 'Return Agent Deposit', + AM: 'Return Agent Merchant', + AE: 'Return Agent Emoney', + R: 'Reward Point', + TE: 'Top Up Escrow', + TM: 'Top Up Master Agent', + TA: 'Top Up Agent', + PL: 'Purchase Loja', + DE: 'Disbursment Escrow', + DM: 'Disbursment Master Agent', + DA: 'Disbursment Agent', + WI: 'Withdraw Merchant', + IC: 'Income Merchant' +}; + +// Import section remains the same... + const ListToolbar = () => { const { table, reload } = useDataGrid(); const { handleAddDialog } = useManageTransferTypeContext(); @@ -31,40 +56,10 @@ const ListToolbar = () => { const [searchValue, setSearchValue] = useState(''); const [statusTypes, setStatusTypes] = useState(''); - const [walletOrigins, setWalletOrigin] = useState(''); - const [walletDestinations, setWalletDestination] = useState(''); const [approval, setApproval] = useState(''); const unique = (arr: string[]) => Array.from(new Set(arr)); const types = unique(transferTypes.map((t) => t.type)); - const origins = unique(transferTypes.map((t) => t.wallet_origin.name)); - const destinations = unique(transferTypes.map((t) => t.wallet_destination.name)); - const typeLabelMap: Record = { - D: 'Disbursement', - O: 'Other', - CA: 'Change Group Emoney Customer to Agent', - AC: 'Change Group Emoney Agent to Customer', - PC: 'Change Group Point Agent to Customer', - PA: 'Change Group Point Customer to Agent', - CE: 'Return Customer Emoney', - AD: 'Return Agent Deposit', - AM: 'Return Agent Merchant', - AE: 'Return Agent Emoney', - R: 'Reward Point', - TE: 'Top Up Escrow', - TM: 'Top Up Master Agent', - TA: 'Top Up Agent', - PL: 'Purchase Loja', - DE: 'Disbursment Escrow', - DM: 'Disbursment Master Agent', - DA: 'Disbursment Agent', - WI: 'Withdraw Merchant', - IC: 'Income Merchant' - }; - const approvalLabelMap: Record = { - Y: 'Yes', - N: 'No' - }; useEffect(() => { const timer = setTimeout(() => { @@ -78,18 +73,6 @@ const ListToolbar = () => { table.getColumn('type')?.setFilterValue(statusTypes); }, [statusTypes]); - useEffect(() => { - table - .getColumn('wallet_origin') - ?.setFilterValue(walletOrigins === '__all__' ? '' : walletOrigins); - }, [walletOrigins]); - - useEffect(() => { - table - .getColumn('wallet_destination') - ?.setFilterValue(walletDestinations === '__all__' ? '' : walletDestinations); - }, [walletDestinations]); - useEffect(() => { table.getColumn('status_approval')?.setFilterValue(approval); }, [approval]); @@ -114,46 +97,30 @@ const ListToolbar = () => { }, []); const handleClearFilter = () => { + // Reset state variables setSearchValue(''); - setStatusTypes('__all__'); - setWalletOrigin('__all__'); - setWalletDestination('__all__'); - setApproval('__all__'); + setStatusTypes(''); + setApproval(''); + + // Clear all column filters table.getColumn('name')?.setFilterValue(''); table.getColumn('type')?.setFilterValue(''); - table.getColumn('wallet_origin')?.setFilterValue(''); - table.getColumn('wallet_destination')?.setFilterValue(''); table.getColumn('status_approval')?.setFilterValue(''); - table.setPageIndex(0); - }; - const renderSelect = ( - placeholder: string, - value: string, - onChange: (val: string) => void, - options: string[], - labelMap?: Record - ) => ( -
- -
- ); - + // Force reset the Select components by using setTimeout + // This ensures the state updates are processed before resetting the UI + setTimeout(() => { + // Reset to first page + table.setPageIndex(0); + // Reload the data + reload(); + }, 0); + }; return (
+ {/* Top bar */}
diff --git a/src/pages/transfer/transfertype/hooks/ManageTransferTypeContext.tsx b/src/pages/transfer/transfertype/hooks/ManageTransferTypeContext.tsx index 8ae1aed..0d7982a 100644 --- a/src/pages/transfer/transfertype/hooks/ManageTransferTypeContext.tsx +++ b/src/pages/transfer/transfertype/hooks/ManageTransferTypeContext.tsx @@ -325,7 +325,7 @@ const ManageTransferTypeContextProvider = ({ children }: { children: React.React order_direction: orderDirection, filter: JSON.stringify(filterObject) }); - // console.log(response); + console.log(response); return { data: response?.data.list, totalCount: response?.data.total_count }; };