refactor: replace baseUrl prop with env.BASE_URL in email components
This commit is contained in:
parent
f2ee374e32
commit
b84c98c334
10 changed files with 22 additions and 52 deletions
|
|
@ -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 (
|
||||
<Base noreply preview="Verifica la tua email">
|
||||
<>
|
||||
|
|
@ -33,7 +28,7 @@ const VerificaEmail = ({
|
|||
|
||||
<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={`${baseUrl}/auth/verifica-email-action?t=${token}&u=${userId}${redirect ? `&r=${redirect}` : ""}`}
|
||||
href={`${env.BASE_URL}/auth/verifica-email-action?t=${token}&u=${userId}${redirect ? `&r=${redirect}` : ""}`}
|
||||
>
|
||||
Clicca qui per verificare
|
||||
</Button>
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<Tailwind
|
||||
config={{
|
||||
|
|
@ -52,7 +47,7 @@ const Base = ({
|
|||
className="mx-auto my-2 scale-80"
|
||||
height={44.25}
|
||||
referrerPolicy="no-referrer"
|
||||
src={`${baseUrl}/Infoalloggi.png`}
|
||||
src={`${env.BASE_URL}/Infoalloggi.png`}
|
||||
width={230.5}
|
||||
/>
|
||||
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<Base preview="Contatto Email">
|
||||
|
|
@ -42,7 +41,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={`${baseUrl}/annuncio/${codice}`}
|
||||
href={`${env.BASE_URL}/annuncio/${codice}`}
|
||||
>
|
||||
Vai all'annuncio
|
||||
</Button>
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<Base preview="Procedi ora su Infoalloggi.it">
|
||||
|
|
@ -49,7 +48,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={`${baseUrl}/servizio/pre-onboard/${token}`}
|
||||
href={`${env.BASE_URL}/servizio/pre-onboard/${token}`}
|
||||
>
|
||||
Vai al servizio
|
||||
</Button>
|
||||
|
|
@ -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%"
|
||||
/>
|
||||
</Row>
|
||||
|
|
@ -86,7 +85,7 @@ const OnboardingServizio = ({
|
|||
</Text>
|
||||
<Link
|
||||
className="block font-semibold text-[14px] text-indigo-600 no-underline"
|
||||
href={`${baseUrl}/annuncio/${annuncio.codice}`}
|
||||
href={`${env.BASE_URL}/annuncio/${annuncio.codice}`}
|
||||
>
|
||||
Scheda dell'annuncio →
|
||||
</Link>
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<Base preview="Errore Pagamento">
|
||||
<>
|
||||
|
|
@ -26,7 +23,7 @@ const PagamentoErrore = ({ baseUrl }: PagamentoErroreProps) => {
|
|||
<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={`${baseUrl}/area-riservata/dashboard`}
|
||||
href={`${env.BASE_URL}/area-riservata/dashboard`}
|
||||
>
|
||||
Vai al tuo account
|
||||
</Button>
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<Base preview="Ricezione Pagamento">
|
||||
<>
|
||||
|
|
@ -26,7 +23,7 @@ const PagamentoRicezione = ({ baseUrl }: PagamentoRicezioneProps) => {
|
|||
<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={`${baseUrl}/area-riservata/dashboard`}
|
||||
href={`${env.BASE_URL}/area-riservata/dashboard`}
|
||||
>
|
||||
Vai al tuo account
|
||||
</Button>
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<Base preview="Registrazione Avvenuta">
|
||||
<>
|
||||
|
|
@ -25,7 +22,7 @@ const RegistrazioneAvvenuta = ({ baseUrl }: RegistrazioneAvvenutaProps) => {
|
|||
<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={`${baseUrl}/area-riservata/dashboard`}
|
||||
href={`${env.BASE_URL}/area-riservata/dashboard`}
|
||||
>
|
||||
Vai al tuo account
|
||||
</Button>
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -250,9 +250,6 @@ export const whIntentFailedHandler = async ({
|
|||
subject: "Pagamento Fallito",
|
||||
to: utente.email,
|
||||
userId: utente.id,
|
||||
props: {
|
||||
baseUrl: env.BASE_URL,
|
||||
},
|
||||
});
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue