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!'); }