diff --git a/app/i18n/config.js b/app/i18n/config.js index da5e4ca..852e335 100644 --- a/app/i18n/config.js +++ b/app/i18n/config.js @@ -1498,6 +1498,12 @@ const resources = { "payments.closeButton": "Close", "payments.propertyLabel": "Property", "payments.uploadReceipt": "Upload Receipt Image", + "payments.receiptDialogTitle": "Upload payment receipt", + "payments.receiptDialogDescription": "Please upload a clear image of the transfer receipt before completing the payment.", + "payments.receiptUploadRequiredHint": "A receipt image is required for this payment method.", + "payments.receiptRequired": "Please upload the payment receipt image first.", + "payments.receiptSelected": "Selected file:", + "payments.continueToPay": "Continue to pay", "payments.loadingPaymentMethods": "Loading payment methods...", "payments.noPaymentMethodsAvailable": "No payment methods available.", "payments.paymentMethodName": "Payment Method", @@ -2549,6 +2555,13 @@ const resources = { "payment.transferDesc": "حول من حساب داخلي ثم أرسل المرجع", "payment.electronic": "دفع إلكتروني", "payment.electronicDesc": "سيتم تفعيل الدفع الإلكتروني والتحويل لاحقاً", + "payments.uploadReceipt": "رفع صورة الوصل", + "payments.receiptDialogTitle": "رفع وصل الدفع", + "payments.receiptDialogDescription": "يرجى رفع صورة واضحة لوصل التحويل قبل إكمال الدفع.", + "payments.receiptUploadRequiredHint": "مطلوب رفع صورة الوصل لهذه الطريقة.", + "payments.receiptRequired": "يرجى رفع صورة وصل الدفع أولاً.", + "payments.receiptSelected": "الملف المختار:", + "payments.continueToPay": "متابعة الدفع", /* ─── Owner Properties Page ─── */ "deleteConfirmTitle": "تأكيد الحذف", diff --git a/app/payments/page.js b/app/payments/page.js index a8563de..9db8d7e 100644 --- a/app/payments/page.js +++ b/app/payments/page.js @@ -70,6 +70,32 @@ function isHaramText(value) { return text.includes('haram') || text.includes('هرم') || text.includes('هرام'); } +function isReceiptRequiredPayment(value, method = null) { + const haystack = [ + value, + method?.name, + method?.label, + method?.id, + method?.description, + ] + .filter(Boolean) + .join(' '); + + const text = normalizeText(haystack); + return ( + text.includes('transfer') || + text.includes('تحويل') || + text.includes('حوالة') || + text.includes('bank') || + text.includes('بنك') || + isHaramText(value) || + isHaramText(method?.name) || + isHaramText(method?.label) || + isHaramText(method?.id) || + isHaramText(method?.description) + ); +} + export default function PaymentsPage() { const { t, i18n } = useTranslation(); const [reservations, setReservations] = useState([]); @@ -165,13 +191,12 @@ export default function PaymentsPage() { const selectedMethod = paymentMethods.find( (m) => String(m.id) === String(paymentTypeId) || String(m.name) === String(paymentTypeId), ); + const requiresReceiptUpload = isReceiptRequiredPayment(paymentKey, selectedMethod); - const isHaram = - isHaramText(selectedMethod?.name) || - isHaramText(selectedMethod?.label) || - isHaramText(selectedMethod?.id) || - isHaramText(selectedMethod?.description) || - isHaramText(paymentKey); + if (requiresReceiptUpload && !paymentImageFile) { + toast.error(t('payments.receiptRequired')); + return; + } setPayingId(reservation.id); try { @@ -201,7 +226,7 @@ export default function PaymentsPage() { if (isGuest) { return ( -
{t('payments.receiptUploadRequiredHint')}
+{t('payments.receiptDialogDescription')}
+