2025-11-20 11:59:24 +01:00
|
|
|
import type { ReactNode } from "react";
|
2026-05-20 10:14:07 +02:00
|
|
|
import { Button, Heading, Row, Section, Text } from "react-email";
|
2026-04-03 11:51:55 +02:00
|
|
|
import z from "zod";
|
2025-08-04 17:45:44 +02:00
|
|
|
import Base from "./base";
|
2025-11-20 11:59:24 +01:00
|
|
|
|
2026-04-03 11:51:55 +02:00
|
|
|
export const GenericMailTag = "generic";
|
|
|
|
|
|
2026-05-08 16:18:36 +02:00
|
|
|
export const GenericPropsSchema = z.object({
|
2026-05-20 10:14:07 +02:00
|
|
|
title: z
|
|
|
|
|
.string({ error: "Il campo non può essere vuoto" })
|
|
|
|
|
.nonempty("Il campo non può essere vuoto"),
|
2026-04-03 11:51:55 +02:00
|
|
|
noreply: z.boolean().optional(),
|
|
|
|
|
link: z
|
|
|
|
|
.object({
|
|
|
|
|
href: z.string(),
|
|
|
|
|
label: z.string().optional(),
|
|
|
|
|
})
|
|
|
|
|
.optional(),
|
2026-05-08 16:18:36 +02:00
|
|
|
corpo: z.custom<ReactNode>().optional(),
|
2026-05-20 10:14:07 +02:00
|
|
|
testo: z
|
|
|
|
|
.string({ error: "Il campo non può essere vuoto" })
|
|
|
|
|
.nonempty("Il campo non può essere vuoto"),
|
2026-04-03 11:51:55 +02:00
|
|
|
});
|
|
|
|
|
|
2025-08-04 17:45:44 +02:00
|
|
|
const Generic = ({
|
2025-08-29 16:18:32 +02:00
|
|
|
title,
|
|
|
|
|
noreply = false,
|
|
|
|
|
testo,
|
2025-11-20 11:59:24 +01:00
|
|
|
corpo,
|
2025-08-29 16:18:32 +02:00
|
|
|
link = undefined,
|
2026-04-03 11:51:55 +02:00
|
|
|
}: z.infer<typeof GenericPropsSchema>) => {
|
2025-08-29 16:18:32 +02:00
|
|
|
return (
|
|
|
|
|
<Base noreply={noreply} preview={title}>
|
|
|
|
|
<>
|
|
|
|
|
<Heading className="text-center text-3xl leading-8">{title}</Heading>
|
|
|
|
|
<Section className="px-5 text-left text-base md:px-12">
|
2026-05-08 16:18:36 +02:00
|
|
|
{corpo || (
|
2025-11-20 11:59:24 +01:00
|
|
|
<Row>
|
|
|
|
|
<Text>{testo}</Text>
|
|
|
|
|
</Row>
|
|
|
|
|
)}
|
2025-08-29 16:18:32 +02:00
|
|
|
{link && (
|
|
|
|
|
<Section className="mb-5">
|
|
|
|
|
<Button
|
2025-10-10 16:18:43 +02:00
|
|
|
className="mx-auto box-border inline-flex h-10 items-center justify-center whitespace-nowrap rounded-md bg-neutral-100 px-4 py-2 text-center align-middle font-semibold text-neutral-900"
|
2025-08-29 16:18:32 +02:00
|
|
|
href={`${link.href}`}
|
|
|
|
|
>
|
|
|
|
|
{link.label}
|
|
|
|
|
</Button>
|
|
|
|
|
</Section>
|
|
|
|
|
)}
|
|
|
|
|
</Section>
|
|
|
|
|
</>
|
|
|
|
|
</Base>
|
|
|
|
|
);
|
2025-08-04 17:45:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default Generic;
|