import { Package, PackageCheck, UserCircle } from "lucide-react"; import Link from "next/link"; import { useRouter } from "next/router"; import { useEffect } from "react"; import toast from "react-hot-toast"; import { AnnuncioCard } from "~/components/servizio/annuncio_card"; import { SaldoButton } from "~/components/servizio/interactions"; import { ServizioDuration } from "~/components/servizio/service-duration-display"; import { ServizioActions2 } from "~/components/servizio/servizio_actions"; import { Button } from "~/components/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "~/components/ui/card"; import { Progress } from "~/components/ui/progress"; import { cn } from "~/lib/utils"; import { ServizioAnnuncioProvider, useServizio, } from "~/providers/ServizioProvider"; import { api } from "~/utils/api"; import { AnnunciCompatibili, AnnunciSelezionati, } from "./servizio_annunci_accordions"; const ServizioCard = ({ cardClassName, header, headerClassName, content, contentClassName, }: { cardClassName?: string; header: React.ReactNode; headerClassName?: string; content: React.ReactNode; contentClassName?: string; }) => { return ( {header} {content} ); }; export const ServizioContent = () => { const { servizio, isAdmin, userId } = useServizio(); const utils = api.useUtils(); const { mutate: updateServizio } = api.servizio.updateServizio.useMutation({ onError: (error) => { toast.error(error.message); }, onSuccess: async () => { toast.success("Servizio modificato con successo"); await utils.servizio.getAllServizioAnnunci.invalidate({ userId }); }, }); const router = useRouter(); useEffect(() => { const id = router.asPath.split("#")[1]; if (id) { document.getElementById(id)?.scrollIntoView({ behavior: "smooth", }); } }, []); if (servizio.isInterrotto) { return ( Servizio interrotto Non è possibile riutilizzare questo servizio, poichè è stato interrotto. > } header={ <> Cerco Affitto {servizio.tipologia} aggiunto il{" "} {servizio.created_at.toLocaleDateString("it", { day: "2-digit", month: "2-digit", year: "numeric", })} > } /> ); } if (!servizio.isOkAcconto || servizio.decorrenza === null) { return ( Procedi all'attivazione {isAdmin && ( updateServizio({ data: { decorrenza: new Date(), isOkAcconto: true, }, servizioId: servizio.servizio_id, }) } variant="success" > Attiva Manualmente (Azione Admin) )} {isAdmin && } } header={ Servizio non attivo } /> ); } const annuncioConfermato = servizio.annunci.filter( (a) => a.accettato_conferma_at !== null, ); if (servizio.isOkSaldo) { return ( {annuncioConfermato.map((data) => { return ( ); })} > } header={ <> > } /> ); } const openContattiAnnunci = servizio.annunci.filter( (a) => a.open_contatti_at !== null && a.user_confirmed_at === null, ); const annunciInConferma = servizio.annunci.filter( (a) => a.user_confirmed_at !== null, ); const annunciNotInConferma = servizio.annunci.filter( (a) => a.user_confirmed_at === null, ); return ( Contatti sbloccati {openContattiAnnunci.length} / 10 {annuncioConfermato.length > 0 && ( Saldi in attesa: {servizio.annunci .filter((a) => a.accettato_conferma_at !== null) .map((a) => ( {a.codice} - confermato il:{" "} {/** biome-ignore lint/style/noNonNullAssertion: */} {new Date(a.accettato_conferma_at!).toLocaleDateString( "it", { day: "2-digit", hour: "2-digit", minute: "2-digit", month: "2-digit", year: "numeric", }, )} ))} )} {openContattiAnnunci.map((data) => { return ( ); })} {annunciInConferma.map((data) => { return ( ); })} > } header={ <> > } /> ); };
Servizio interrotto
Non è possibile riutilizzare questo servizio, poichè è stato interrotto.
aggiunto il{" "} {servizio.created_at.toLocaleDateString("it", { day: "2-digit", month: "2-digit", year: "numeric", })}