From 31cea258a72e7f7f03d8665c2645e791073ad583 Mon Sep 17 00:00:00 2001 From: ValdiANS Date: Mon, 4 May 2026 09:48:46 +0700 Subject: [PATCH] fix: adjust delete click handler --- src/components/pages/purchase/PurchaseTable.tsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/components/pages/purchase/PurchaseTable.tsx b/src/components/pages/purchase/PurchaseTable.tsx index facc7079..781fb2cf 100644 --- a/src/components/pages/purchase/PurchaseTable.tsx +++ b/src/components/pages/purchase/PurchaseTable.tsx @@ -409,10 +409,17 @@ const PurchaseTable = () => { setIsDeleteLoading(true); try { - await PurchaseApi.delete(selectedPurchase?.id as number); - refreshPurchaseRequests(); - deleteModal.closeModal(); - toast.success('Berhasil menghapus data permintaan pembelian!'); + const deleteResponse = await PurchaseApi.delete( + selectedPurchase?.id as number + ); + + if (isResponseSuccess(deleteResponse)) { + refreshPurchaseRequests(); + deleteModal.closeModal(); + toast.success('Berhasil menghapus data permintaan pembelian!'); + } else { + toast.error(deleteResponse?.message ?? 'Gagal menghapus data!'); + } } catch { toast.error('Gagal menghapus data permintaan pembelian!'); }