diff --git a/apps/infoalloggi/emails/base.tsx b/apps/infoalloggi/emails/base.tsx index e5a0eb9..53f7181 100644 --- a/apps/infoalloggi/emails/base.tsx +++ b/apps/infoalloggi/emails/base.tsx @@ -41,7 +41,7 @@ const Base = ({ {preview} - + Infoalloggi.it -
+

-
{children}
+
{children}
{noreply && ( diff --git a/apps/infoalloggi/emails/gereric-email.tsx b/apps/infoalloggi/emails/gereric-email.tsx index 4c6a0f0..6185b13 100644 --- a/apps/infoalloggi/emails/gereric-email.tsx +++ b/apps/infoalloggi/emails/gereric-email.tsx @@ -1,24 +1,33 @@ import { Button, Heading, Row, Section, Text } from "@react-email/components"; +import type { ReactNode } from "react"; import Base from "./base"; export type Generic_NewMail = { mailType: "generic"; props: GenericProps; }; - +type Corpo = { + testo?: undefined; + corpo: ReactNode; +}; +type Testo = { + testo: string; + corpo?: undefined; +}; type GenericProps = { title: string; noreply?: boolean; - testo: string; + link?: { href: string; label?: string; }; -}; +} & (Corpo | Testo); const Generic = ({ title, noreply = false, testo, + corpo, link = undefined, }: GenericProps) => { return ( @@ -26,9 +35,13 @@ const Generic = ({ <> {title}
- - {testo} - + {corpo ? ( + corpo + ) : ( + + {testo} + + )} {link && (
- +
+ + + + + + + + setInputEmail(e.target.value)} + onKeyDown={(e) => { + if ( + e.key === "Enter" && + z.safeParse(z.email(), inputEmail).success + ) { + sendEmail(); + } + }} + type="email" + /> + + + +
@@ -239,6 +311,7 @@ export function SchedaAnnuncio({ data }: { data: Annunci }) { diff --git a/apps/infoalloggi/src/components/svgs.tsx b/apps/infoalloggi/src/components/svgs.tsx index 74d0ddc..0ec0b7b 100644 --- a/apps/infoalloggi/src/components/svgs.tsx +++ b/apps/infoalloggi/src/components/svgs.tsx @@ -427,6 +427,7 @@ export const LogoSvg = (props: SVGProps) => ( width={258.758} xmlns="http://www.w3.org/2000/svg" {...props} + id="mainLogoSvg" > {"Infolloggi.it "} diff --git a/apps/infoalloggi/src/forms/FormFlags.tsx b/apps/infoalloggi/src/forms/FormFlags.tsx index 37817db..357401f 100644 --- a/apps/infoalloggi/src/forms/FormFlags.tsx +++ b/apps/infoalloggi/src/forms/FormFlags.tsx @@ -15,6 +15,7 @@ export type initialValues = { id: FlagsId; value: string; }; +//TODO salvare flags come boolean type FormProps = { initialValues: initialValues | null; submitMutation: (values: initialValues) => void; diff --git a/apps/infoalloggi/src/server/api/routers/comunicazioni.ts b/apps/infoalloggi/src/server/api/routers/comunicazioni.ts index 2c41e72..6303107 100644 --- a/apps/infoalloggi/src/server/api/routers/comunicazioni.ts +++ b/apps/infoalloggi/src/server/api/routers/comunicazioni.ts @@ -45,6 +45,9 @@ export const comunicazioniRouter = createTRPCRouter({ z.object({ pdf: z.string(), codice: z.string(), + numero: z.string(), + nominativo: z.string(), + indirizzo: z.string(), to: z.email(), }), ) @@ -53,13 +56,14 @@ export const comunicazioniRouter = createTRPCRouter({ const base64Content = input.pdf.includes("base64,") ? input.pdf.split("base64,")[1] : input.pdf; + await NewMail({ template: { - mailType: "generic", + mailType: "emailSchedaContatto", props: { - noreply: true, - testo: `In allegato la scheda annuncio stampabile per l'annuncio con codice ${input.codice}.`, - title: "Scheda Annuncio Stampabile", + nominativo: input.nominativo, + telefono: input.numero, + indirizzo: input.indirizzo, }, }, mail: { @@ -67,7 +71,7 @@ export const comunicazioniRouter = createTRPCRouter({ to: input.to, attachments: [ { - filename: `scheda-annuncio-${input.codice}.pdf`, + filename: `scheda annuncio ${input.codice}.pdf`, content: base64Content, encoding: "base64", contentType: "application/pdf", diff --git a/apps/infoalloggi/src/server/services/mailer.ts b/apps/infoalloggi/src/server/services/mailer.ts index 9dd287b..0ea2da8 100644 --- a/apps/infoalloggi/src/server/services/mailer.ts +++ b/apps/infoalloggi/src/server/services/mailer.ts @@ -25,6 +25,9 @@ import type { Recesso_NewMail } from "emails/recesso"; import Recesso from "emails/recesso"; import type { RegistrazioneAvvenuta_NewMail } from "emails/registrazione-avvenuta"; import RegistrazioneAvvenuta from "emails/registrazione-avvenuta"; +import EmailSchedaContatto, { + type SchedaContatto_NewMail, +} from "emails/scheda-annuncio"; import VerificaEmail, { type VerificaEmail_NewMail, } from "emails/VerificaEmail"; @@ -85,7 +88,8 @@ export type MailsTemplates = | RegistrazioneAvvenuta_NewMail | VerificaEmail_NewMail | OnboardingServizio_NewMail - | Generic_NewMail; + | Generic_NewMail + | SchedaContatto_NewMail; export const genMail = async ({ ...mail }: MailsTemplates) => { let mailComponent: JSX.Element | null = null; @@ -165,6 +169,12 @@ export const genMail = async ({ ...mail }: MailsTemplates) => { }); title = mail.props.title || "Email Generica"; break; + case "emailSchedaContatto": + mailComponent = EmailSchedaContatto({ + ...mail.props, + }); + title = "Scheda Contatto Annuncio"; + break; } if (mailComponent === null) { throw new TRPCError({