fix group name on wallet history
This commit is contained in:
@ -192,8 +192,7 @@ const ManageWalletContextProvider = ({ children }: { children: React.ReactNode }
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorFn: (row) => row.group.name,
|
accessorKey: 'group_name',
|
||||||
id: 'group_name',
|
|
||||||
header: ({ column }) => <DataGridColumnHeader title="Group Name" column={column} />,
|
header: ({ column }) => <DataGridColumnHeader title="Group Name" column={column} />,
|
||||||
enableSorting: false,
|
enableSorting: false,
|
||||||
enableHiding: false,
|
enableHiding: false,
|
||||||
@ -253,12 +252,13 @@ const ManageWalletContextProvider = ({ children }: { children: React.ReactNode }
|
|||||||
order_direction: sortDirection,
|
order_direction: sortDirection,
|
||||||
filter: JSON.stringify(filterParams)
|
filter: JSON.stringify(filterParams)
|
||||||
});
|
});
|
||||||
// console.log(response);
|
|
||||||
if (!response || !response.data) {
|
if (!response || !response.data) {
|
||||||
console.warn('No data received:', response);
|
console.warn('No data received:', response);
|
||||||
return { data: [], totalCount: 0 };
|
return { data: [], totalCount: 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fetch wallets to map wallet names
|
||||||
const walletsResponse = await GetData(`${API_URL_WALLET}/dashboard/wallet/`, {
|
const walletsResponse = await GetData(`${API_URL_WALLET}/dashboard/wallet/`, {
|
||||||
limit: 100,
|
limit: 100,
|
||||||
page: 1,
|
page: 1,
|
||||||
@ -267,6 +267,15 @@ const ManageWalletContextProvider = ({ children }: { children: React.ReactNode }
|
|||||||
order_direction: 'ASC'
|
order_direction: 'ASC'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Fetch groups to map group names
|
||||||
|
const groupsResponse = await GetData(`${API_URL_WALLET}/dashboard/group/`, {
|
||||||
|
limit: 100,
|
||||||
|
page: 1,
|
||||||
|
with_deleted: false,
|
||||||
|
order_field: 'created_at',
|
||||||
|
order_direction: 'ASC'
|
||||||
|
});
|
||||||
|
|
||||||
const walletsMap = walletsResponse?.data?.list
|
const walletsMap = walletsResponse?.data?.list
|
||||||
? walletsResponse.data.list.reduce((acc: any, wallet: any) => {
|
? walletsResponse.data.list.reduce((acc: any, wallet: any) => {
|
||||||
acc[wallet.ID] = wallet.name;
|
acc[wallet.ID] = wallet.name;
|
||||||
@ -274,9 +283,17 @@ const ManageWalletContextProvider = ({ children }: { children: React.ReactNode }
|
|||||||
}, {})
|
}, {})
|
||||||
: {};
|
: {};
|
||||||
|
|
||||||
|
const groupsMap = groupsResponse?.data?.list
|
||||||
|
? groupsResponse.data.list.reduce((acc: any, group: any) => {
|
||||||
|
acc[group.ID] = group.name;
|
||||||
|
return acc;
|
||||||
|
}, {})
|
||||||
|
: {};
|
||||||
|
|
||||||
const enrichedData = response?.data.list.map((item: any) => ({
|
const enrichedData = response?.data.list.map((item: any) => ({
|
||||||
...item,
|
...item,
|
||||||
name: walletsMap[item.id_wallet] || 'Unknown Wallet'
|
name: walletsMap[item.id_wallet] || 'Unknown Wallet',
|
||||||
|
group_name: groupsMap[item.id_group] || 'Unknown Group'
|
||||||
}));
|
}));
|
||||||
|
|
||||||
setWallets(enrichedData);
|
setWallets(enrichedData);
|
||||||
|
|||||||
Reference in New Issue
Block a user