mailing-part 50%
This commit is contained in:
@@ -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;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user