mailing-part 50%

This commit is contained in:
amNobodyyy
2025-01-23 22:42:41 +05:30
parent d96d27154b
commit b39cb67b0f
4 changed files with 154 additions and 193 deletions

View File

@@ -137,3 +137,31 @@ export const updateCourseStatus = async (courseId) => {
});
};
// Send email
export const sendEmail = async (emailData) => {
console.log("Sending email with data:", emailData);
// Validate input
// if (!emailData.to || !emailData.subject || !emailData.message) {
// const errorMessage = "Missing required fields: to, subject, message";
// console.error(errorMessage);
// throw new Error(errorMessage);
// }
try {
const url = `${BASE_URL}/send-email`;
const response = await fetchData(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(emailData), // Pass the email data to the server
});
console.log("Email sent successfully:", response);
return response;
} catch (error) {
console.error("Error sending email:", error.message);
throw error;
}
};