diff --git a/src/lib/email.ts b/src/lib/email.ts index 3546458..c31a5a0 100644 --- a/src/lib/email.ts +++ b/src/lib/email.ts @@ -190,6 +190,29 @@ export async function sendTestEmail(to: string) { }).catch((e) => console.error("[email] sendTestEmail:", e)); } +export async function sendAccessEmail( + to: string, + name: string, + courseTitle: string, + tempPassword: string +) { + const school = await getSchoolName(); + await getResend().emails.send({ + from: FROM, + to, + subject: `Доступ к курсу «${courseTitle}» открыт`, + html: base(` +

Привет!

+

Вам открыт доступ к курсу «${courseTitle}» на образовательной платформе ${school}.

+

Ваши данные для входа:

+ ${quote(`Логин: ${to}\nПароль: ${tempPassword}`)} +

После входа рекомендуем сразу сменить пароль в разделе «Профиль».

+

Если пароль не подходит — воспользуйтесь ссылкой «Забыли пароль?» на странице входа.

+ ${btn(`${BASE_URL}/login`, "Войти на платформу")} + `, school), + }).catch((e) => console.error("[email] sendAccessEmail:", e)); +} + export async function sendPasswordResetEmail(to: string, name: string, resetUrl: string) { const school = await getSchoolName(); await getResend().emails.send({ @@ -205,3 +228,66 @@ export async function sendPasswordResetEmail(to: string, name: string, resetUrl: `, school), }).catch((e) => console.error("[email] sendPasswordResetEmail:", e)); } + +export async function sendQuestionCreatedEmail( + to: string, + recipientName: string, + studentName: string, + questionTitle: string, +) { + const school = await getSchoolName(); + await getResend().emails.send({ + from: FROM, + to, + subject: `Новый вопрос от ${studentName}`, + html: base(` +

Привет, ${recipientName}!

+

Студент ${studentName} задал новый вопрос:

+ ${quote(questionTitle)} +

Откройте панель, чтобы ответить:

+ ${btn(`${BASE_URL}/admin/questions`, "Перейти к вопросам")} + `, school), + }).catch((e) => console.error("[email] sendQuestionCreatedEmail:", e)); +} + +export async function sendQuestionReplyEmail( + to: string, + studentName: string, + questionTitle: string, + questionId: string, +) { + const school = await getSchoolName(); + await getResend().emails.send({ + from: FROM, + to, + subject: `Ответ на ваш вопрос`, + html: base(` +

Привет, ${studentName}!

+

Школа ответила на ваш вопрос:

+ ${quote(questionTitle)} +

Откройте тред чтобы прочитать ответ:

+ ${btn(`${BASE_URL}/questions/${questionId}`, "Читать ответ")} + `, school), + }).catch((e) => console.error("[email] sendQuestionReplyEmail:", e)); +} + +export async function sendHomeworkUpdatedEmail( + to: string, + recipientName: string, + studentName: string, + lessonTitle: string, + submissionId: string, +) { + const school = await getSchoolName(); + await getResend().emails.send({ + from: FROM, + to, + subject: `Студент обновил работу — ${lessonTitle}`, + html: base(` +

Привет, ${recipientName}!

+

Студент ${studentName} обновил работу по уроку «${lessonTitle}».

+

Откройте работу чтобы проверить изменения:

+ ${btn(`${BASE_URL}/curator/homework/${submissionId}`, "Открыть работу")} + `, school), + }).catch((e) => console.error("[email] sendHomeworkUpdatedEmail:", e)); +}