diff --git a/apps/infoalloggi/emails/scheda-contatti.tsx b/apps/infoalloggi/emails/scheda-contatti.tsx
deleted file mode 100644
index e6995d0..0000000
--- a/apps/infoalloggi/emails/scheda-contatti.tsx
+++ /dev/null
@@ -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 (
-
- <>
-
- Dati Contatto Annuncio
-
-
-
-
- I contatti per l'annuncio {codice} sono stati sbloccati con
- successo.
-
-
-
- Scriva un messaggio WhatsApp ({" "}
-
- Clicca per aprire WhatsApp
- {" "}
- ) avvisando di aver ricevuto da Infoalloggi il suo contatto e
- chieda un appuntamento, poi ci aggiorniamo per l'esito.
-
-
- Nominativo: {nominativo}
- Tel: {telefono}
- Indirizzo immobile: {indirizzo}
-
-
- In allegato trova la scheda completa dell'annuncio
-
-
-
-
- Per ulteriori informazioni e chiarimenti non esiti a contattarci
- all'indirizzo{" "}
-
- web@infoalloggi.it
- {" "}
- oppure tramite tel. 0424529869.
-
- Cordiali saluti
-
-
- {" "}
- 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.
-
-
-
- >
-
- );
-};
-
-export default EmailContattiConScheda;
diff --git a/apps/infoalloggi/src/components/servizio/annuncio_actions.tsx b/apps/infoalloggi/src/components/servizio/annuncio_actions.tsx
index c9801f5..4b3c658 100644
--- a/apps/infoalloggi/src/components/servizio/annuncio_actions.tsx
+++ b/apps/infoalloggi/src/components/servizio/annuncio_actions.tsx
@@ -3,7 +3,6 @@ import {
FileText,
FolderKanban,
Info,
- Mail,
PackageCheck,
Pointer,
Printer,
@@ -63,7 +62,6 @@ export const AdminActions = () => {
-
{data.user_confirmed_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 (
-
{
- mutate({
- annuncioId,
- userId,
- });
- }}
- title="Invia email scheda"
- >
-
-
- Invia Scheda
-
-
- );
-};
-
export const UserActions = () => {
const { servizioId } = useServizio();
const { data, annuncioId } = useServizioAnnuncio();
diff --git a/apps/infoalloggi/src/forms/FormContattoAnnuncio.tsx b/apps/infoalloggi/src/forms/FormContattoAnnuncio.tsx
index 32baa4e..0e81542 100644
--- a/apps/infoalloggi/src/forms/FormContattoAnnuncio.tsx
+++ b/apps/infoalloggi/src/forms/FormContattoAnnuncio.tsx
@@ -54,32 +54,33 @@ export const FormContattoAnnucio = ({ codice }: { codice: string }) => {
},
});
- const { mutate } = api.comunicazioni.sendContattoAnnuncioEmail.useMutation({
- onError: (error) => {
- console.error(error);
- toast.error("Errore durante l'invio dell'email", {
- id: "contatto",
- });
- },
- onMutate: () => {
- toast.loading("Invio in corso...", {
- id: "contatto",
- });
- },
- onSuccess: (data) => {
- setHasSent(true);
- form.reset();
- toast.success(
- "Email inviata correttamente, ti contatteremo al più presto",
- {
+ const { mutate } =
+ api.comunicazioni.sendUtenteInteressatoAdAnnuncioEmail.useMutation({
+ onError: (error) => {
+ console.error(error);
+ toast.error("Errore durante l'invio dell'email", {
id: "contatto",
- },
- );
- setValue({
- ...data,
- });
- },
- });
+ });
+ },
+ 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",
+ },
+ );
+ setValue({
+ ...data,
+ });
+ },
+ });
const onSubmit = (data: FromValues) => {
mutate({
...data,
diff --git a/apps/infoalloggi/src/server/api/routers/comunicazioni.ts b/apps/infoalloggi/src/server/api/routers/comunicazioni.ts
index d0e0ece..7f87a1f 100644
--- a/apps/infoalloggi/src/server/api/routers/comunicazioni.ts
+++ b/apps/infoalloggi/src/server/api/routers/comunicazioni.ts
@@ -8,7 +8,7 @@ import {
publicProcedure,
} from "~/server/api/trpc";
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 {
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(
z.object({
codice: z.string(),
@@ -208,7 +144,7 @@ export const comunicazioniRouter = createTRPCRouter({
}),
)
.mutation(async ({ input }) => {
- return await SendContattoAnnuncioEmail({
+ return await UtenteInteressatoAdAnnuncioEmail({
...input,
});
}),
diff --git a/apps/infoalloggi/src/server/controllers/servizio.controller.ts b/apps/infoalloggi/src/server/controllers/servizio.controller.ts
index 87a40ce..34a4fe5 100644
--- a/apps/infoalloggi/src/server/controllers/servizio.controller.ts
+++ b/apps/infoalloggi/src/server/controllers/servizio.controller.ts
@@ -780,39 +780,6 @@ export const SbloccaContatti = async ({
recipient: [numeroProprietario],
}
: 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 (EmailProprietario) {
@@ -1203,7 +1170,7 @@ export const userAccettaConferma = async ({
}
};
-export const SendContattoAnnuncioEmail = async ({
+export const UtenteInteressatoAdAnnuncioEmail = async ({
codice,
nome,
email,
diff --git a/apps/infoalloggi/src/server/services/mailer.ts b/apps/infoalloggi/src/server/services/mailer.ts
index af23443..5a40dd6 100644
--- a/apps/infoalloggi/src/server/services/mailer.ts
+++ b/apps/infoalloggi/src/server/services/mailer.ts
@@ -27,8 +27,6 @@ import RegistrazioneAvvenuta from "emails/registrazione-avvenuta";
import EmailSchedaContatto, {
type SchedaContatto_NewMail,
} 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 ServizioAttivato from "emails/servizio-attivato";
import VerificaEmail, {
@@ -93,7 +91,6 @@ export type MailsTemplates =
| Generic_NewMail
| SchedaContatto_NewMail
| Invito_NewMail
- | ContattiConScheda_NewMail
| ServizioAttivato_NewMail;
export const genMail = async ({ ...mail }: MailsTemplates) => {
@@ -178,12 +175,6 @@ export const genMail = async ({ ...mail }: MailsTemplates) => {
});
title = "Invito al sito";
break;
- case "emailContattiConScheda":
- mailComponent = EmailContattiConScheda({
- ...mail.props,
- });
- title = "Contatti Con Scheda";
- break;
case "servizioAttivato":
mailComponent = ServizioAttivato();
title = "Servizio Attivato";