update
This commit is contained in:
@ -77,12 +77,40 @@ const ShowDetailWalletDialog: React.FC<ShowDetailWalletDialogProps> = ({
|
|||||||
}, [fetchTransferType]);
|
}, [fetchTransferType]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
const categoryMap: Record<string, string> = {
|
||||||
|
T: 'TRANSFER',
|
||||||
|
P: 'PURCHASE',
|
||||||
|
W: 'WITHDRAW',
|
||||||
|
U: 'TOP UP',
|
||||||
|
R: 'RETURN',
|
||||||
|
N: 'TOP UP PARTNER',
|
||||||
|
E: 'REWARD',
|
||||||
|
L: 'PURCHASE LOJA',
|
||||||
|
B: 'TOP UP P24',
|
||||||
|
A: 'TRANSFER AGENT',
|
||||||
|
M: 'WITHDRAWAL AGENT',
|
||||||
|
O: 'TOP UP AGENT',
|
||||||
|
S: 'TRANSFER P24',
|
||||||
|
I: 'WIJTDRAW MERCHANT',
|
||||||
|
D: 'DONATION',
|
||||||
|
F: 'FEE',
|
||||||
|
V: 'REVERSAL',
|
||||||
|
C: 'CASHBACK CASH',
|
||||||
|
H: 'CASHBACK POINT',
|
||||||
|
};
|
||||||
|
|
||||||
const uniqueCategories = Array.from(
|
const uniqueCategories = Array.from(
|
||||||
new Set(transaction.map((tx) => tx.category).filter((cat) => !!cat))
|
new Set(
|
||||||
|
transaction
|
||||||
|
.map((tx) => categoryMap[tx.category] || '_') // map code to label or default to '_'
|
||||||
|
.filter((cat) => !!cat && cat !== '_') // remove undefined/null or underscore
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
setCategory(uniqueCategories);
|
setCategory(uniqueCategories);
|
||||||
}, [transaction]);
|
}, [transaction]);
|
||||||
|
|
||||||
|
|
||||||
const handleTransferTypeChange = (value: string) => {
|
const handleTransferTypeChange = (value: string) => {
|
||||||
setSelectedTransferType(value === 'all' ? null : value);
|
setSelectedTransferType(value === 'all' ? null : value);
|
||||||
};
|
};
|
||||||
@ -174,10 +202,37 @@ const ShowDetailWalletDialog: React.FC<ShowDetailWalletDialogProps> = ({
|
|||||||
meta: { headerClassName: 'min-w-[100px]' },
|
meta: { headerClassName: 'min-w-[100px]' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
accessorFn: (row: any) => {
|
||||||
|
switch (row.category) {
|
||||||
|
case 'T': return 'TRANSFER';
|
||||||
|
case 'P': return 'PURCHASE';
|
||||||
|
case 'W': return 'WITHDRAW';
|
||||||
|
case 'U': return 'TOP UP';
|
||||||
|
case 'R': return 'RETURN';
|
||||||
|
case 'N': return 'TOP UP PARTNER';
|
||||||
|
case 'E': return 'REWARD';
|
||||||
|
case 'L': return 'PURCHASE LOJA';
|
||||||
|
case 'B': return 'TOP UP P24';
|
||||||
|
case 'A': return 'TRANSFER AGENT';
|
||||||
|
case 'M': return 'WITHDRAWAL AGENT';
|
||||||
|
case 'O': return 'TOP UP AGENT';
|
||||||
|
case 'S': return 'TRANSFER P24';
|
||||||
|
case 'I': return 'WIJTDRAW MERCHANT';
|
||||||
|
case 'D': return 'DONATION';
|
||||||
|
case 'F': return 'FEE';
|
||||||
|
case 'V': return 'REVERSAL';
|
||||||
|
case 'C': return 'CASHBACK CASH';
|
||||||
|
case 'H': return 'CASHBACK POINT';
|
||||||
|
default: return '_';
|
||||||
|
}
|
||||||
|
},
|
||||||
accessorKey: 'category',
|
accessorKey: 'category',
|
||||||
header: ({ column }: any) => <DataGridColumnHeader title="Category" column={column} />,
|
header: ({ column }: any) => <DataGridColumnHeader title="Category" column={column} />,
|
||||||
enableSorting: false,
|
enableSorting: false,
|
||||||
meta: { headerClassName: 'min-w-[80px]' },
|
enableHiding: false,
|
||||||
|
meta: {
|
||||||
|
headerClassName: 'w-[250px]'
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: 'date',
|
accessorKey: 'date',
|
||||||
@ -225,7 +280,7 @@ const ShowDetailWalletDialog: React.FC<ShowDetailWalletDialogProps> = ({
|
|||||||
filter: JSON.stringify(filters)
|
filter: JSON.stringify(filters)
|
||||||
});
|
});
|
||||||
|
|
||||||
// console.log(filters);
|
// console.log(response);
|
||||||
|
|
||||||
if (!response || !response.data) {
|
if (!response || !response.data) {
|
||||||
console.warn('No data received:', response);
|
console.warn('No data received:', response);
|
||||||
|
|||||||
Reference in New Issue
Block a user