From b84c98c33406b5601f0eed6eaeb7a8fecdefc5e2 Mon Sep 17 00:00:00 2001 From: Marco Pedone Date: Mon, 20 Oct 2025 17:27:32 +0200 Subject: [PATCH] refactor: replace baseUrl prop with env.BASE_URL in email components --- apps/infoalloggi/emails/VerificaEmail.tsx | 11 +++-------- apps/infoalloggi/emails/base.tsx | 7 +------ apps/infoalloggi/emails/contatto_annuncio.tsx | 5 ++--- apps/infoalloggi/emails/onboarding-servizio.tsx | 9 ++++----- apps/infoalloggi/emails/pagamento-errore.tsx | 9 +++------ apps/infoalloggi/emails/pagamento-ricezione.tsx | 9 +++------ apps/infoalloggi/emails/registrazione-avvenuta.tsx | 9 +++------ .../src/server/controllers/servizio.controller.ts | 2 -- .../src/server/controllers/stripe.controller.ts | 3 --- apps/infoalloggi/src/server/services/mailer.ts | 10 +++------- 10 files changed, 22 insertions(+), 52 deletions(-) diff --git a/apps/infoalloggi/emails/VerificaEmail.tsx b/apps/infoalloggi/emails/VerificaEmail.tsx index 419eba4..5d46b40 100644 --- a/apps/infoalloggi/emails/VerificaEmail.tsx +++ b/apps/infoalloggi/emails/VerificaEmail.tsx @@ -1,4 +1,5 @@ import { Button, Heading, Row, Section, Text } from "@react-email/components"; +import { env } from "~/env"; import Base from "./base"; export type VerificaEmail_NewMail = { mailType: "verificaEmail"; @@ -6,18 +7,12 @@ export type VerificaEmail_NewMail = { }; type VerificaEmailProps = { - baseUrl: string; token: string; userId: string; redirect?: string; }; -const VerificaEmail = ({ - baseUrl, - token, - userId, - redirect, -}: VerificaEmailProps) => { +const VerificaEmail = ({ token, userId, redirect }: VerificaEmailProps) => { return ( <> @@ -33,7 +28,7 @@ const VerificaEmail = ({ diff --git a/apps/infoalloggi/emails/base.tsx b/apps/infoalloggi/emails/base.tsx index 34d0238..e5a0eb9 100644 --- a/apps/infoalloggi/emails/base.tsx +++ b/apps/infoalloggi/emails/base.tsx @@ -22,11 +22,6 @@ const Base = ({ preview: string; noreply?: boolean; }) => { - console.log("BASE_URL:", env.BASE_URL); - console.log("INTERNAL_BASE_URL:", env.INTERNAL_BASE_URL); - console.log("NEXT_PUBLIC_BASE_URL:", env.NEXT_PUBLIC_BASE_URL); - console.log("process.env.BASE_URL:", process.env.BASE_URL); - const baseUrl = process.env.BASE_URL; return ( diff --git a/apps/infoalloggi/emails/contatto_annuncio.tsx b/apps/infoalloggi/emails/contatto_annuncio.tsx index 965b9e7..f7b3b60 100644 --- a/apps/infoalloggi/emails/contatto_annuncio.tsx +++ b/apps/infoalloggi/emails/contatto_annuncio.tsx @@ -1,4 +1,5 @@ import { Button, Heading, Row, Section, Text } from "@react-email/components"; +import { env } from "~/env"; import Base from "./base"; export type ContattoAnnuncio_NewMail = { @@ -12,7 +13,6 @@ type ContattoAnnuncioEmailProps = { email: string; telefono: string; messaggio: string; - baseUrl: string; }; const ContattoAnnuncioEmail = ({ nome, @@ -20,7 +20,6 @@ const ContattoAnnuncioEmail = ({ email, telefono, messaggio, - baseUrl, }: ContattoAnnuncioEmailProps) => { return ( @@ -42,7 +41,7 @@ const ContattoAnnuncioEmail = ({
diff --git a/apps/infoalloggi/emails/onboarding-servizio.tsx b/apps/infoalloggi/emails/onboarding-servizio.tsx index 1aa8ae8..69c643c 100644 --- a/apps/infoalloggi/emails/onboarding-servizio.tsx +++ b/apps/infoalloggi/emails/onboarding-servizio.tsx @@ -7,6 +7,7 @@ import { Section, Text, } from "@react-email/components"; +import { env } from "~/env"; import Base from "./base"; export type OnboardingServizio_NewMail = { mailType: "onboardingServizio"; @@ -22,14 +23,12 @@ type OnboardingServizioProps = { codice: string; prezzo: number; }[]; - baseUrl: string; }; const OnboardingServizio = ({ token, nome, annunci, - baseUrl, }: OnboardingServizioProps) => { return ( @@ -49,7 +48,7 @@ const OnboardingServizio = ({
@@ -66,7 +65,7 @@ const OnboardingServizio = ({ alt={`Annuncio image - ${annuncio.codice}`} className="block w-[240px] rounded-[4px] object-cover object-center" height="140px" - src={`${baseUrl}/go-api/images/get/${annuncio.immagine}`} + src={`${env.BASE_URL}/go-api/images/get/${annuncio.immagine}`} width="100%" /> @@ -86,7 +85,7 @@ const OnboardingServizio = ({ Scheda dell'annuncio → diff --git a/apps/infoalloggi/emails/pagamento-errore.tsx b/apps/infoalloggi/emails/pagamento-errore.tsx index da4771f..825137b 100644 --- a/apps/infoalloggi/emails/pagamento-errore.tsx +++ b/apps/infoalloggi/emails/pagamento-errore.tsx @@ -1,14 +1,11 @@ import { Button, Heading, Row, Section, Text } from "@react-email/components"; +import { env } from "~/env"; import Base from "./base"; export type PagamentoErrore_NewMail = { mailType: "pagamentoErrore"; - props: PagamentoErroreProps; }; -type PagamentoErroreProps = { - baseUrl: string; -}; -const PagamentoErrore = ({ baseUrl }: PagamentoErroreProps) => { +const PagamentoErrore = () => { return ( <> @@ -26,7 +23,7 @@ const PagamentoErrore = ({ baseUrl }: PagamentoErroreProps) => {
diff --git a/apps/infoalloggi/emails/pagamento-ricezione.tsx b/apps/infoalloggi/emails/pagamento-ricezione.tsx index 0976989..280d274 100644 --- a/apps/infoalloggi/emails/pagamento-ricezione.tsx +++ b/apps/infoalloggi/emails/pagamento-ricezione.tsx @@ -1,14 +1,11 @@ import { Button, Heading, Row, Section, Text } from "@react-email/components"; +import { env } from "~/env"; import Base from "./base"; export type PagamentoRicezione_NewMail = { mailType: "pagamentoRicezione"; - props: PagamentoRicezioneProps; }; -type PagamentoRicezioneProps = { - baseUrl: string; -}; -const PagamentoRicezione = ({ baseUrl }: PagamentoRicezioneProps) => { +const PagamentoRicezione = () => { return ( <> @@ -26,7 +23,7 @@ const PagamentoRicezione = ({ baseUrl }: PagamentoRicezioneProps) => {
diff --git a/apps/infoalloggi/emails/registrazione-avvenuta.tsx b/apps/infoalloggi/emails/registrazione-avvenuta.tsx index 27f561a..1e5ffeb 100644 --- a/apps/infoalloggi/emails/registrazione-avvenuta.tsx +++ b/apps/infoalloggi/emails/registrazione-avvenuta.tsx @@ -1,14 +1,11 @@ import { Button, Heading, Row, Section, Text } from "@react-email/components"; +import { env } from "~/env"; import Base from "./base"; export type RegistrazioneAvvenuta_NewMail = { mailType: "registrazioneAvvenuta"; - props: RegistrazioneAvvenutaProps; -}; -type RegistrazioneAvvenutaProps = { - baseUrl: string; }; -const RegistrazioneAvvenuta = ({ baseUrl }: RegistrazioneAvvenutaProps) => { +const RegistrazioneAvvenuta = () => { return ( <> @@ -25,7 +22,7 @@ const RegistrazioneAvvenuta = ({ baseUrl }: RegistrazioneAvvenutaProps) => {
diff --git a/apps/infoalloggi/src/server/controllers/servizio.controller.ts b/apps/infoalloggi/src/server/controllers/servizio.controller.ts index d8f8e63..7b4bded 100644 --- a/apps/infoalloggi/src/server/controllers/servizio.controller.ts +++ b/apps/infoalloggi/src/server/controllers/servizio.controller.ts @@ -1169,7 +1169,6 @@ export const sendServizioEmail = async ({ })), nome, token: servizioId, - baseUrl: env.BASE_URL, }, subject: "Procedi ora su Infoalloggi.it", to: email, @@ -1448,7 +1447,6 @@ export const SendContactEmail = async ({ messaggio, nome, telefono, - baseUrl: env.BASE_URL, }, subject: "Contatto per annuncio", to: "web@infoalloggi.it", diff --git a/apps/infoalloggi/src/server/controllers/stripe.controller.ts b/apps/infoalloggi/src/server/controllers/stripe.controller.ts index 6e994a9..5f3ad67 100644 --- a/apps/infoalloggi/src/server/controllers/stripe.controller.ts +++ b/apps/infoalloggi/src/server/controllers/stripe.controller.ts @@ -250,9 +250,6 @@ export const whIntentFailedHandler = async ({ subject: "Pagamento Fallito", to: utente.email, userId: utente.id, - props: { - baseUrl: env.BASE_URL, - }, }); } return true; diff --git a/apps/infoalloggi/src/server/services/mailer.ts b/apps/infoalloggi/src/server/services/mailer.ts index c03267d..bc21af6 100644 --- a/apps/infoalloggi/src/server/services/mailer.ts +++ b/apps/infoalloggi/src/server/services/mailer.ts @@ -129,14 +129,12 @@ export const genMail = async ({ ...mail }: MailsTemplates) => { break; case "pagamentoErrore": - mailComponent = PagamentoErrore({ - ...mail.props, - }); + mailComponent = PagamentoErrore(); title = "Errore pagamento"; break; case "pagamentoRicezione": - mailComponent = PagamentoRicezione({ ...mail.props }); + mailComponent = PagamentoRicezione(); title = "Ricezione pagamento"; break; @@ -153,9 +151,7 @@ export const genMail = async ({ ...mail }: MailsTemplates) => { break; case "registrazioneAvvenuta": - mailComponent = RegistrazioneAvvenuta({ - ...mail.props, - }); + mailComponent = RegistrazioneAvvenuta(); title = "Registrazione avvenuta"; break;