fix: update environment variable handling and add baseUrl prop to email components for improved functionality

This commit is contained in:
Marco Pedone 2025-10-20 12:33:49 +02:00
parent 42249a75e2
commit 07767dd51b
14 changed files with 54 additions and 23 deletions

View file

@ -1,4 +1,4 @@
BASE_URL="https://www.infoalloggi.it" #BASE_URL="https://www.infoalloggi.it"
NEXT_PUBLIC_BASE_URL = "https://info.marcopedone.it" NEXT_PUBLIC_BASE_URL = "https://info.marcopedone.it"
INTERNAL_BASE_URL = "http://web:3000" INTERNAL_BASE_URL = "http://web:3000"
#Api key for the mail service #Api key for the mail service

View file

@ -1,4 +1,4 @@
BASE_URL="https://info.marcopedone.it" #BASE_URL="https://info.marcopedone.it"
NEXT_PUBLIC_BASE_URL = "https://info.marcopedone.it" NEXT_PUBLIC_BASE_URL = "https://info.marcopedone.it"
INTERNAL_BASE_URL = "http://web:3000" INTERNAL_BASE_URL = "http://web:3000"
#Api key for the mail service #Api key for the mail service

View file

@ -25,8 +25,8 @@ ENV NEXT_TELEMETRY_DISABLED=1
ENV SKIP_REDIS="true" ENV SKIP_REDIS="true"
# Only essential build-time variables # Only essential build-time variables
ARG BASE_URL ARG NEXT_PUBLIC_BASE_URL
ENV NEXT_PUBLIC_BASE_URL=$BASE_URL ENV NEXT_PUBLIC_BASE_URL=$NEXT_PUBLIC_BASE_URL
ARG NEXT_PUBLIC_STRIPE_PUBLIC_KEY ARG NEXT_PUBLIC_STRIPE_PUBLIC_KEY
ENV NEXT_PUBLIC_STRIPE_PUBLIC_KEY=$NEXT_PUBLIC_STRIPE_PUBLIC_KEY ENV NEXT_PUBLIC_STRIPE_PUBLIC_KEY=$NEXT_PUBLIC_STRIPE_PUBLIC_KEY
@ -81,8 +81,8 @@ ENV NEXT_TELEMETRY_DISABLED=1
ENV SKIP_REDIS="false" ENV SKIP_REDIS="false"
# Essential runtime variables # Essential runtime variables
ARG BASE_URL ARG NEXT_PUBLIC_BASE_URL
ENV NEXT_PUBLIC_BASE_URL=$BASE_URL ENV NEXT_PUBLIC_BASE_URL=$NEXT_PUBLIC_BASE_URL
ARG INTERNAL_BASE_URL ARG INTERNAL_BASE_URL
ENV INTERNAL_BASE_URL=$INTERNAL_BASE_URL ENV INTERNAL_BASE_URL=$INTERNAL_BASE_URL
ARG POSTGRES_USER ARG POSTGRES_USER

View file

