From d18aee8a956743ce388474675cad236fcbd44968 Mon Sep 17 00:00:00 2001 From: Marco Pedone Date: Thu, 12 Mar 2026 17:02:35 +0100 Subject: [PATCH] feat: update admin actions layout and add contact details dialog; modify user link path in UsersTable --- .../components/servizio/annuncio_actions.tsx | 201 ++++++++++++------ .../src/components/servizio/annuncio_card.tsx | 80 +------ .../src/components/tables/users-table.tsx | 2 +- 3 files changed, 139 insertions(+), 144 deletions(-) diff --git a/apps/infoalloggi/src/components/servizio/annuncio_actions.tsx b/apps/infoalloggi/src/components/servizio/annuncio_actions.tsx index ac3804d..b947e73 100644 --- a/apps/infoalloggi/src/components/servizio/annuncio_actions.tsx +++ b/apps/infoalloggi/src/components/servizio/annuncio_actions.tsx @@ -1,17 +1,27 @@ import { - ExternalLink, - Eye, FileBadge, FileText, FolderKanban, + Info, Mail, PackageCheck, Pointer, Printer, Trash2, + Wrench, } from "lucide-react"; import Link from "next/link"; import toast from "react-hot-toast"; +import { + AlertDialog, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, + AlertDialogTrigger, +} from "~/components/ui/alert-dialog"; import { Button, type ButtonConfigs } from "~/components/ui/button"; import { Tooltip, @@ -49,75 +59,79 @@ export const AdminActions = () => { if (!isAdmin) return null; return ( -
- {} - {data.user_confirmed_at != null && } - {data.accettato_conferma_at != null && ( - <> - - {data.gestionale_id && ( - - - - )} - - )} - + <> +

Azioni Admin:

+
+ + + {data.user_confirmed_at != null && } + {data.accettato_conferma_at != null && ( + <> + + {data.gestionale_id && ( + + + + )} + + )} + {/* - - - - + + - - - - - { - mutate({ - annuncioId, - servizioId, - }); - }} - title="Elimina annuncio" - > - - -
+ + + + { + mutate({ + annuncioId, + servizioId, + }); + }} + title="Elimina annuncio" + > + + +
+ ); }; @@ -156,7 +170,7 @@ const AdminSendScheda = () => { > ); @@ -243,6 +257,61 @@ export const UserActions = () => { ); }; +const AdminAnnuncioContatti = () => { + const { data } = useServizioAnnuncio(); + const { data: annuncio, isLoading } = api.annunci.getAnnuncioFull.useQuery({ + id: data.id, + }); + return ( + + + + + + + Contatti Annuncio {data.codice} + + desc + + +
+
+ Contatti Aperti il: + {data.open_contatti_at + ? new Date(data.open_contatti_at).toLocaleString("it-IT") + : "Non ancora aperti"} +
+ {isLoading ? ( +
+ Loading... +
+ ) : ( + <> +
+ Locatore/Incaricato: + {annuncio?.locatore || "N/A"} +
+
+ Email: + {annuncio?.email || "N/A"} +
+
+ Telefono: + {annuncio?.numero || "N/A"} +
+ + )} +
+ + Chiudi + +
+
+ ); +}; const PostConfermaSection = () => { const { servizio, servizioId } = useServizio(); diff --git a/apps/infoalloggi/src/components/servizio/annuncio_card.tsx b/apps/infoalloggi/src/components/servizio/annuncio_card.tsx index 1d5b4ca..c7781c7 100644 --- a/apps/infoalloggi/src/components/servizio/annuncio_card.tsx +++ b/apps/infoalloggi/src/components/servizio/annuncio_card.tsx @@ -1,19 +1,9 @@ -import { Info, Toolbox } from "lucide-react"; +import { Toolbox } from "lucide-react"; import Image from "next/image"; import { AdminActions, UserActions, } from "~/components/servizio/annuncio_actions"; -import { - AlertDialog, - AlertDialogCancel, - AlertDialogContent, - AlertDialogDescription, - AlertDialogFooter, - AlertDialogHeader, - AlertDialogTitle, - AlertDialogTrigger, -} from "~/components/ui/alert-dialog"; import { Card, CardContent, CardHeader, CardTitle } from "~/components/ui/card"; import { handleConsegna } from "~/lib/annuncio_details"; import { getStorageUrl } from "~/lib/storage_utils"; @@ -21,7 +11,6 @@ import { cn, formatCurrency } from "~/lib/utils"; import { useTranslation } from "~/providers/I18nProvider"; import { useServizio, useServizioAnnuncio } from "~/providers/ServizioProvider"; import type { AnnuncioRicerca } from "~/server/controllers/annunci.controller"; -import { api } from "~/utils/api"; import { Button } from "../ui/button"; import { Collapsible, @@ -49,7 +38,7 @@ export const AnnuncioCard = ({ className }: { className?: string }) => {
- @@ -108,7 +97,6 @@ export const AnnuncioDisplay = ({ data: AnnuncioRicerca; className?: string; }) => { - const { isAdmin } = useServizio(); const { t } = useTranslation(); return ( @@ -158,71 +146,9 @@ export const AnnuncioDisplay = ({ {formatCurrency(data.prezzo / 1e2)}
-
+
- {isAdmin && }
); }; - -const AdminAnnuncioContatti = () => { - const { data } = useServizioAnnuncio(); - const { data: annuncio, isLoading } = api.annunci.getAnnuncioFull.useQuery({ - id: data.id, - }); - return ( - - - - - - - Contatti Annuncio {data.codice} - - desc - - -
-
- Contatti Aperti il: - {data.open_contatti_at - ? new Date(data.open_contatti_at).toLocaleString("it-IT") - : "Non ancora aperti"} -
- {isLoading ? ( -
- Loading... -
- ) : ( - <> -
- Locatore/Incaricato: - {annuncio?.locatore || "N/A"} -
-
- Email: - {annuncio?.email || "N/A"} -
-
- Telefono: - {annuncio?.numero || "N/A"} -
- - )} -
- - Chiudi - -
-
- ); -}; diff --git a/apps/infoalloggi/src/components/tables/users-table.tsx b/apps/infoalloggi/src/components/tables/users-table.tsx index c80334e..3b07c32 100644 --- a/apps/infoalloggi/src/components/tables/users-table.tsx +++ b/apps/infoalloggi/src/components/tables/users-table.tsx @@ -135,7 +135,7 @@ export const UsersTable = (props: { data: UserWChatInfo[] }) => {