Update: 2026-05-08 23:18:10

This commit is contained in:
Hamza-Ayed
2026-05-08 23:18:10 +03:00
parent 72424bf92c
commit 67cc322f5e
10 changed files with 99 additions and 23 deletions

View File

@@ -98,4 +98,22 @@ class SubscriptionController extends GetxController {
}
return null;
}
Future<bool> cancelPaymentRequest(String paymentId) async {
try {
isLoading.value = true;
final res = await DioClient().client.post('payments/cancel', data: {'payment_id': paymentId});
if (res.data['success'] == true) {
AppSnackbar.showSuccess('تم الإلغاء', 'تم إلغاء طلب الدفع بنجاح');
await loadAll();
return true;
}
} catch (e) {
AppLogger.error('Failed to cancel payment', e);
AppSnackbar.showError('خطأ', 'فشل إلغاء طلب الدفع');
} finally {
isLoading.value = false;
}
return false;
}
}

View File

@@ -169,21 +169,57 @@ class SubscriptionView extends StatelessWidget {
Text('رقم المرجع: ${payment['reference_number']}', style: const TextStyle(fontFamily: 'monospace', fontSize: 14, fontWeight: FontWeight.bold)),
Text('المبلغ: ${payment['amount_jod']} JOD', style: const TextStyle(fontSize: 13)),
const SizedBox(height: 8),
SizedBox(
width: double.infinity,
child: ElevatedButton.icon(
icon: const Icon(Icons.upload_file, size: 18),
label: const Text('رفع وصل الدفع'),
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFFF59E0B),
foregroundColor: Colors.white,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
const SizedBox(height: 12),
Row(
children: [
Expanded(
child: ElevatedButton.icon(
icon: const Icon(Icons.upload_file, size: 18),
label: const Text('رفع الوصل'),
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFFF59E0B),
foregroundColor: Colors.white,
padding: const EdgeInsets.symmetric(vertical: 10),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
),
onPressed: () {
Get.toNamed('/payment-receipt', arguments: payment);
},
),
),
onPressed: () {
// Navigate to receipt upload screen
Get.toNamed('/payment-receipt', arguments: payment);
},
),
const SizedBox(width: 8),
Expanded(
child: OutlinedButton.icon(
icon: const Icon(Icons.close, size: 18),
label: const Text('إلغاء الطلب'),
style: OutlinedButton.styleFrom(
foregroundColor: Colors.red,
side: const BorderSide(color: Colors.red),
padding: const EdgeInsets.symmetric(vertical: 10),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
),
onPressed: () {
Get.dialog(
AlertDialog(
title: const Text('إلغاء الطلب'),
content: const Text('هل أنت متأكد من إلغاء طلب الدفع هذا؟'),
actions: [
TextButton(onPressed: () => Get.back(), child: const Text('تراجع')),
TextButton(
onPressed: () {
Get.back();
final ctrl = Get.find<SubscriptionController>();
ctrl.cancelPaymentRequest(payment['id'].toString());
},
child: const Text('نعم، إلغاء', style: TextStyle(color: Colors.red)),
),
],
),
);
},
),
),
],
),
],
),