$('.btn_reject').click(_ => Swal.fire({ title: localized.rejection, html: `
${localized.rejectionReasonQ}
`, icon: "question", input: "text", inputAttributes: { autocapitalize: "off" }, showCancelButton: true, confirmButtonColor: "#3085d6", cancelButtonColor: "#d33", confirmButtonText: localized.complete, cancelButtonText: localized.back, showLoaderOnConfirm: true, preConfirm: async (reason) => { try { var res = await rejectEnvelope(reason); return res; } catch (error) { Swal.showValidationMessage(` Request failed: ${error} `); } }, allowOutsideClick: () => !Swal.isLoading() }).then((result) => { if (!result.isConfirmed) return; const res = result.value; console.log(res) if (res.ok) { alert('rejected') } else alert('fail') }));