@ -6,12 +6,18 @@ export type VerificaEmail_NewMail = {
}; };
type VerificaEmailProps = { type VerificaEmailProps = {
baseUrl: string;
token: string; token: string;
userId: string; userId: string;
redirect?: string; redirect?: string;
}; };
const VerificaEmail = ({ token, userId, redirect }: VerificaEmailProps) => { const VerificaEmail = ({
baseUrl,
token,
userId,
redirect,
}: VerificaEmailProps) => {
return ( return (
<Base noreply preview="Verifica la tua email"> <Base noreply preview="Verifica la tua email">
<> <>
@ -27,7 +33,7 @@ const VerificaEmail = ({ token, userId, redirect }: VerificaEmailProps) => {
<Button <Button
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" 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"
href={`${process.env.NEXT_PUBLIC_BASE_URL}/auth/verifica-email-action?t=${token}&u=${userId}${redirect ? `&r=${redirect}` : ""}`} href={`${baseUrl}/auth/verifica-email-action?t=${token}&u=${userId}${redirect ? `&r=${redirect}` : ""}`}
> >
Clicca qui per verificare Clicca qui per verificare
</Button> </Button>

View file

@ -12,6 +12,7 @@ type ContattoAnnuncioEmailProps = {
email: string; email: string;
telefono: string; telefono: string;
messaggio: string; messaggio: string;
baseUrl: string;
}; };
const ContattoAnnuncioEmail = ({ const ContattoAnnuncioEmail = ({
nome, nome,
@ -19,6 +20,7 @@ const ContattoAnnuncioEmail = ({
email, email,
telefono, telefono,
messaggio, messaggio,
baseUrl,
}: ContattoAnnuncioEmailProps) => { }: ContattoAnnuncioEmailProps) => {
return ( return (
<Base preview="Contatto Email"> <Base preview="Contatto Email">
@ -40,7 +42,7 @@ const ContattoAnnuncioEmail = ({
<Section className="mb-5"> <Section className="mb-5">
<Button <Button
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" 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"
href={`${process.env.NEXT_PUBLIC_BASE_URL}/annuncio/${codice}`} href={`${baseUrl}/annuncio/${codice}`}
> >
Vai all&apos;annuncio Vai all&apos;annuncio
</Button> </Button>

View file

@ -22,12 +22,14 @@ type OnboardingServizioProps = {
codice: string; codice: string;
prezzo: number; prezzo: number;
}[]; }[];
baseUrl: string;
}; };
const OnboardingServizio = ({ const OnboardingServizio = ({
token, token,
nome, nome,
annunci, annunci,
baseUrl,
}: OnboardingServizioProps) => { }: OnboardingServizioProps) => {
return ( return (
<Base preview="Procedi ora su Infoalloggi.it"> <Base preview="Procedi ora su Infoalloggi.it">
@ -47,7 +49,7 @@ const OnboardingServizio = ({
<Section className="mb-5"> <Section className="mb-5">
<Button <Button
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" 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"
href={`${process.env.NEXT_PUBLIC_BASE_URL}/servizio/pre-onboard/${token}`} href={`${baseUrl}/servizio/pre-onboard/${token}`}
> >
Vai al servizio Vai al servizio
</Button> </Button>
@ -64,7 +66,7 @@ const OnboardingServizio = ({
alt={`Annuncio image - ${annuncio.codice}`} alt={`Annuncio image - ${annuncio.codice}`}
className="block w-[240px] rounded-[4px] object-cover object-center" className="block w-[240px] rounded-[4px] object-cover object-center"
height="140px" height="140px"
src={`${process.env.NEXT_PUBLIC_BASE_URL}/go-api/images/get/${annuncio.immagine}`} src={`${baseUrl}/go-api/images/get/${annuncio.immagine}`}
width="100%" width="100%"
/> />
</Row> </Row>
@ -84,7 +86,7 @@ const OnboardingServizio = ({
</Text> </Text>
<Link <Link
className="block font-semibold text-[14px] text-indigo-600 no-underline" className="block font-semibold text-[14px] text-indigo-600 no-underline"
href={`${process.env.NEXT_PUBLIC_BASE_URL}/annuncio/${annuncio.codice}`} href={`${baseUrl}/annuncio/${annuncio.codice}`}
> >
Scheda dell&apos;annuncio Scheda dell&apos;annuncio
</Link> </Link>

View file

@ -2,9 +2,13 @@ import { Button, Heading, Row, Section, Text } from "@react-email/components";
import Base from "./base"; import Base from "./base";
export type PagamentoErrore_NewMail = { export type PagamentoErrore_NewMail = {
mailType: "pagamentoErrore"; mailType: "pagamentoErrore";
props: PagamentoErroreProps;
}; };
const PagamentoErrore = () => { type PagamentoErroreProps = {
baseUrl: string;
};
const PagamentoErrore = ({ baseUrl }: PagamentoErroreProps) => {
return ( return (
<Base preview="Errore Pagamento"> <Base preview="Errore Pagamento">
<> <>
@ -22,7 +26,7 @@ const PagamentoErrore = () => {
<Section className="mb-5"> <Section className="mb-5">
<Button <Button
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" 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"
href={`${process.env.NEXT_PUBLIC_BASE_URL}/area-riservata/dashboard`} href={`${baseUrl}/area-riservata/dashboard`}
> >
Vai al tuo account Vai al tuo account
</Button> </Button>

View file

@ -2,9 +2,13 @@ import { Button, Heading, Row, Section, Text } from "@react-email/components";
import Base from "./base"; import Base from "./base";
export type PagamentoRicezione_NewMail = { export type PagamentoRicezione_NewMail = {
mailType: "pagamentoRicezione"; mailType: "pagamentoRicezione";
props: PagamentoRicezioneProps;
}; };
const PagamentoRicezione = () => { type PagamentoRicezioneProps = {
baseUrl: string;
};
const PagamentoRicezione = ({ baseUrl }: PagamentoRicezioneProps) => {
return ( return (
<Base preview="Ricezione Pagamento"> <Base preview="Ricezione Pagamento">
<> <>
@ -22,7 +26,7 @@ const PagamentoRicezione = () => {
<Section className="mb-5"> <Section className="mb-5">
<Button <Button
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" 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"
href={`${process.env.NEXT_PUBLIC_BASE_URL}/area-riservata/dashboard`} href={`${baseUrl}/area-riservata/dashboard`}
> >
Vai al tuo account Vai al tuo account
</Button> </Button>

View file

@ -2,9 +2,13 @@ import { Button, Heading, Row, Section, Text } from "@react-email/components";
import Base from "./base"; import Base from "./base";
export type RegistrazioneAvvenuta_NewMail = { export type RegistrazioneAvvenuta_NewMail = {
mailType: "registrazioneAvvenuta"; mailType: "registrazioneAvvenuta";
props: RegistrazioneAvvenutaProps;
};
type RegistrazioneAvvenutaProps = {
baseUrl: string;
}; };
const RegistrazioneAvvenuta = () => { const RegistrazioneAvvenuta = ({ baseUrl }: RegistrazioneAvvenutaProps) => {
return ( return (
<Base preview="Registrazione Avvenuta"> <Base preview="Registrazione Avvenuta">
<> <>
@ -21,7 +25,7 @@ const RegistrazioneAvvenuta = () => {
<Section className="mb-5"> <Section className="mb-5">
<Button <Button
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" 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"
href={`${process.env.NEXT_PUBLIC_BASE_URL}/area-riservata/dashboard`} href={`${baseUrl}/area-riservata/dashboard`}
> >
Vai al tuo account Vai al tuo account
</Button> </Button>

View file

@ -168,7 +168,7 @@ export const TabServizio = ({
<Button <Button
aria-label="Invia Email Servizio" aria-label="Invia Email Servizio"
className="flex w-full justify-start gap-3 px-2 font-normal" className="flex w-full justify-start gap-3 px-2 font-normal"
disabled={onboardDone} //disabled={onboardDone}
size="sm" size="sm"
variant="ghost" variant="ghost"
> >

View file

@ -1169,6 +1169,7 @@ export const sendServizioEmail = async ({
})), })),
nome, nome,
token: servizioId, token: servizioId,
baseUrl: env.NEXT_PUBLIC_BASE_URL,
}, },
subject: "Procedi ora su Infoalloggi.it", subject: "Procedi ora su Infoalloggi.it",
to: email, to: email,
@ -1447,6 +1448,7 @@ export const SendContactEmail = async ({
messaggio, messaggio,
nome, nome,
telefono, telefono,
baseUrl: env.NEXT_PUBLIC_BASE_URL,
}, },
subject: "Contatto per annuncio", subject: "Contatto per annuncio",
to: "web@infoalloggi.it", to: "web@infoalloggi.it",

View file

@ -250,6 +250,9 @@ export const whIntentFailedHandler = async ({
subject: "Pagamento Fallito", subject: "Pagamento Fallito",
to: utente.email, to: utente.email,
userId: utente.id, userId: utente.id,
props: {
baseUrl: env.NEXT_PUBLIC_BASE_URL,
},
}); });
} }
return true; return true;

View file

@ -137,12 +137,14 @@ export const genMail = async ({ ...mail }: MailsTemplates) => {
break; break;
case "pagamentoErrore": case "pagamentoErrore":
mailComponent = PagamentoErrore(); mailComponent = PagamentoErrore({
...mail.props,
});
title = "Errore pagamento"; title = "Errore pagamento";
break; break;
case "pagamentoRicezione": case "pagamentoRicezione":
mailComponent = PagamentoRicezione(); mailComponent = PagamentoRicezione({ ...mail.props });
title = "Ricezione pagamento"; title = "Ricezione pagamento";
break; break;
@ -159,7 +161,9 @@ export const genMail = async ({ ...mail }: MailsTemplates) => {
break; break;
case "registrazioneAvvenuta": case "registrazioneAvvenuta":
mailComponent = RegistrazioneAvvenuta(); mailComponent = RegistrazioneAvvenuta({
...mail.props,
});
title = "Registrazione avvenuta"; title = "Registrazione avvenuta";
break; break;

View file

@ -129,7 +129,7 @@ services:
BACKENDSERVER_URL: http://backend:1323 BACKENDSERVER_URL: http://backend:1323
KEYDB_URL: keydb:6379 KEYDB_URL: keydb:6379
TILES_URL: tiles:6379 TILES_URL: tiles:6379
BASE_URL: ${BASE_URL} #BASE_URL: ${BASE_URL}
SENDGRID_API_KEY: ${SENDGRID_API_KEY} SENDGRID_API_KEY: ${SENDGRID_API_KEY}
STRIPE_SECRET_KEY: ${STRIPE_SECRET_KEY} STRIPE_SECRET_KEY: ${STRIPE_SECRET_KEY}
NEXT_PUBLIC_STRIPE_PUBLIC_KEY: ${NEXT_PUBLIC_STRIPE_PUBLIC_KEY} NEXT_PUBLIC_STRIPE_PUBLIC_KEY: ${NEXT_PUBLIC_STRIPE_PUBLIC_KEY}