27 lines
1.1 KiB
JavaScript
27 lines
1.1 KiB
JavaScript
/* Preview the exact rejection reason before submitting the staff decision. */
|
|
(() => {
|
|
const form = document.querySelector('.pay-decision-form');
|
|
if (!form) return;
|
|
form.addEventListener('submit', event => {
|
|
const confirmation = form.elements.namedItem('confirm_rejection');
|
|
confirmation.value = '';
|
|
if (event.submitter?.value !== 'REJECT') return;
|
|
const reason = form.elements.namedItem('reason');
|
|
if (!reason.value.trim()) {
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
reason.setCustomValidity('دلیل رد فیش را برای مشتری بنویسید.');
|
|
reason.reportValidity();
|
|
reason.setCustomValidity('');
|
|
reason.focus();
|
|
return;
|
|
}
|
|
if (!window.confirm('این فیش رد میشود و دلیل زیر با پیامک برای مشتری ارسال خواهد شد:\n\n' + reason.value.trim() + '\n\nرد فیش و ارسال این دلیل را تأیید میکنید؟')) {
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
return;
|
|
}
|
|
confirmation.value = '1';
|
|
});
|
|
})();
|