From bbf17930a7d05ac1b2c217450c50253c28baee0f Mon Sep 17 00:00:00 2001 From: wayanrivan Date: Wed, 7 May 2025 11:10:28 +0700 Subject: [PATCH] update destination customer full name in datatable --- .../hooks/ApprovalTransactionContext.tsx | 19 +++++++++++++++++-- .../hooks/TransactionContext.tsx | 17 ++++++++++++++++- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/pages/transaction/approval-transaction/hooks/ApprovalTransactionContext.tsx b/src/pages/transaction/approval-transaction/hooks/ApprovalTransactionContext.tsx index 3022287..39b0d25 100644 --- a/src/pages/transaction/approval-transaction/hooks/ApprovalTransactionContext.tsx +++ b/src/pages/transaction/approval-transaction/hooks/ApprovalTransactionContext.tsx @@ -95,7 +95,22 @@ const ApprovalTransactionProvider = ({ children }: { children: React.ReactNode } }, { accessorKey: 'origin_customer.fullname', - header: ({ column }) => , + header: ({ column }) => , + enableSorting: false, + enableHiding: false, + meta: { + headerClassName: 'w-[250px]', + }, + }, + { + accessorFn: (row) => { + const purchase = row?.purchase?.destination_customer.fullname; + const transfer = row?.transfer?.destination_customer.fullname; + + return purchase ?? transfer ?? "-"; + }, + id: 'destination_customer.fullname', + header: ({ column }) => , enableSorting: false, enableHiding: false, meta: { @@ -270,7 +285,7 @@ const ApprovalTransactionProvider = ({ children }: { children: React.ReactNode } }); } - + // ✅ Declare formattedFilter early const formattedFilter: any = { "Transactions.transaction_date": { diff --git a/src/pages/transaction/history-transaction/hooks/TransactionContext.tsx b/src/pages/transaction/history-transaction/hooks/TransactionContext.tsx index 8e78c1c..39bc60f 100644 --- a/src/pages/transaction/history-transaction/hooks/TransactionContext.tsx +++ b/src/pages/transaction/history-transaction/hooks/TransactionContext.tsx @@ -107,13 +107,28 @@ const TransactionProvider = ({ children }: { children: React.ReactNode }) => { }, { accessorKey: 'origin_customer.fullname', - header: ({ column }) => , + header: ({ column }) => , enableSorting: false, enableHiding: false, meta: { headerClassName: 'w-[250px]' } }, + { + accessorFn: (row) => { + const purchase = row?.purchase?.destination_customer.fullname; + const transfer = row?.transfer?.destination_customer.fullname; + + return purchase ?? transfer ?? "-"; + }, + id: 'destination_customer.fullname', + header: ({ column }) => , + enableSorting: false, + enableHiding: false, + meta: { + headerClassName: 'w-[250px]', + }, + }, { accessorFn: (row) => { const purchaseAmount = row?.purchase?.amount;