- Updated package.json to include html2canvas-pro and jsPDF for PDF generation. - Enhanced SchedaAnnuncioStampabile component to generate a PDF from HTML and send it via email. - Implemented new API endpoint for sending the generated PDF as an email attachment. - Refactored existing email sending logic across various controllers to use a unified template structure. - Improved error handling and logging for email sending processes.
42 lines
997 B
TypeScript
42 lines
997 B
TypeScript
import { z } from "zod/v4";
|
|
import { createTRPCRouter, publicProcedure } from "~/server/api/trpc";
|
|
import { NewMail } from "~/server/services/mailer";
|
|
// Create a new ratelimiter, that allows 10 requests per 10 seconds
|
|
/*
|
|
const ratelimit = new RateLimiterHandler({
|
|
windowSize: 10,
|
|
maxRequests: 10,
|
|
analytics: true,
|
|
});
|
|
*/
|
|
export const contactRouter = createTRPCRouter({
|
|
postContact: publicProcedure
|
|
.input(
|
|
z.object({
|
|
cognome: z.string(),
|
|
email: z.email(),
|
|
messaggio: z.string(),
|
|
nome: z.string(),
|
|
telefono: z.string(),
|
|
}),
|
|
)
|
|
.mutation(async ({ input }) => {
|
|
await NewMail({
|
|
template: {
|
|
mailType: "contattoAdminEmail",
|
|
props: {
|
|
cognome: input.cognome,
|
|
email: input.email,
|
|
messaggio: input.messaggio,
|
|
nome: input.nome,
|
|
telefono: input.telefono,
|
|
},
|
|
},
|
|
mail: {
|
|
subject: `Richiesta di contatto da ${input.nome}`,
|
|
to: "web@infoalloggi.it",
|
|
},
|
|
});
|
|
return { success: true };
|
|
}),
|
|
});
|