From 76bcf640ca883fee6257f9e885c5a05841d58317 Mon Sep 17 00:00:00 2001 From: Marco Pedone Date: Fri, 9 Jan 2026 13:13:17 +0100 Subject: [PATCH] feat: implement AnnuncioDisplay component and integrate it into ServizioContent for better display of selected announcements --- .../src/components/servizio/annuncio_card.tsx | 133 +++++++++--------- .../src/components/servizio/main.tsx | 36 ++++- .../servizio/servizio_annunci_accordions.tsx | 106 +------------- apps/infoalloggi/src/styles/globals.css | 18 +-- 4 files changed, 106 insertions(+), 187 deletions(-) diff --git a/apps/infoalloggi/src/components/servizio/annuncio_card.tsx b/apps/infoalloggi/src/components/servizio/annuncio_card.tsx index 7990ad8..ca19419 100644 --- a/apps/infoalloggi/src/components/servizio/annuncio_card.tsx +++ b/apps/infoalloggi/src/components/servizio/annuncio_card.tsx @@ -35,6 +35,70 @@ export const AnnuncioCard = ({ /> ); }; + +export const AnnuncioDisplay = ({ + data, + confirming, +}: { + data: AnnuncioRicerca; + confirming?: boolean; +}) => { + const { t } = useTranslation(); + + return ( +
+
+ {data.codice} +
+ +
+ {data.titolo_it} +
+ +
+ + + {handleConsegna({ + aggiornamento: t.card.in_aggiornamento, + consegna: data.consegna, + consegna_da: t.card.consegna_da, + mesi: t.parametri.mesi, + subito: t.card.consegna_subito, + })} + + + {formatCurrency(data.prezzo / 1e2)} + +
+
+ +
+
+ ); +}; + export const BasicAnnuncioCard = ({ actions, interactions, @@ -48,8 +112,6 @@ export const BasicAnnuncioCard = ({ data: AnnuncioRicerca; confirming?: boolean; }) => { - const { t } = useTranslation(); - return ( @@ -64,56 +126,7 @@ export const BasicAnnuncioCard = ({ )} id="container" > -
-
- {data.codice} -
- -
- {data.titolo_it} -
- -
- - - {handleConsegna({ - aggiornamento: t.card.in_aggiornamento, - consegna: data.consegna, - consegna_da: t.card.consegna_da, - mesi: t.parametri.mesi, - subito: t.card.consegna_subito, - })} - - - {formatCurrency(data.prezzo / 1e2)} - -
-
- -
-
+
); }; - -export const AnnuncioCardSkeleton = () => { - return ( - - - - - -
-
-
-
- - - ); -}; diff --git a/apps/infoalloggi/src/components/servizio/main.tsx b/apps/infoalloggi/src/components/servizio/main.tsx index a590fd7..1fa651c 100644 --- a/apps/infoalloggi/src/components/servizio/main.tsx +++ b/apps/infoalloggi/src/components/servizio/main.tsx @@ -6,7 +6,7 @@ import { useEffect } from "react"; import toast from "react-hot-toast"; import { AnnuncioCard, - AnnuncioCardSkeleton, + AnnuncioDisplay, } from "~/components/servizio/annuncio_card"; import { SaldoButton } from "~/components/servizio/interactions"; import { ServizioActions } from "~/components/servizio/servizio_actions"; @@ -26,7 +26,6 @@ import { import { api } from "~/utils/api"; import { AlarmClockSVG } from "../svgs"; import { AnnunciCompatibili } from "./compatibili_dialog"; -import { AnnunciSelezionatiDialog } from "./servizio_annunci_accordions"; const ServizioCard = ({ cardClassName, @@ -163,7 +162,34 @@ export const ServizioContent = () => { )}
- {isAdmin && } + {servizio.annunci.length > 0 && ( +
+

+ Sono giĆ  stati selezionati {servizio.annunci.length} annunci + che potrebbero interessarti. +

+
+ {servizio.annunci.map((data) => ( +
+ +
+ ))} + {servizio.annunci.length % 2 === 1 && ( +
+ )} +
+
+ )}
} contentClassName={cn(!isAdmin && "gap-0")} @@ -297,7 +323,9 @@ export const ServizioContent = () => { ); })} - {servizio.annunci.length % 2 === 1 && } + {servizio.annunci.length % 2 === 1 && ( +
+ )}
diff --git a/apps/infoalloggi/src/components/servizio/servizio_annunci_accordions.tsx b/apps/infoalloggi/src/components/servizio/servizio_annunci_accordions.tsx index b9b0a29..5baa60b 100644 --- a/apps/infoalloggi/src/components/servizio/servizio_annunci_accordions.tsx +++ b/apps/infoalloggi/src/components/servizio/servizio_annunci_accordions.tsx @@ -1,11 +1,6 @@ -import { ExternalLink, Trash2 } from "lucide-react"; -import Link from "next/link"; -import type { ReactNode } from "react"; +import { Trash2 } from "lucide-react"; import toast from "react-hot-toast"; -import { - AnnuncioCard, - BasicAnnuncioCard, -} from "~/components/servizio/annuncio_card"; +import { BasicAnnuncioCard } from "~/components/servizio/annuncio_card"; import { Accordion, AccordionContent, @@ -13,105 +8,8 @@ import { AccordionTrigger, } from "~/components/ui/accordion"; import { Button } from "~/components/ui/button"; -import { - ServizioAnnuncioProvider, - useServizio, -} from "~/providers/ServizioProvider"; import type { UsersId } from "~/schemas/public/Users"; -import type { ServizioData } from "~/server/controllers/servizio.controller"; import { api } from "~/utils/api"; -import { - Dialog, - DialogContent, - DialogDescription, - DialogHeader, - DialogTitle, - DialogTrigger, -} from "../ui/dialog"; - -const DialogServizio = ({ - trigger, - title, - children, -}: { - trigger: ReactNode; - title: string; - children: ReactNode; -}) => { - return ( - - {trigger} - - - {title} - - Servizio Dialog - - - {children} - - - ); -}; - -export const AnnunciSelezionatiDialog = ({ - annunci, -}: { - annunci: ServizioData["annunci"]; -}) => { - const { servizioId, userId } = useServizio(); - return ( - - - - - {annunci.length || 0} - -
- } - > -
- {annunci.length > 0 ? ( - annunci.map((data) => { - return ( - - - - ); - }) - ) : ( -
- - Nessun annuncio selezionato, fai una ricerca nella pagina{" "} - - Annunci - - - -
- )} -
- - ); -}; export const AnnunciRichiesti = ({ userId }: { userId: UsersId }) => { const { data, isLoading } = api.intrests.getUserInterestsAnnunci.useQuery({ diff --git a/apps/infoalloggi/src/styles/globals.css b/apps/infoalloggi/src/styles/globals.css index 8f343af..9b6ffe1 100644 --- a/apps/infoalloggi/src/styles/globals.css +++ b/apps/infoalloggi/src/styles/globals.css @@ -14,17 +14,13 @@ @custom-variant search-cancel (&::-webkit-search-cancel-button); -@utility stripes-* { - background-image: linear-gradient(45deg, - --value([color]) 12.5%, - transparent 12.5%, - transparent 50%, - --value([color]) 50%, - --value([color]) 62.5%, - transparent 62.5%, - transparent 100%); - background-size: 10.66px 10.66px; -} +/* +STRIPED BACKGROUND EXAMPLE: +
+*/ @theme inline { --font-sans: var(--font-inter);