2025-12-05 17:24:16 +01:00
|
|
|
import * as z from 'zod';
|
|
|
|
|
|
2025-12-02 09:54:38 +01:00
|
|
|
import { defineEmail } from '../send';
|
|
|
|
|
import { getDefaultTemplate } from '../templates';
|
2026-06-22 05:43:48 +01:00
|
|
|
import { ZEmailBranding } from '../core/branding';
|
2026-07-11 22:22:36 +01:00
|
|
|
import { escapeHtml } from '../utils/functions/email-helpers';
|
2025-12-02 09:54:38 +01:00
|
|
|
|
|
|
|
|
export const inviteTeacherEmail = defineEmail({
|
|
|
|
|
id: 'inviteTeacher',
|
2026-07-11 22:22:36 +01:00
|
|
|
subject: 'You have been invited to join an organization on ClassroomIO',
|
2025-12-02 09:54:38 +01:00
|
|
|
schema: z.object({
|
|
|
|
|
email: z.string().email(),
|
|
|
|
|
orgName: z.string().min(1),
|
|
|
|
|
orgSiteName: z.string().min(1),
|
2026-03-09 11:18:22 +01:00
|
|
|
roleName: z.string().min(1),
|
2026-07-11 22:22:36 +01:00
|
|
|
inviterName: z.string().min(1).optional(),
|
2026-03-09 11:18:22 +01:00
|
|
|
expiresAt: z.string().min(1),
|
2026-06-22 05:43:48 +01:00
|
|
|
inviteLink: z.url(),
|
|
|
|
|
branding: ZEmailBranding
|
2025-12-02 09:54:38 +01:00
|
|
|
}),
|
|
|
|
|
render: (fields) => {
|
2026-07-11 22:22:36 +01:00
|
|
|
const orgName = escapeHtml(fields.orgName);
|
|
|
|
|
const roleName = escapeHtml(fields.roleName);
|
|
|
|
|
const inviterName = fields.inviterName ? escapeHtml(fields.inviterName) : undefined;
|
|
|
|
|
const inviteLink = escapeHtml(fields.inviteLink);
|
|
|
|
|
const expiresAt = escapeHtml(fields.expiresAt);
|
|
|
|
|
|
|
|
|
|
const invitationLine = inviterName
|
|
|
|
|
? `<p><strong>${inviterName}</strong> invited you to join <strong>${orgName}</strong> on ClassroomIO as ${roleName}.</p>`
|
|
|
|
|
: `<p>You have been invited to join <strong>${orgName}</strong> on ClassroomIO as ${roleName}.</p>`;
|
|
|
|
|
|
2025-12-02 09:54:38 +01:00
|
|
|
const content = `
|
2026-07-11 22:22:36 +01:00
|
|
|
<p>Hi there,</p>
|
|
|
|
|
${invitationLine}
|
|
|
|
|
<p>This invite expires on ${expiresAt} (UTC).</p>
|
2025-12-02 09:54:38 +01:00
|
|
|
<div>
|
2026-07-11 22:22:36 +01:00
|
|
|
<a class="button" href="${inviteLink}">Accept Invitation</a>
|
2025-12-02 09:54:38 +01:00
|
|
|
</div>
|
|
|
|
|
`;
|
|
|
|
|
|
2026-06-22 05:43:48 +01:00
|
|
|
return getDefaultTemplate(content, fields.branding);
|
2025-12-02 09:54:38 +01:00
|
|
|
}
|
|
|
|
|
});
|