Add question and homework-update email helpers
This commit is contained in:
@@ -190,6 +190,29 @@ export async function sendTestEmail(to: string) {
|
|||||||
}).catch((e) => console.error("[email] sendTestEmail:", e));
|
}).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(`
|
||||||
|
<p ${p}>Привет!</p>
|
||||||
|
<p ${p}>Вам открыт доступ к курсу <strong>«${courseTitle}»</strong> на образовательной платформе <strong>${school}</strong>.</p>
|
||||||
|
<p ${p}>Ваши данные для входа:</p>
|
||||||
|
${quote(`Логин: ${to}\nПароль: ${tempPassword}`)}
|
||||||
|
<p ${p}>После входа рекомендуем сразу сменить пароль в разделе «Профиль».</p>
|
||||||
|
<p ${pLast}>Если пароль не подходит — воспользуйтесь ссылкой «Забыли пароль?» на странице входа.</p>
|
||||||
|
${btn(`${BASE_URL}/login`, "Войти на платформу")}
|
||||||
|
`, school),
|
||||||
|
}).catch((e) => console.error("[email] sendAccessEmail:", e));
|
||||||
|
}
|
||||||
|
|
||||||
export async function sendPasswordResetEmail(to: string, name: string, resetUrl: string) {
|
export async function sendPasswordResetEmail(to: string, name: string, resetUrl: string) {
|
||||||
const school = await getSchoolName();
|
const school = await getSchoolName();
|
||||||
await getResend().emails.send({
|
await getResend().emails.send({
|
||||||
@@ -205,3 +228,66 @@ export async function sendPasswordResetEmail(to: string, name: string, resetUrl:
|
|||||||
`, school),
|
`, school),
|
||||||
}).catch((e) => console.error("[email] sendPasswordResetEmail:", e));
|
}).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(`
|
||||||
|
<p ${p}>Привет, ${recipientName}!</p>
|
||||||
|
<p ${p}>Студент <strong>${studentName}</strong> задал новый вопрос:</p>
|
||||||
|
${quote(questionTitle)}
|
||||||
|
<p ${pLast}>Откройте панель, чтобы ответить:</p>
|
||||||
|
${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(`
|
||||||
|
<p ${p}>Привет, ${studentName}!</p>
|
||||||
|
<p ${p}>Школа ответила на ваш вопрос:</p>
|
||||||
|
${quote(questionTitle)}
|
||||||
|
<p ${pLast}>Откройте тред чтобы прочитать ответ:</p>
|
||||||
|
${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(`
|
||||||
|
<p ${p}>Привет, ${recipientName}!</p>
|
||||||
|
<p ${p}>Студент <strong>${studentName}</strong> обновил работу по уроку <strong>«${lessonTitle}»</strong>.</p>
|
||||||
|
<p ${pLast}>Откройте работу чтобы проверить изменения:</p>
|
||||||
|
${btn(`${BASE_URL}/curator/homework/${submissionId}`, "Открыть работу")}
|
||||||
|
`, school),
|
||||||
|
}).catch((e) => console.error("[email] sendHomeworkUpdatedEmail:", e));
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user