From 1664a05ca434c0f5c47d8d0fdcb4915f2e904e55 Mon Sep 17 00:00:00 2001 From: Kavehhn174 Date: Sun, 16 Aug 2026 22:38:00 +0330 Subject: [PATCH] Add admin UI to cancel payment transactions. Show cancelled rows in history with distinct styling and let admins confirm cancellation so replacement transactions can be added later. --- src/api/paymentApi.js | 3 +- src/components/common/StatusTag.vue | 4 +- src/views/payments/PaymentDetailView.vue | 93 ++++++++++++++++++++++-- 3 files changed, 93 insertions(+), 7 deletions(-) diff --git a/src/api/paymentApi.js b/src/api/paymentApi.js index 2198dc0..4e02f16 100644 --- a/src/api/paymentApi.js +++ b/src/api/paymentApi.js @@ -9,5 +9,6 @@ export const paymentApi = { update: (id, data) => axiosInstance.put(`/payments/admin/update/${id}`, data), delete: (id) => axiosInstance.delete(`/payments/admin/delete/${id}`), recordTransaction: (paymentId, data) => axiosInstance.post(`/payments/admin/transactions/${paymentId}`, data), - updateTransaction: (transactionId, data) => axiosInstance.put(`/payments/admin/transactions/${transactionId}`, data) + updateTransaction: (transactionId, data) => axiosInstance.put(`/payments/admin/transactions/${transactionId}`, data), + cancelTransaction: (transactionId) => axiosInstance.post(`/payments/admin/transactions/${transactionId}/cancel`) }; diff --git a/src/components/common/StatusTag.vue b/src/components/common/StatusTag.vue index bc54dfa..052e7ff 100644 --- a/src/components/common/StatusTag.vue +++ b/src/components/common/StatusTag.vue @@ -46,7 +46,8 @@ const PAYMENT_LABELS = { paid: 'تسویه‌شده', partial: 'پرداخت جزئی', pending: 'در انتظار پرداخت', - overdue: 'معوق' + overdue: 'معوق', + cancelled: 'لغوشده' }; const PENDING_STUDENT_LABELS = { @@ -65,6 +66,7 @@ const severity = computed(() => { if (val === 'partial' || val === 'پرداخت جزئی') return 'contrast'; if (val === 'pending' || val === 'در انتظار پرداخت') return 'info'; if (val === 'overdue' || val === 'معوق شده' || val === 'معوق') return 'danger'; + if (val === 'cancelled' || val === 'canceled' || val === 'لغوشده') return 'secondary'; } if (props.type === 'session') { diff --git a/src/views/payments/PaymentDetailView.vue b/src/views/payments/PaymentDetailView.vue index 7e0edf0..e9124c5 100644 --- a/src/views/payments/PaymentDetailView.vue +++ b/src/views/payments/PaymentDetailView.vue @@ -67,15 +67,21 @@ - + @@ -108,10 +114,31 @@ {{ data.notes || '—' }} - + @@ -209,6 +236,20 @@