From 58ddd9b99109219a66974ad54baf85571922226c Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Wed, 13 May 2026 15:26:10 +0700 Subject: [PATCH 1/4] fix: set sortDescFirst false --- src/components/Table.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/Table.tsx b/src/components/Table.tsx index d9d81543..2795cbb4 100644 --- a/src/components/Table.tsx +++ b/src/components/Table.tsx @@ -173,6 +173,7 @@ const Table = ({ const tableOptions: TableOptions = { columns, data: isLoading ? (DUMMY_SKELETON_DATA as TData[]) : data, // Type assertion + defaultColumn: { sortDescFirst: false }, getCoreRowModel: getCoreRowModel(), getSortedRowModel: getSortedRowModel(), getPaginationRowModel: getPaginationRowModel(), From 910a36857e0647041b7e3e8d6ed91bb7af73a8e5 Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Wed, 13 May 2026 15:26:30 +0700 Subject: [PATCH 2/4] fix: pass the rest of secondaryButton props --- src/components/modal/ConfirmationModalWithNotes.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/modal/ConfirmationModalWithNotes.tsx b/src/components/modal/ConfirmationModalWithNotes.tsx index 20f63019..cf55a7c9 100644 --- a/src/components/modal/ConfirmationModalWithNotes.tsx +++ b/src/components/modal/ConfirmationModalWithNotes.tsx @@ -69,6 +69,7 @@ const ConfirmationModalWithNotes: React.FC = ({ secondaryButton={ secondaryButton ? { + ...secondaryButton, text: secondaryButton?.text ?? 'Tidak', onClick: (e) => { if (secondaryButton && secondaryButton?.onClick) { From fe2a2dfb43fb6c7893366ff6defbcb9d42ca6807 Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Wed, 13 May 2026 15:29:03 +0700 Subject: [PATCH 3/4] fix: add loading state to approve modal --- .../pages/marketing/MarketingTable.tsx | 70 +++++++++++++------ 1 file changed, 48 insertions(+), 22 deletions(-) diff --git a/src/components/pages/marketing/MarketingTable.tsx b/src/components/pages/marketing/MarketingTable.tsx index 08dcf318..39384b0d 100644 --- a/src/components/pages/marketing/MarketingTable.tsx +++ b/src/components/pages/marketing/MarketingTable.tsx @@ -297,6 +297,8 @@ const MarketingTable = () => { const [isLoadingExportingToExcel, setIsLoadingExportingToExcel] = useState(false); + const [isApproveLoading, setIsApproveLoading] = useState(false); + const [isDeliveryLoading, setIsDeliveryLoading] = useState(false); const filterResetHandler = () => { updateFilter('product_ids', '', true); @@ -452,23 +454,33 @@ const MarketingTable = () => { return; } - const approveMarketingRes: BaseApiResponse | undefined = - approveAction === 'APPROVED' - ? await MarketingApi.bulkApprovals( - idsToProcess, - nextApprovalStatus as 'SALES_ORDER' | 'DELIVERY_ORDER', - '', - notes || `APPROVED marketing ${idsToProcess.join(', ')}` - ) - : await SalesOrderApi.bulkApprovals(idsToProcess, approveAction, notes); + setIsApproveLoading(true); - if (isResponseSuccess(approveMarketingRes)) { - confirmationModal.closeModal(); - toast.success(approveMarketingRes?.message as string); - setRowSelection({}); + try { + const approveMarketingRes: BaseApiResponse | undefined = + approveAction === 'APPROVED' + ? await MarketingApi.bulkApprovals( + idsToProcess, + nextApprovalStatus as 'SALES_ORDER' | 'DELIVERY_ORDER', + '', + notes || `APPROVED marketing ${idsToProcess.join(', ')}` + ) + : await SalesOrderApi.bulkApprovals( + idsToProcess, + approveAction, + notes + ); + + if (isResponseSuccess(approveMarketingRes)) { + confirmationModal.closeModal(); + toast.success(approveMarketingRes?.message as string); + setRowSelection({}); + } + + refreshMarketing(); + } finally { + setIsApproveLoading(false); } - - refreshMarketing(); }; const bulkDeliveryDateChangeHandler: ChangeEventHandler = ( @@ -530,13 +542,21 @@ const MarketingTable = () => { }; const confirmationModalDeliveryClickHandler = async (notes: string) => { - const res = await SalesOrderApi.delivery(selectedItem?.id as number, notes); - deliveryModal.closeModal(); - toast.success(res?.message as string); - refreshMarketing?.(); - router.push( - `/marketing/detail/delivery-orders/edit?id=${selectedItem?.id}` - ); + setIsDeliveryLoading(true); + try { + const res = await SalesOrderApi.delivery( + selectedItem?.id as number, + notes + ); + deliveryModal.closeModal(); + toast.success(res?.message as string); + refreshMarketing?.(); + router.push( + `/marketing/detail/delivery-orders/edit?id=${selectedItem?.id}` + ); + } finally { + setIsDeliveryLoading(false); + } }; const getRowCanSelect = useCallback( @@ -1020,11 +1040,13 @@ const MarketingTable = () => { text={`Apakah anda yakin ingin ${approveAction == 'APPROVED' ? 'approve' : 'reject'} data penjualan tahap ${selectedApprovalStep ?? '-'} (${idsToProcess.length} data)?`} secondaryButton={{ text: 'Tidak', + isLoading: isApproveLoading, onClick: confirmationModal.closeModal, }} primaryButton={{ text: 'Ya', color: approveAction === 'APPROVED' ? 'success' : 'error', + isLoading: isApproveLoading, onClick: approveMarketingHandler, }} /> @@ -1048,10 +1070,12 @@ const MarketingTable = () => { text={`Apakah anda yakin ingin deliver penjualan ${selectedItem?.so_number}?`} secondaryButton={{ text: 'Tidak', + isLoading: isDeliveryLoading, }} primaryButton={{ text: 'Ya', color: 'success', + isLoading: isDeliveryLoading, onClick: confirmationModalDeliveryClickHandler, }} /> @@ -1111,6 +1135,7 @@ const MarketingTable = () => {