diff --git a/src/pages/master/wallet/hooks/ManageWalletContext.tsx b/src/pages/master/wallet/hooks/ManageWalletContext.tsx index 0142fb8..e6592d3 100644 --- a/src/pages/master/wallet/hooks/ManageWalletContext.tsx +++ b/src/pages/master/wallet/hooks/ManageWalletContext.tsx @@ -73,7 +73,7 @@ const ManageWalletContextProvider = ({ children }: { children: React.ReactNode } const columns = useMemo[]>( () => [ { - accessorFn: (row) => row.Wallet_name, + accessorFn: (row) => row.name, id: 'name', header: ({ column }) => , enableSorting: true, @@ -83,7 +83,7 @@ const ManageWalletContextProvider = ({ children }: { children: React.ReactNode } } }, { - accessorFn: (row) => row.Wallet_description, + accessorFn: (row) => row.description, id: 'description', header: ({ column }) => , enableSorting: true, @@ -93,13 +93,13 @@ const ManageWalletContextProvider = ({ children }: { children: React.ReactNode } } }, { - accessorFn: (row) => row.Wallet_status, + accessorFn: (row) => row.status, id: 'status', header: ({ column }) => , enableSorting: true, enableHiding: false, cell: ({ row }) => { - const isActive = row.original.Wallet_status === 'Y'; + const isActive = row.original.status === 'Y'; return ( } layout={{ card: true }} - sorting={[{ id: 'created_at', desc: true }]} + sorting={[{ id: 'wallets.created_at', desc: true }]} serverSide={true} onFetchData={({ pageIndex, pageSize, sorting, columnFilters }) => getWalletLists(pageIndex, pageSize, sorting, columnFilters) diff --git a/src/pages/master/walletRule/blocks/AddDialog.tsx b/src/pages/master/walletRule/blocks/AddDialog.tsx index 6bdd088..108901c 100644 --- a/src/pages/master/walletRule/blocks/AddDialog.tsx +++ b/src/pages/master/walletRule/blocks/AddDialog.tsx @@ -40,14 +40,24 @@ interface GroupProps { status: string; } -interface WalletProps { - ID: string; +interface WalletGroupProps { + id: string; name: string; - id_currency: string; + description: string; status: string; } +interface WalletProps { + id: string; + name: string; + id_currency: string; + status: string; + group: WalletGroupProps[]; +} + const API_URL_WALLET = apiConfig.service_wallet; +const API_URL_MASTERDATA = apiConfig.service_master_data; + const AddDialog = () => { const { showAddDialog, handleAddDialog, selectedWalletRule } = useManageWalletRuleContext(); const { reload } = useDataGrid(); @@ -143,7 +153,7 @@ const AddDialog = () => { const getWalletLists = async (sorting: any) => { try { - const response = await GetData(`${API_URL_WALLET}/dashboard/wallet`, { + const response = await GetData(`${API_URL_MASTERDATA}/wallet/list`, { limit: 100, page: 1, with_deleted: false, @@ -158,8 +168,11 @@ const AddDialog = () => { } }; + const selectedWallet = wallets.find((wallet) => wallet.id === formField.id_wallet); + const filteredGroups = selectedWallet ? selectedWallet.group : []; + useEffect(() => { - getWalletLists([{ id: 'name', desc: false }]); + getWalletLists([{ id: 'wallets.name', desc: false }]); getGroupLists([{ id: 'name', desc: false }]); }, []); @@ -193,14 +206,16 @@ const AddDialog = () => { setFormField({ ...formField, id_group: value })} + disabled={filteredGroups.length === 0} > - {groups.map((group) => ( - - {group.name} - - ))} + {filteredGroups.length > 0 ? ( + filteredGroups.map((group) => ( + + {group.name} + + )) + ) : ( + No groups available + )} diff --git a/src/pages/master/walletRule/hooks/ManageWalletRuleContext.tsx b/src/pages/master/walletRule/hooks/ManageWalletRuleContext.tsx index 9b7385b..14e66c3 100644 --- a/src/pages/master/walletRule/hooks/ManageWalletRuleContext.tsx +++ b/src/pages/master/walletRule/hooks/ManageWalletRuleContext.tsx @@ -222,7 +222,7 @@ const ManageWalletRuleContextProvider = ({ children }: { children: React.ReactNo order_direction: sorting[0].desc == false ? 'ASC' : 'DESC', filter: JSON.stringify(filter) }); - console.log(response?.data); + // console.log(response?.data); setWalletRules(response?.data.list); return { data: response?.data.list, totalCount: response?.data.total_count }; } catch (error) {