From 7adb33f4854882eb33929d661881250e864f6009 Mon Sep 17 00:00:00 2001 From: Marco Pedone Date: Wed, 25 Mar 2026 17:30:33 +0100 Subject: [PATCH] feat: enhance RichiesteTable with improved status and decorrenza handling - Updated RichiesteTable to display decorrenza with tooltip based on status. - Enhanced status display with badges indicating various states (e.g., Attesa attivazione, Interrotto). - Added Popover for displaying Annunci details in RichiesteTable. - Refactored API to fetch user interests and related announcements. - Introduced Queue component to display email events for users. - Updated translations to include new "Requests" section in admin navigation. - Improved database queries for fetching user interests and announcements. --- .../src/components/servizio/annuncio_card.tsx | 59 ++- .../src/components/servizio/servizio.tsx | 31 +- .../servizio/servizio_annunci_accordions.tsx | 74 +-- .../src/components/tables/richieste-table.tsx | 229 +++++++-- .../infoalloggi/src/components/ui/popover.tsx | 46 +- apps/infoalloggi/src/i18n/en.ts | 1 + apps/infoalloggi/src/i18n/it.ts | 1 + .../user-view/comunicazioni/[userId].tsx | 12 +- .../src/server/api/routers/interests.ts | 46 +- .../controllers/event_queue.controller.ts | 19 + .../server/controllers/servizio.controller.ts | 477 +++++++++--------- .../src/server/services/interests.service.ts | 44 ++ 12 files changed, 659 insertions(+), 380 deletions(-) diff --git a/apps/infoalloggi/src/components/servizio/annuncio_card.tsx b/apps/infoalloggi/src/components/servizio/annuncio_card.tsx index fb7ccbc..1839781 100644 --- a/apps/infoalloggi/src/components/servizio/annuncio_card.tsx +++ b/apps/infoalloggi/src/components/servizio/annuncio_card.tsx @@ -15,7 +15,10 @@ import { getStorageUrl } from "~/lib/storage_utils"; import { cn, formatCurrency } from "~/lib/utils"; import { useTranslation } from "~/providers/I18nProvider"; import { useServizio, useServizioAnnuncio } from "~/providers/ServizioProvider"; +import type { AnnunciId } from "~/schemas/public/Annunci"; +import type { ServizioServizioId } from "~/schemas/public/Servizio"; import type { AnnuncioRicerca } from "~/server/controllers/annunci.controller"; +import type { ServizioAnnuncioData } from "~/server/controllers/servizio.controller"; import { api } from "~/utils/api"; import { Button } from "../ui/button"; import { @@ -30,15 +33,9 @@ export const AnnuncioCard = ({ className }: { className?: string }) => { const { data } = useServizioAnnuncio(); return ( - @@ -60,20 +57,22 @@ export const AnnuncioCard = ({ className }: { className?: string }) => { ) } + isAdmin={isAdmin} /> ); }; -export const BasicAnnuncioCard = ({ +export const AnnuncioCardContent = ({ interactions, className, data, + isAdmin, }: { interactions?: React.ReactNode; className?: string; - data: AnnuncioRicerca; + data: ServizioAnnuncioData; + isAdmin: boolean; }) => { - const { isAdmin } = useServizio(); return ( {interactions} - {isAdmin && } + {isAdmin && ( + + )} ); }; -const AnnuncioNote = () => { - const { servizioId } = useServizio(); - const { data } = useServizioAnnuncio(); - - const [newNote, setNewNote] = useState(data.note || ""); +const AnnuncioNote = ({ + servizioId, + annuncioId, + note, +}: { + servizioId: ServizioServizioId; + annuncioId: AnnunciId; + note: string | null; +}) => { + const [newNote, setNewNote] = useState(note); const utils = api.useUtils(); const { mutate, isPending } = api.servizio.updateServizioAnnunci.useMutation({ onSuccess: async () => { @@ -142,21 +152,22 @@ const AnnuncioNote = () => {