diff --git a/apps/infoalloggi/src/components/servizio/annuncio_card.tsx b/apps/infoalloggi/src/components/servizio/annuncio_card.tsx index 1440257..f679a2b 100644 --- a/apps/infoalloggi/src/components/servizio/annuncio_card.tsx +++ b/apps/infoalloggi/src/components/servizio/annuncio_card.tsx @@ -1,53 +1,17 @@ -import { ExternalLink, UnfoldVertical } from "lucide-react"; +import { ExternalLink } from "lucide-react"; import Link from "next/link"; -import { - Credenza, - CredenzaBody, - CredenzaClose, - CredenzaContent, - CredenzaDescription, - CredenzaFooter, - CredenzaHeader, - CredenzaTitle, - CredenzaTrigger, -} from "~/components/custom_ui/credenza"; import { ImageFlbk } from "~/components/ImageWithFallback"; import { AnnuncioActions } from "~/components/servizio/annuncio_actions"; import { Interactions } from "~/components/servizio/interactions"; import { Button } from "~/components/ui/button"; import { Card, CardContent, CardHeader, CardTitle } from "~/components/ui/card"; -import { - Carousel, - CarouselContent, - CarouselItem, - CarouselNext, - CarouselPrevious, -} from "~/components/ui/carousel"; import { handleConsegna } from "~/lib/annuncio_details"; -import { replaceWithBr } from "~/lib/newlineToBr"; import { cn, formatCurrency } from "~/lib/utils"; import { useTranslation } from "~/providers/I18nProvider"; import { useServizioAnnuncio } from "~/providers/ServizioProvider"; -import type { Annunci } from "~/schemas/public/Annunci"; -import { Badge } from "../ui/badge"; +import type { AnnuncioRicerca } from "~/server/controllers/annunci.controller"; +import { AnnuncioDettaglio, TipoBadge } from "./annuncio_dettaglio"; -type AnnuncioData = Pick< - Annunci, - | "id" - | "codice" - | "prezzo" - | "desc_en" - | "desc_it" - | "titolo_en" - | "titolo_it" - | "tipo" - | "consegna" - | "stato" - | "web" - | "media_updated_at" -> & { - images: Pick<{ img: string; thumb: string }, "img">[]; -}; export const AnnuncioCard = ({ className }: { className?: string }) => { const { data } = useServizioAnnuncio(); @@ -57,6 +21,7 @@ export const AnnuncioCard = ({ className }: { className?: string }) => { className={className} data={{ ...data, + modificato_il: data.modificato_il ? new Date(data.modificato_il) : null, media_updated_at: data.media_updated_at ? new Date(data.media_updated_at) : null, @@ -74,7 +39,7 @@ export const BasicAnnuncioCard = ({ actions?: React.ReactNode; interactions?: React.ReactNode; className?: string; - data: AnnuncioData; + data: AnnuncioRicerca; }) => { const { t } = useTranslation(); @@ -136,125 +101,3 @@ export const BasicAnnuncioCard = ({ ); }; - -const TipoBadge = ({ tipo }: { tipo: Annunci["tipo"] }) => { - return ( - - Affitto {tipo} - - ); -}; - -const AnnuncioDettaglio = ({ data }: { data: AnnuncioData }) => { - const { locale, t } = useTranslation(); - - return ( - - - - - - - - Annuncio {data.codice} - - - Annuncio {data.codice} - - - -
- - - {data?.images?.map((img, idx) => ( - - - - ))} - -
e.preventDefault()} - onKeyDown={(e) => e.stopPropagation()} - role="button" - tabIndex={0} - > - - -
-
-
- - -
-
-
-
{t.card.codice}
- -
- Cod: {data.codice} -
-
-
-
{t.card.prezzo}
- -
- {formatCurrency(data.prezzo / 1e2)} -
-
-
- -
-
{t.card.titolo}
- -
- {locale === "it" ? data.titolo_it : data.titolo_en} -
-
- -
-
-
-
-
-
-
- - - - - -
-
- ); -}; diff --git a/apps/infoalloggi/src/components/servizio/annuncio_dettaglio.tsx b/apps/infoalloggi/src/components/servizio/annuncio_dettaglio.tsx new file mode 100644 index 0000000..be47e2d --- /dev/null +++ b/apps/infoalloggi/src/components/servizio/annuncio_dettaglio.tsx @@ -0,0 +1,118 @@ +import { ExternalLink, UnfoldVertical } from "lucide-react"; +import Link from "next/link"; +import { replaceWithBr } from "~/lib/newlineToBr"; +import { cn, formatCurrency } from "~/lib/utils"; +import { useTranslation } from "~/providers/I18nProvider"; +import type { Annunci } from "~/schemas/public/Annunci"; +import type { AnnuncioRicerca } from "~/server/controllers/annunci.controller"; +import { CarouselAnnuncio } from "../annuncio_card"; +import { Badge } from "../ui/badge"; +import { Button } from "../ui/button"; +import { + Dialog, + DialogContent, + DialogDescription, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "../ui/dialog"; + +export const TipoBadge = ({ tipo }: { tipo: Annunci["tipo"] }) => { + return ( + + Affitto {tipo} + + ); +}; + +export const AnnuncioDettaglio = ({ data }: { data: AnnuncioRicerca }) => { + const { locale, t } = useTranslation(); + + return ( + + + + + + + Annuncio {data.codice} + + + + + Annuncio {data.codice} + + +
+
+ img.img)} + updated_at={data.media_updated_at} + videos={data.url_video} + /> +
+ +
+
+ + {data.stato === "Trattativa" && ( + + Annuncio in Trattativa + + )} +
+ +
+
+
+
{t.card.codice}
+ +
Cod: {data.codice}
+
+
+
{t.card.prezzo}
+ +
+ {formatCurrency(data.prezzo / 1e2)} +
+
+
+ +
+
{t.card.titolo}
+ +
+ {locale === "it" ? data.titolo_it : data.titolo_en} +
+
+ +
+
+
+
+
+
+
+
+ ); +}; diff --git a/apps/infoalloggi/src/components/servizio/compatibili_dialog.tsx b/apps/infoalloggi/src/components/servizio/compatibili_dialog.tsx index 96584a9..91da237 100644 --- a/apps/infoalloggi/src/components/servizio/compatibili_dialog.tsx +++ b/apps/infoalloggi/src/components/servizio/compatibili_dialog.tsx @@ -1,17 +1,9 @@ -import { ExternalLink, UnfoldVertical } from "lucide-react"; -import Link from "next/link"; import { useState } from "react"; -import { replaceWithBr } from "~/lib/newlineToBr"; -import { cn, formatCurrency } from "~/lib/utils"; -import { useTranslation } from "~/providers/I18nProvider"; import { useServizio } from "~/providers/ServizioProvider"; -import type { Annunci } from "~/schemas/public/Annunci"; -import type { AnnuncioRicerca } from "~/server/controllers/annunci.controller"; import { api } from "~/utils/api"; -import { CardAnnuncio, CarouselAnnuncio } from "../annuncio_card"; +import { CardAnnuncio } from "../annuncio_card"; import { InteressatoButtonServizio } from "../annuncio-interactions/annuncio_interactions"; import { LoadingPage } from "../loading"; -import { Badge } from "../ui/badge"; import { Button } from "../ui/button"; import { Dialog, @@ -25,6 +17,7 @@ import { } from "../ui/dialog"; import { Label } from "../ui/label"; import { Switch } from "../ui/switch"; +import { AnnuncioDettaglio } from "./annuncio_dettaglio"; export const AnnunciCompatibili = () => { const { servizioId, isAdmin } = useServizio(); @@ -36,7 +29,7 @@ export const AnnunciCompatibili = () => { return ( - @@ -67,12 +60,10 @@ export const AnnunciCompatibili = () => { ) : ( <> {!data || data.length === 0 ? ( -
- - Nessun annuncio compatibile trovato. Amplia la ricerca per - trovare annunci compatibili. - -
+ + Nessun annuncio compatibile trovato. Amplia la ricerca per + trovare annunci compatibili. + ) : (
{data.map((annuncio) => ( @@ -109,106 +100,3 @@ export const AnnunciCompatibili = () => {
); }; - -const TipoBadge = ({ tipo }: { tipo: Annunci["tipo"] }) => { - return ( - - Affitto {tipo} - - ); -}; - -const AnnuncioDettaglio = ({ data }: { data: AnnuncioRicerca }) => { - const { locale, t } = useTranslation(); - - return ( - - - - - - - Annuncio {data.codice} - - - - - Annuncio {data.codice} - - -
-
- img.img)} - updated_at={data.media_updated_at} - videos={data.url_video} - /> -
- -
-
- - {data.stato === "Trattativa" && ( - - Annuncio in Trattativa - - )} -
- -
-
-
-
{t.card.codice}
- -
Cod: {data.codice}
-
-
-
{t.card.prezzo}
- -
- {formatCurrency(data.prezzo / 1e2)} -
-
-
- -
-
{t.card.titolo}
- -
- {locale === "it" ? data.titolo_it : data.titolo_en} -
-
- -
-
-
-
-
-
- - - -
-
- ); -}; diff --git a/apps/infoalloggi/src/server/api/routers/interests.ts b/apps/infoalloggi/src/server/api/routers/interests.ts index 8c464aa..6129180 100644 --- a/apps/infoalloggi/src/server/api/routers/interests.ts +++ b/apps/infoalloggi/src/server/api/routers/interests.ts @@ -93,16 +93,23 @@ export const intrestsRouter = createTRPCRouter({ .select((eb) => [ "annunci.id", "annunci.codice", + "annunci.comune", + "annunci.provincia", "annunci.prezzo", + "annunci.consegna", + "annunci.numero_camere", + "annunci.mq", + "annunci.tipo", + "annunci.titolo_it", + "annunci.titolo_en", "annunci.desc_en", "annunci.desc_it", - "annunci.titolo_en", - "annunci.titolo_it", - "annunci.tipo", - "annunci.consegna", + "annunci.modificato_il", "annunci.stato", - "annunci.web", + "annunci.url_video", "annunci.media_updated_at", + "annunci.homepage", + "annunci.web", jsonArrayFrom( eb .selectFrom("images_refs") diff --git a/apps/infoalloggi/src/server/controllers/servizio.controller.ts b/apps/infoalloggi/src/server/controllers/servizio.controller.ts index 9600918..c09c5eb 100644 --- a/apps/infoalloggi/src/server/controllers/servizio.controller.ts +++ b/apps/infoalloggi/src/server/controllers/servizio.controller.ts @@ -605,6 +605,7 @@ export const setupSaldoConsulenzaServizio = async ({ }); } }; + export type ServizioData = Awaited< ReturnType >[number]; @@ -679,16 +680,23 @@ export const getAllServizioAnnunci = async (userId: UsersId) => { .select((eb) => [ "annunci.id", "annunci.codice", + "annunci.comune", + "annunci.provincia", "annunci.prezzo", + "annunci.consegna", + "annunci.numero_camere", + "annunci.mq", + "annunci.tipo", + "annunci.titolo_it", + "annunci.titolo_en", "annunci.desc_en", "annunci.desc_it", - "annunci.titolo_en", - "annunci.titolo_it", - "annunci.tipo", - "annunci.consegna", + "annunci.modificato_il", "annunci.stato", - "annunci.web", + "annunci.url_video", "annunci.media_updated_at", + "annunci.homepage", + "annunci.web", jsonArrayFrom( eb .selectFrom("images_refs")