export const sendMail = async (email: string, subject: string, html: string) => { await fetch(`${process.env.NEXT_PUBLIC_HUB_SERVER_URL}/mail/send`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ to: email, subject, html, }), }); }; export const sendMailByTemplate = async ( email: string, template: | "password-change" | "course-completed" | "email-verification" | "ban-notice" | "timeban-notice", data: unknown, ) => { try { await fetch(`${process.env.NEXT_PUBLIC_HUB_SERVER_URL}/mail/template/${template}`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ to: email, data, }), }); } catch (error) { console.error("Error sending mail:", error); } };