committed by
GitHub
parent
59dfc0ad91
commit
c185bcfa11
57
apps/dev-tool/app/emails/lib/email-loader.tsx
Normal file
57
apps/dev-tool/app/emails/lib/email-loader.tsx
Normal file
@@ -0,0 +1,57 @@
|
||||
import {
|
||||
renderAccountDeleteEmail,
|
||||
renderInviteEmail,
|
||||
} from '@kit/email-templates';
|
||||
|
||||
export async function loadEmailTemplate(id: string) {
|
||||
if (id === 'account-delete-email') {
|
||||
return renderAccountDeleteEmail({
|
||||
productName: 'Makerkit',
|
||||
userDisplayName: 'Giancarlo',
|
||||
});
|
||||
}
|
||||
|
||||
if (id === 'invite-email') {
|
||||
return renderInviteEmail({
|
||||
teamName: 'Makerkit',
|
||||
teamLogo:
|
||||
'',
|
||||
inviter: 'Giancarlo',
|
||||
invitedUserEmail: 'test@makerkit.dev',
|
||||
link: 'https://makerkit.dev',
|
||||
productName: 'Makerkit',
|
||||
});
|
||||
}
|
||||
|
||||
if (id === 'magic-link-email') {
|
||||
return loadFromFileSystem('magic-link');
|
||||
}
|
||||
|
||||
if (id === 'reset-password-email') {
|
||||
return loadFromFileSystem('reset-password');
|
||||
}
|
||||
|
||||
if (id === 'change-email-address-email') {
|
||||
return loadFromFileSystem('change-email-address');
|
||||
}
|
||||
|
||||
if (id === 'confirm-email') {
|
||||
return loadFromFileSystem('confirm-email');
|
||||
}
|
||||
|
||||
throw new Error(`Email template not found: ${id}`);
|
||||
}
|
||||
|
||||
async function loadFromFileSystem(fileName: string) {
|
||||
const { readFileSync } = await import('node:fs');
|
||||
const { join } = await import('node:path');
|
||||
|
||||
const filePath = join(
|
||||
process.cwd(),
|
||||
`../web/supabase/templates/${fileName}.html`,
|
||||
);
|
||||
|
||||
return {
|
||||
html: readFileSync(filePath, 'utf8'),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user