loader funtion change
This commit is contained in:
parent
2b8bc2a1ca
commit
626b3b502a
|
|
@ -1158,10 +1158,10 @@ function BSReprint({ setOpenModel = () => { } }) {
|
|||
};
|
||||
|
||||
const handleSendEmail = async (value) => {
|
||||
const toEmail = value.email;
|
||||
setLoading(true);
|
||||
try {
|
||||
const toEmail = value.email;
|
||||
if (selectedRows.length === 0) {
|
||||
setLoading(true);
|
||||
const result = await MobilePdfPrint({
|
||||
printerTemplateStyle,
|
||||
printDatas,
|
||||
|
|
@ -1172,16 +1172,25 @@ function BSReprint({ setOpenModel = () => { } }) {
|
|||
});
|
||||
|
||||
if (result?.data?.status === 1) {
|
||||
setEmailModalOpen(false); // ✅ Close modal
|
||||
setEmailId(''); // ✅ Reset email input (optional)
|
||||
setLoading(false);
|
||||
setMessage({ type: 'success', data: result?.data?.response || 'Email sent successfully' });
|
||||
setEmailModalOpen(false);
|
||||
setEmailId('');
|
||||
form.resetFields();
|
||||
} else {
|
||||
setMessage({ type: 'error', data: result?.data?.response || 'Email sending failed' });
|
||||
}
|
||||
} else {
|
||||
mutiplePrint('email',toEmail);
|
||||
await mutiplePrint('email', toEmail);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('❌ Email error:', err);
|
||||
setMessage({ type: 'error', data: err?.message || 'Something went wrong while sending email' });
|
||||
} finally {
|
||||
setLoading(false);
|
||||
if (selectedRows.length === 0) {
|
||||
// for single row, form already reset on success; for failure, still reset to clear bad input
|
||||
form.resetFields();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -1844,10 +1853,10 @@ function BSReprint({ setOpenModel = () => { } }) {
|
|||
/>
|
||||
</Modal> */}
|
||||
|
||||
{(emailModalOpen || isProcessing) && (
|
||||
{(emailModalOpen || loading) && (
|
||||
<EmailModel
|
||||
open={emailModalOpen}
|
||||
emailSending={isProcessing}
|
||||
emailSending={loading}
|
||||
handleCancel={() => setEmailModalOpen(false)}
|
||||
form={form}
|
||||
handleSendEmailWithEnteredEmail={handleSendEmail}
|
||||
|
|
|
|||
Loading…
Reference in New Issue