feat: remove unused EmailContattiConScheda component and related email functionality
This commit is contained in:
parent
d4ec0919c3
commit
cc06738db4
6 changed files with 30 additions and 258 deletions
|
|
@ -1,80 +0,0 @@
|
||||||
import { Heading, Row, Section, Text } from "@react-email/components";
|
|
||||||
import Base from "./base";
|
|
||||||
export type ContattiConScheda_NewMail = {
|
|
||||||
mailType: "emailContattiConScheda";
|
|
||||||
props: EmailContattiConSchedaProps;
|
|
||||||
};
|
|
||||||
type EmailContattiConSchedaProps = {
|
|
||||||
nominativo: string;
|
|
||||||
telefono: string;
|
|
||||||
indirizzo: string;
|
|
||||||
codice: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
const EmailContattiConScheda = ({
|
|
||||||
nominativo,
|
|
||||||
telefono,
|
|
||||||
indirizzo,
|
|
||||||
codice,
|
|
||||||
}: EmailContattiConSchedaProps) => {
|
|
||||||
return (
|
|
||||||
<Base noreply={true} preview="Dati Contatto Annuncio - Infoalloggi.it">
|
|
||||||
<>
|
|
||||||
<Heading className="text-center text-3xl leading-8">
|
|
||||||
Dati Contatto Annuncio
|
|
||||||
</Heading>
|
|
||||||
<Section className="px-5 text-left md:px-12">
|
|
||||||
<Row>
|
|
||||||
<Text className="text-base">
|
|
||||||
I contatti per l'annuncio {codice} sono stati sbloccati con
|
|
||||||
successo.
|
|
||||||
</Text>
|
|
||||||
|
|
||||||
<Text className="text-base">
|
|
||||||
Scriva un messaggio WhatsApp ({" "}
|
|
||||||
<a href={`https://wa.me/${telefono}`} rel="noopener noreferrer">
|
|
||||||
Clicca per aprire WhatsApp
|
|
||||||
</a>{" "}
|
|
||||||
) avvisando di aver ricevuto da Infoalloggi il suo contatto e
|
|
||||||
chieda un appuntamento, poi ci aggiorniamo per l'esito.
|
|
||||||
</Text>
|
|
||||||
|
|
||||||
<Text className="text-base">Nominativo: {nominativo}</Text>
|
|
||||||
<Text className="text-base">Tel: {telefono}</Text>
|
|
||||||
<Text className="text-base">Indirizzo immobile: {indirizzo}</Text>
|
|
||||||
|
|
||||||
<Text className="text-base">
|
|
||||||
In allegato trova la scheda completa dell'annuncio
|
|
||||||
</Text>
|
|
||||||
<br />
|
|
||||||
|
|
||||||
<Text className="text-base">
|
|
||||||
Per ulteriori informazioni e chiarimenti non esiti a contattarci
|
|
||||||
all'indirizzo{" "}
|
|
||||||
<a href="mailto:web@infoalloggi.it" rel="noopener noreferrer">
|
|
||||||
web@infoalloggi.it
|
|
||||||
</a>{" "}
|
|
||||||
oppure tramite tel. 0424529869.
|
|
||||||
</Text>
|
|
||||||
<Text className="text-base">Cordiali saluti</Text>
|
|
||||||
<br />
|
|
||||||
<Text className="text-xs">
|
|
||||||
{" "}
|
|
||||||
Le informazioni contenute in questo messaggio di posta elettronica
|
|
||||||
sono riservate confidenziali e ne è vietata la diffusione in
|
|
||||||
qualunque modo eseguita. Qualora Lei non fosse la persona a cui il
|
|
||||||
presente messaggio è destinato, La invitiamo gentilmente ad
|
|
||||||
eliminarlo dopo averne dato tempestiva comunicazione al mittente e
|
|
||||||
a non utilizzare in alcun caso il suo contenuto. Qualsiasi
|
|
||||||
utilizzo non autorizzato di questo messaggio e dei suoi eventuali
|
|
||||||
allegati espone il responsabile alle relative conseguenze civili e
|
|
||||||
penali.
|
|
||||||
</Text>
|
|
||||||
</Row>
|
|
||||||
</Section>
|
|
||||||
</>
|
|
||||||
</Base>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default EmailContattiConScheda;
|
|
||||||
|
|
@ -3,7 +3,6 @@ import {
|
||||||
FileText,
|
FileText,
|
||||||
FolderKanban,
|
FolderKanban,
|
||||||
Info,
|
Info,
|
||||||
Mail,
|
|
||||||
PackageCheck,
|
PackageCheck,
|
||||||
Pointer,
|
Pointer,
|
||||||
Printer,
|
Printer,
|
||||||
|
|
@ -63,7 +62,6 @@ export const AdminActions = () => {
|
||||||
<h3 className="ml-1 font-semibold">Azioni Admin:</h3>
|
<h3 className="ml-1 font-semibold">Azioni Admin:</h3>
|
||||||
<div className="flex w-full max-w-fit flex-wrap justify-start gap-3">
|
<div className="flex w-full max-w-fit flex-wrap justify-start gap-3">
|
||||||
<AdminAnnuncioContatti />
|
<AdminAnnuncioContatti />
|
||||||
<AdminSendScheda />
|
|
||||||
{data.user_confirmed_at != null && <AdminLavoraConferma />}
|
{data.user_confirmed_at != null && <AdminLavoraConferma />}
|
||||||
{data.accettato_conferma_at != null && (
|
{data.accettato_conferma_at != null && (
|
||||||
<>
|
<>
|
||||||
|
|
@ -135,47 +133,6 @@ export const AdminActions = () => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const AdminSendScheda = () => {
|
|
||||||
const { userId } = useServizio();
|
|
||||||
const { annuncioId } = useServizioAnnuncio();
|
|
||||||
|
|
||||||
const { mutate } = api.comunicazioni.sendSchedaAnnuncioServizio.useMutation({
|
|
||||||
onMutate: () => {
|
|
||||||
toast.loading("Invio email in corso...", {
|
|
||||||
id: "send-scheda-annuncio-email",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onSuccess: () => {
|
|
||||||
toast.success("Email inviata con successo!", {
|
|
||||||
id: "send-scheda-annuncio-email",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onError: (error) => {
|
|
||||||
toast.error(`Errore durante l'invio dell'email: ${error.message}`, {
|
|
||||||
id: "send-scheda-annuncio-email",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Confirm
|
|
||||||
description="Sei sicuro di voler inviare l'email con la scheda dell'annuncio?"
|
|
||||||
onConfirm={() => {
|
|
||||||
mutate({
|
|
||||||
annuncioId,
|
|
||||||
userId,
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
title="Invia email scheda"
|
|
||||||
>
|
|
||||||
<Button className="w-fit" size="sm" variant="outline">
|
|
||||||
<Mail />
|
|
||||||
<span>Invia Scheda</span>
|
|
||||||
</Button>
|
|
||||||
</Confirm>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const UserActions = () => {
|
export const UserActions = () => {
|
||||||
const { servizioId } = useServizio();
|
const { servizioId } = useServizio();
|
||||||
const { data, annuncioId } = useServizioAnnuncio();
|
const { data, annuncioId } = useServizioAnnuncio();
|
||||||
|
|
|
||||||
|
|
@ -54,32 +54,33 @@ export const FormContattoAnnucio = ({ codice }: { codice: string }) => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const { mutate } = api.comunicazioni.sendContattoAnnuncioEmail.useMutation({
|
const { mutate } =
|
||||||
onError: (error) => {
|
api.comunicazioni.sendUtenteInteressatoAdAnnuncioEmail.useMutation({
|
||||||
console.error(error);
|
onError: (error) => {
|
||||||
toast.error("Errore durante l'invio dell'email", {
|
console.error(error);
|
||||||
id: "contatto",
|
toast.error("Errore durante l'invio dell'email", {
|
||||||
});
|
|
||||||
},
|
|
||||||
onMutate: () => {
|
|
||||||
toast.loading("Invio in corso...", {
|
|
||||||
id: "contatto",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onSuccess: (data) => {
|
|
||||||
setHasSent(true);
|
|
||||||
form.reset();
|
|
||||||
toast.success(
|
|
||||||
"Email inviata correttamente, ti contatteremo al più presto",
|
|
||||||
{
|
|
||||||
id: "contatto",
|
id: "contatto",
|
||||||
},
|
});
|
||||||
);
|
},
|
||||||
setValue({
|
onMutate: () => {
|
||||||
...data,
|
toast.loading("Invio in corso...", {
|
||||||
});
|
id: "contatto",
|
||||||
},
|
});
|
||||||
});
|
},
|
||||||
|
onSuccess: (data) => {
|
||||||
|
setHasSent(true);
|
||||||
|
form.reset();
|
||||||
|
toast.success(
|
||||||
|
"Email inviata correttamente, ti contatteremo al più presto",
|
||||||
|
{
|
||||||
|
id: "contatto",
|
||||||
|
},
|
||||||
|
);
|
||||||
|
setValue({
|
||||||
|
...data,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
const onSubmit = (data: FromValues) => {
|
const onSubmit = (data: FromValues) => {
|
||||||
mutate({
|
mutate({
|
||||||
...data,
|
...data,
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import {
|
||||||
publicProcedure,
|
publicProcedure,
|
||||||
} from "~/server/api/trpc";
|
} from "~/server/api/trpc";
|
||||||
import { addEventToQueue } from "~/server/controllers/event_queue.controller";
|
import { addEventToQueue } from "~/server/controllers/event_queue.controller";
|
||||||
import { SendContattoAnnuncioEmail } from "~/server/controllers/servizio.controller";
|
import { UtenteInteressatoAdAnnuncioEmail } from "~/server/controllers/servizio.controller";
|
||||||
import { db } from "~/server/db";
|
import { db } from "~/server/db";
|
||||||
import {
|
import {
|
||||||
deleteAllUserEmails,
|
deleteAllUserEmails,
|
||||||
|
|
@ -132,72 +132,8 @@ export const comunicazioniRouter = createTRPCRouter({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
sendSchedaAnnuncioServizio: adminProcedure
|
|
||||||
.input(
|
|
||||||
z.object({
|
|
||||||
userId: zUserId,
|
|
||||||
annuncioId: zAnnuncioId,
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.mutation(async ({ input }) => {
|
|
||||||
try {
|
|
||||||
const scheda = await genPdfSchedaAnnuncioBase64(input.annuncioId);
|
|
||||||
const user = await db
|
|
||||||
.selectFrom("users")
|
|
||||||
.select("email")
|
|
||||||
.where("id", "=", input.userId)
|
|
||||||
.executeTakeFirstOrThrow(() => {
|
|
||||||
throw new Error(`User not found - userId: ${input.userId}`);
|
|
||||||
});
|
|
||||||
const annuncio = await db
|
|
||||||
.selectFrom("annunci")
|
|
||||||
.select([
|
|
||||||
"codice",
|
|
||||||
"locatore",
|
|
||||||
"indirizzo",
|
|
||||||
"civico",
|
|
||||||
"comune",
|
|
||||||
"cap",
|
|
||||||
"provincia",
|
|
||||||
"numero",
|
|
||||||
"tipo_locatore",
|
|
||||||
])
|
|
||||||
.where("id", "=", input.annuncioId)
|
|
||||||
.executeTakeFirstOrThrow(
|
|
||||||
() =>
|
|
||||||
new Error(`Annuncio not found - annuncioId: ${input.annuncioId}`),
|
|
||||||
);
|
|
||||||
await NewMail({
|
|
||||||
template: {
|
|
||||||
mailType: "emailContattiConScheda",
|
|
||||||
props: {
|
|
||||||
codice: annuncio.codice,
|
|
||||||
nominativo: `${annuncio.locatore}${annuncio?.tipo_locatore ? ` (${annuncio.tipo_locatore})` : ""}`,
|
|
||||||
telefono: annuncio.numero || "",
|
|
||||||
indirizzo: `${annuncio.indirizzo || ""}, ${annuncio.civico || ""} ${annuncio.comune || ""} ${annuncio.cap || ""} (${annuncio.provincia || ""})`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
mail: {
|
|
||||||
subject: `Contatti Annuncio ${annuncio.codice} - Infoalloggi.it`,
|
|
||||||
to: user.email,
|
|
||||||
attachments: [
|
|
||||||
{
|
|
||||||
filename: `scheda annuncio ${annuncio.codice}.pdf`,
|
|
||||||
content: scheda,
|
|
||||||
encoding: "base64",
|
|
||||||
contentType: "application/pdf",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
throw new Error(
|
|
||||||
`Errore nell'invio dell'email: ${(e as Error).message}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
|
|
||||||
sendContattoAnnuncioEmail: publicProcedure
|
sendUtenteInteressatoAdAnnuncioEmail: publicProcedure
|
||||||
.input(
|
.input(
|
||||||
z.object({
|
z.object({
|
||||||
codice: z.string(),
|
codice: z.string(),
|
||||||
|
|
@ -208,7 +144,7 @@ export const comunicazioniRouter = createTRPCRouter({
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.mutation(async ({ input }) => {
|
.mutation(async ({ input }) => {
|
||||||
return await SendContattoAnnuncioEmail({
|
return await UtenteInteressatoAdAnnuncioEmail({
|
||||||
...input,
|
...input,
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
|
|
@ -780,39 +780,6 @@ export const SbloccaContatti = async ({
|
||||||
recipient: [numeroProprietario],
|
recipient: [numeroProprietario],
|
||||||
}
|
}
|
||||||
: null;
|
: null;
|
||||||
await addEventToQueue({
|
|
||||||
data: {
|
|
||||||
data: {
|
|
||||||
template: {
|
|
||||||
mailType: "emailContattiConScheda",
|
|
||||||
props: {
|
|
||||||
nominativo: `${data.annuncio.locatore}${data.annuncio?.tipo_locatore ? ` (${data.annuncio.tipo_locatore})` : ""}`,
|
|
||||||
telefono: data.annuncio.numero || "",
|
|
||||||
indirizzo: data.annuncio.indirizzo || "",
|
|
||||||
codice: data.annuncio.codice,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
mail: {
|
|
||||||
subject: `Contatti Annuncio ${data.annuncio.codice} - InfoAlloggi`,
|
|
||||||
to: data.user.email,
|
|
||||||
attachments: [
|
|
||||||
{
|
|
||||||
filename: `scheda annuncio ${data.annuncio.codice}.pdf`,
|
|
||||||
generate: {
|
|
||||||
type: "scheda_annuncio",
|
|
||||||
annuncioId: data.annuncioId,
|
|
||||||
},
|
|
||||||
encoding: "base64",
|
|
||||||
contentType: "application/pdf",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
userId: data.user.id,
|
|
||||||
},
|
|
||||||
tipo: "email",
|
|
||||||
},
|
|
||||||
lock_expires: new Date(Date.now() + 3000),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (canSendNotification()) {
|
if (canSendNotification()) {
|
||||||
if (EmailProprietario) {
|
if (EmailProprietario) {
|
||||||
|
|
@ -1203,7 +1170,7 @@ export const userAccettaConferma = async ({
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const SendContattoAnnuncioEmail = async ({
|
export const UtenteInteressatoAdAnnuncioEmail = async ({
|
||||||
codice,
|
codice,
|
||||||
nome,
|
nome,
|
||||||
email,
|
email,
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,6 @@ import RegistrazioneAvvenuta from "emails/registrazione-avvenuta";
|
||||||
import EmailSchedaContatto, {
|
import EmailSchedaContatto, {
|
||||||
type SchedaContatto_NewMail,
|
type SchedaContatto_NewMail,
|
||||||
} from "emails/scheda-annuncio";
|
} from "emails/scheda-annuncio";
|
||||||
import type { ContattiConScheda_NewMail } from "emails/scheda-contatti";
|
|
||||||
import EmailContattiConScheda from "emails/scheda-contatti";
|
|
||||||
import type { ServizioAttivato_NewMail } from "emails/servizio-attivato";
|
import type { ServizioAttivato_NewMail } from "emails/servizio-attivato";
|
||||||
import ServizioAttivato from "emails/servizio-attivato";
|
import ServizioAttivato from "emails/servizio-attivato";
|
||||||
import VerificaEmail, {
|
import VerificaEmail, {
|
||||||
|
|
@ -93,7 +91,6 @@ export type MailsTemplates =
|
||||||
| Generic_NewMail
|
| Generic_NewMail
|
||||||
| SchedaContatto_NewMail
|
| SchedaContatto_NewMail
|
||||||
| Invito_NewMail
|
| Invito_NewMail
|
||||||
| ContattiConScheda_NewMail
|
|
||||||
| ServizioAttivato_NewMail;
|
| ServizioAttivato_NewMail;
|
||||||
|
|
||||||
export const genMail = async ({ ...mail }: MailsTemplates) => {
|
export const genMail = async ({ ...mail }: MailsTemplates) => {
|
||||||
|
|
@ -178,12 +175,6 @@ export const genMail = async ({ ...mail }: MailsTemplates) => {
|
||||||
});
|
});
|
||||||
title = "Invito al sito";
|
title = "Invito al sito";
|
||||||
break;
|
break;
|
||||||
case "emailContattiConScheda":
|
|
||||||
mailComponent = EmailContattiConScheda({
|
|
||||||
...mail.props,
|
|
||||||
});
|
|
||||||
title = "Contatti Con Scheda";
|
|
||||||
break;
|
|
||||||
case "servizioAttivato":
|
case "servizioAttivato":
|
||||||
mailComponent = ServizioAttivato();
|
mailComponent = ServizioAttivato();
|
||||||
title = "Servizio Attivato";
|
title = "Servizio Attivato";
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue