Edit payment with haram
All checks were successful
Build frontend / build (push) Successful in 1m31s
All checks were successful
Build frontend / build (push) Successful in 1m31s
This commit is contained in:
@ -65,6 +65,11 @@ function normalizeText(value) {
|
||||
return String(value ?? '').trim().toLowerCase();
|
||||
}
|
||||
|
||||
function isHaramText(value) {
|
||||
const text = normalizeText(value);
|
||||
return text.includes('haram') || text.includes('هرم');
|
||||
}
|
||||
|
||||
export default function PaymentsPage() {
|
||||
const { t, i18n } = useTranslation();
|
||||
const [reservations, setReservations] = useState([]);
|
||||
@ -161,12 +166,11 @@ export default function PaymentsPage() {
|
||||
(m) => String(m.id) === String(paymentTypeId) || String(m.name) === String(paymentTypeId),
|
||||
);
|
||||
|
||||
const isHaram = normalizeText(selectedMethod?.name).includes('haram');
|
||||
|
||||
if (isHaram && !paymentImageFile) {
|
||||
toast.error(t('payments.uploadReceiptRequired', { defaultValue: 'يرجى رفع صورة الوصل' }));
|
||||
return;
|
||||
}
|
||||
const isHaram =
|
||||
isHaramText(selectedMethod?.name) ||
|
||||
isHaramText(selectedMethod?.label) ||
|
||||
isHaramText(selectedMethod?.id) ||
|
||||
isHaramText(paymentKey);
|
||||
|
||||
setPayingId(reservation.id);
|
||||
try {
|
||||
@ -335,10 +339,10 @@ function PaymentCard({ reservation, payingId, paymentMethods, loadingPaymentMeth
|
||||
});
|
||||
|
||||
const isHaramPayment =
|
||||
normalizeText(selectedPayment).includes('haram') ||
|
||||
normalizeText(selectedMethod?.name).includes('haram') ||
|
||||
normalizeText(selectedMethod?.label).includes('haram') ||
|
||||
normalizeText(selectedMethod?.id).includes('haram');
|
||||
isHaramText(selectedPayment) ||
|
||||
isHaramText(selectedMethod?.name) ||
|
||||
isHaramText(selectedMethod?.label) ||
|
||||
isHaramText(selectedMethod?.id);
|
||||
|
||||
return (
|
||||
<>
|
||||
@ -407,11 +411,11 @@ function PaymentCard({ reservation, payingId, paymentMethods, loadingPaymentMeth
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-3">
|
||||
{loadingPaymentMethods ? (
|
||||
<div className="col-span-full rounded-2xl border border-dashed border-gray-200 bg-gray-50 p-4 text-sm text-gray-600">
|
||||
{t('payments.loadingPaymentMethods', { defaultValue: 'جاري تحميل طرق الدفع...' })}
|
||||
{t('payments.loadingPaymentMethods')}
|
||||
</div>
|
||||
) : methods.length === 0 ? (
|
||||
<div className="col-span-full rounded-2xl border border-dashed border-gray-200 bg-gray-50 p-4 text-sm text-gray-600">
|
||||
{t('payments.noPaymentMethodsAvailable', { defaultValue: 'لا توجد طرق دفع متاحة حالياً.' })}
|
||||
{t('payments.noPaymentMethodsAvailable')}
|
||||
</div>
|
||||
) : (
|
||||
methods.map((method, index) => {
|
||||
@ -443,7 +447,7 @@ function PaymentCard({ reservation, payingId, paymentMethods, loadingPaymentMeth
|
||||
</div>
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className={`text-sm font-bold ${isSelected ? 'text-amber-900' : 'text-gray-800'}`}>
|
||||
{method.name || method.label || t('paymentMethod', { defaultValue: 'طريقة الدفع' })}
|
||||
{method.name || method.label || t('payments.paymentMethodName')}
|
||||
</p>
|
||||
{method.description && (
|
||||
<p className="text-xs text-gray-500 mt-0.5 leading-relaxed">
|
||||
@ -455,7 +459,7 @@ function PaymentCard({ reservation, payingId, paymentMethods, loadingPaymentMeth
|
||||
isActive ? 'bg-amber-100 text-amber-700' : 'bg-gray-200 text-gray-500'
|
||||
}`}
|
||||
>
|
||||
{isActive ? t('active', { defaultValue: 'نشط' }) : t('inactive', { defaultValue: 'غير نشط' })}
|
||||
{isActive ? t('payments.methodActive') : t('payments.methodInactive')}
|
||||
</span>
|
||||
</div>
|
||||
{isSelected && (
|
||||
@ -474,7 +478,7 @@ function PaymentCard({ reservation, payingId, paymentMethods, loadingPaymentMeth
|
||||
{isHaramPayment && (
|
||||
<div className="px-6 py-5 border-b border-gray-100">
|
||||
<label className="block text-sm font-bold text-gray-700 mb-3">
|
||||
{t('payments.uploadReceipt', { defaultValue: 'صورة الوصل' })}
|
||||
{t('payments.uploadReceipt')}
|
||||
</label>
|
||||
<input
|
||||
type="file"
|
||||
|
||||
Reference in New Issue
Block a user