refactor: update company registration flow and email handling; switch to zod for validation

This commit is contained in:
Danel Kungla
2025-06-17 13:45:46 +03:00
parent fe44030190
commit 291919c2d1
18 changed files with 274 additions and 87 deletions
+42
View File
@@ -0,0 +1,42 @@
'use server';
import { getMailer } from '@kit/mailers';
import { enhanceAction } from '@kit/next/actions';
import { CompanySubmitData } from '../types/company';
import { emailSchema } from '../validations/email.schema';
export const sendCompanyOfferEmail = async (
data: CompanySubmitData,
language: string,
) => {
const { renderCompanyOfferEmail } = await import('@kit/email-templates');
const { html, subject, to } = await renderCompanyOfferEmail({
language,
companyData: data,
});
await sendEmail({
subject,
html,
to,
});
};
export const sendEmail = enhanceAction(
async ({ subject, html, to }) => {
const mailer = await getMailer();
await mailer.sendEmail({
to,
subject,
html,
});
return {};
},
{
schema: emailSchema,
auth: false,
},
);