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"
INTERNAL_BASE_URL = "http://web:3000"
#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"
INTERNAL_BASE_URL = "http://web:3000"
#Api key for the mail service

View file

@ -25,8 +25,8 @@ ENV NEXT_TELEMETRY_DISABLED=1
ENV SKIP_REDIS="true"
# Only essential build-time variables
ARG BASE_URL
ENV NEXT_PUBLIC_BASE_URL=$BASE_URL
ARG NEXT_PUBLIC_BASE_URL
ENV NEXT_PUBLIC_BASE_URL=$NEXT_PUBLIC_BASE_URL
ARG 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"
# Essential runtime variables
ARG BASE_URL
ENV NEXT_PUBLIC_BASE_URL=$BASE_URL
ARG NEXT_PUBLIC_BASE_URL
ENV NEXT_PUBLIC_BASE_URL=$NEXT_PUBLIC_BASE_URL
ARG INTERNAL_BASE_URL
ENV INTERNAL_BASE_URL=$INTERNAL_BASE_URL
ARG POSTGRES_USER

View file

@ -6,12 +6,18 @@ export type VerificaEmail_NewMail = {
};
type VerificaEmailProps = {
baseUrl: string;
token: string;
userId: string;
redirect?: string;
};
const VerificaEmail = ({ token, userId, redirect }: VerificaEmailProps) => {
const VerificaEmail = ({
baseUrl,
token,
userId,
redirect,
}: VerificaEmailProps) => {
return (
<Base noreply preview="Verifica la tua email">
<>
@ -27,7 +33,7 @@ const VerificaEmail = ({ token, userId, redirect }: VerificaEmailProps) => {
<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"
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
</Button>

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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