diff --git a/src/sections/Profile/Admin/Form/CertificatesForm/SendCertificate.jsx b/src/sections/Profile/Admin/Form/CertificatesForm/SendCertificate.jsx index 2ed237e2..f1a936e5 100644 --- a/src/sections/Profile/Admin/Form/CertificatesForm/SendCertificate.jsx +++ b/src/sections/Profile/Admin/Form/CertificatesForm/SendCertificate.jsx @@ -248,15 +248,15 @@ const SendCertificate = () => { token: authCtx.token, }); - if (response?.status === 200) { + if (response?.status === 200 || response?.status === 207) { setAlert({ - type: "success", - message: "Certificates sent successfully!", + type: response.status === 200 ? "success" : "warning", + message: response.data?.message || "Certificates processed.", position: "top-right", - duration: 3000, + duration: 4000, }); } else { - throw new Error("Failed to send certificates"); + throw new Error(response?.data?.error || "Failed to send certificates"); } } catch (error) { console.error("Error in handleSendBatchMail:", error); diff --git a/src/sections/Profile/Admin/Form/CertificatesForm/tools/certificateTools.js b/src/sections/Profile/Admin/Form/CertificatesForm/tools/certificateTools.js index 7833f2cf..49614ce7 100644 --- a/src/sections/Profile/Admin/Form/CertificatesForm/tools/certificateTools.js +++ b/src/sections/Profile/Admin/Form/CertificatesForm/tools/certificateTools.js @@ -111,8 +111,10 @@ const generatedAndSendCertificate = async ({ } else { console.error("Error:", response.data); } + return response; } catch (error) { console.error("Failed to generate and send certificates:", error); + return error.response; } };