2025-08-04 17:45:44 +02:00
|
|
|
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";
|
2025-08-28 18:27:07 +02:00
|
|
|
import { SaldoButton } from "~/components/servizio/interactions";
|
2025-08-04 17:45:44 +02:00
|
|
|
import { ServizioDuration } from "~/components/servizio/service-duration-display";
|
2025-08-28 18:27:07 +02:00
|
|
|
import {
|
|
|
|
|
ServizioActions,
|
|
|
|
|
ServizioActions2,
|
|
|
|
|
} from "~/components/servizio/servizio_actions";
|
|
|
|
|
import {
|
|
|
|
|
AnnunciCompatibili,
|
|
|
|
|
AnnunciInConferma,
|
|
|
|
|
AnnunciSelezionati,
|
|
|
|
|
} from "~/components/servizio/servizio_annunci_accordions";
|
|
|
|
|
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,
|
|
|
|
|
ServizioProvider,
|
|
|
|
|
useServizio,
|
|
|
|
|
} from "~/providers/ServizioProvider";
|
|
|
|
|
import type { UsersId } from "~/schemas/public/Users";
|
|
|
|
|
import type { ServizioData } from "~/server/controllers/servizio.controller";
|
|
|
|
|
import { api } from "~/utils/api";
|
2025-08-04 17:45:44 +02:00
|
|
|
|
|
|
|
|
export const ServizioContainer = ({
|
2025-08-28 18:27:07 +02:00
|
|
|
servizio,
|
|
|
|
|
userId,
|
|
|
|
|
isAdmin,
|
2025-08-04 17:45:44 +02:00
|
|
|
}: {
|
2025-08-28 18:27:07 +02:00
|
|
|
servizio: ServizioData;
|
|
|
|
|
userId: UsersId;
|
|
|
|
|
isAdmin: boolean;
|
2025-08-04 17:45:44 +02:00
|
|
|
}) => {
|
2025-08-28 18:27:07 +02:00
|
|
|
return (
|
|
|
|
|
<ServizioProvider
|
|
|
|
|
isAdmin={isAdmin}
|
|
|
|
|
servizio={servizio}
|
2025-08-29 16:18:32 +02:00
|
|
|
servizioId={servizio.servizio_id}
|
|
|
|
|
userId={userId}
|
2025-08-28 18:27:07 +02:00
|
|
|
>
|
|
|
|
|
<ServizioMain />
|
|
|
|
|
</ServizioProvider>
|
|
|
|
|
);
|
2025-08-04 17:45:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const ServizioCard = ({
|
2025-08-28 18:27:07 +02:00
|
|
|
cardClassName,
|
|
|
|
|
header,
|
|
|
|
|
headerClassName,
|
|
|
|
|
content,
|
|
|
|
|
contentClassName,
|
2025-08-04 17:45:44 +02:00
|
|
|
}: {
|
2025-08-28 18:27:07 +02:00
|
|
|
cardClassName?: string;
|
|
|
|
|
header: React.ReactNode;
|
|
|
|
|
headerClassName?: string;
|
|
|
|
|
content: React.ReactNode;
|
|
|
|
|
contentClassName?: string;
|
2025-08-04 17:45:44 +02:00
|
|
|
}) => {
|
2025-08-28 18:27:07 +02:00
|
|
|
return (
|
|
|
|
|
<Card
|
|
|
|
|
className={cn("gap-2 border-neutral-200 bg-neutral-200", cardClassName)}
|
|
|
|
|
>
|
|
|
|
|
<CardHeader
|
|
|
|
|
className={cn(
|
|
|
|
|
"flex flex-col items-start justify-between gap-3 space-y-0 px-4 pb-8 sm:flex-row",
|
|
|
|
|
headerClassName,
|
|
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
{header}
|
|
|
|
|
</CardHeader>
|
|
|
|
|
<CardContent className={cn("space-y-4 p-4 pt-0", contentClassName)}>
|
|
|
|
|
{content}
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
);
|
2025-08-04 17:45:44 +02:00
|
|
|
};
|
|
|
|
|
|
2025-08-24 15:47:08 +02:00
|
|
|
export const ServizioContent = () => {
|
2025-08-28 18:27:07 +02:00
|
|
|
const { servizio, isAdmin, userId } = useServizio();
|
|
|
|
|
const utils = api.useUtils();
|
|
|
|
|
const { mutate: updateServizio } = api.servizio.updateServizio.useMutation({
|
2025-08-29 16:18:32 +02:00
|
|
|
onError: (error) => {
|
|
|
|
|
toast.error(error.message);
|
|
|
|
|
},
|
2025-08-28 18:27:07 +02:00
|
|
|
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 (
|
|
|
|
|
<ServizioCard
|
|
|
|
|
cardClassName="bg-neutral-100 border-neutral-300"
|
2025-08-29 16:18:32 +02:00
|
|
|
content={
|
|
|
|
|
<>
|
2025-10-10 16:18:43 +02:00
|
|
|
<p className="font-medium text-lg">Servizio interrotto</p>
|
2025-08-29 16:18:32 +02:00
|
|
|
<p>
|
|
|
|
|
Non è possibile riutilizzare questo servizio, poichè è stato
|
|
|
|
|
interrotto.
|
|
|
|
|
</p>
|
|
|
|
|
</>
|
|
|
|
|
}
|
2025-08-28 18:27:07 +02:00
|
|
|
header={
|
|
|
|
|
<>
|
|
|
|
|
<div className="flex flex-col gap-4">
|
|
|
|
|
<CardTitle className="flex items-center gap-2 text-xl sm:text-2xl">
|
2025-10-10 16:18:43 +02:00
|
|
|
<Package className="size-6 text-primary" />
|
2025-08-28 18:27:07 +02:00
|
|
|
Cerco Affitto {servizio.tipologia}
|
|
|
|
|
</CardTitle>
|
|
|
|
|
|
2025-10-10 16:18:43 +02:00
|
|
|
<CardDescription className="space-y-2 pl-2 text-foreground/70">
|
2025-08-28 18:27:07 +02:00
|
|
|
<p>
|
|
|
|
|
aggiunto il{" "}
|
|
|
|
|
{servizio.created_at.toLocaleDateString("it", {
|
|
|
|
|
day: "2-digit",
|
2025-08-29 16:18:32 +02:00
|
|
|
month: "2-digit",
|
|
|
|
|
year: "numeric",
|
2025-08-28 18:27:07 +02:00
|
|
|
})}
|
|
|
|
|
</p>
|
|
|
|
|
</CardDescription>
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!servizio.isOkAcconto || servizio.decorrenza === null) {
|
|
|
|
|
return (
|
|
|
|
|
<ServizioCard
|
|
|
|
|
content={
|
|
|
|
|
<div className="flex flex-col gap-4">
|
|
|
|
|
<div className="flex flex-wrap gap-3">
|
|
|
|
|
<Link
|
|
|
|
|
aria-label="Attiva Servizio"
|
2025-08-29 16:18:32 +02:00
|
|
|
href={`/servizio/onboard/${servizio.servizio_id}`}
|
2025-08-28 18:27:07 +02:00
|
|
|
>
|
|
|
|
|
<Button>Procedi all'attivazione</Button>
|
|
|
|
|
</Link>
|
|
|
|
|
{isAdmin && (
|
|
|
|
|
<Button
|
|
|
|
|
onClick={() =>
|
|
|
|
|
updateServizio({
|
|
|
|
|
data: {
|
|
|
|
|
decorrenza: new Date(),
|
2025-08-29 16:18:32 +02:00
|
|
|
isOkAcconto: true,
|
2025-08-28 18:27:07 +02:00
|
|
|
},
|
2025-08-29 16:18:32 +02:00
|
|
|
servizioId: servizio.servizio_id,
|
2025-08-28 18:27:07 +02:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
variant="success"
|
|
|
|
|
>
|
|
|
|
|
Attiva Manualmente (Azione Admin)
|
|
|
|
|
</Button>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
{isAdmin && (
|
|
|
|
|
<AnnunciSelezionati
|
|
|
|
|
annunci={servizio.annunci}
|
2025-08-29 16:18:32 +02:00
|
|
|
isConfirming={false}
|
2025-08-28 18:27:07 +02:00
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
}
|
2025-08-29 16:18:32 +02:00
|
|
|
header={
|
|
|
|
|
<div className="flex w-full flex-col gap-2">
|
|
|
|
|
{/* <div className="flex w-full flex-col gap-4">
|
|
|
|
|
<CardTitle className="flex items-center gap-2 text-xl sm:text-2xl">
|
|
|
|
|
<Package className="text-primary size-6" />
|
|
|
|
|
Cerco Affitto {servizio.tipologia}
|
|
|
|
|
</CardTitle>
|
|
|
|
|
<CardDescription className="text-foreground/70 pl-2">
|
|
|
|
|
<p>Servizio non attivo</p>
|
|
|
|
|
</CardDescription>
|
|
|
|
|
</div> */}
|
|
|
|
|
<span className="text-foreground/70 text-lg">
|
|
|
|
|
Servizio non attivo
|
|
|
|
|
</span>
|
|
|
|
|
<ServizioActions2 />
|
|
|
|
|
</div>
|
|
|
|
|
}
|
2025-08-28 18:27:07 +02:00
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
const annuncioConfermato = servizio.annunci.filter(
|
|
|
|
|
(a) => a.accettato_conferma_at !== null,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (servizio.isOkSaldo) {
|
|
|
|
|
return (
|
|
|
|
|
<ServizioCard
|
2025-08-29 16:18:32 +02:00
|
|
|
content={
|
|
|
|
|
<>
|
|
|
|
|
{annuncioConfermato.map((data) => {
|
|
|
|
|
return (
|
|
|
|
|
<ServizioAnnuncioProvider data={data} key={data.id}>
|
|
|
|
|
<AnnuncioCard />
|
|
|
|
|
</ServizioAnnuncioProvider>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</>
|
|
|
|
|
}
|
2025-08-28 18:27:07 +02:00
|
|
|
header={
|
|
|
|
|
<>
|
|
|
|
|
{/* <div className="flex w-full flex-wrap items-center gap-2">
|
2025-08-24 15:47:08 +02:00
|
|
|
<CardTitle className="flex items-center gap-2 text-xl sm:text-2xl">
|
|
|
|
|
<Package className="text-primary size-6" />
|
|
|
|
|
Cerco Affitto {servizio.tipologia}
|
|
|
|
|
</CardTitle>
|
|
|
|
|
|
|
|
|
|
<CardDescription className="text-foreground/70 space-y-2 pl-2">
|
|
|
|
|
<p>
|
|
|
|
|
aggiunto il{" "}
|
|
|
|
|
{servizio.created_at.toLocaleDateString("it", {
|
|
|
|
|
year: "numeric",
|
|
|
|
|
month: "2-digit",
|
|
|
|
|
day: "2-digit",
|
|
|
|
|
})}
|
|
|
|
|
</p>
|
|
|
|
|
</CardDescription>
|
|
|
|
|
</div> */}
|
|
|
|
|
|
2025-08-28 18:27:07 +02:00
|
|
|
<ServizioActions2 />
|
|
|
|
|
</>
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const openContattiCount = servizio.annunci.filter(
|
|
|
|
|
(a) => a.open_contatti_at !== null,
|
|
|
|
|
).length;
|
|
|
|
|
|
|
|
|
|
const annunciInConferma = servizio.annunci.filter(
|
|
|
|
|
(a) => a.user_confirmed_at !== null,
|
|
|
|
|
);
|
|
|
|
|
const annunciNotInConferma = servizio.annunci.filter(
|
|
|
|
|
(a) => a.user_confirmed_at === null,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<ServizioCard
|
|
|
|
|
content={
|
|
|
|
|
<>
|
|
|
|
|
<div className="flex flex-col gap-2">
|
|
|
|
|
<div className="flex items-center justify-between">
|
|
|
|
|
<div className="flex items-center gap-2">
|
2025-10-10 16:18:43 +02:00
|
|
|
<UserCircle className="size-6 text-primary" />
|
2025-08-28 18:27:07 +02:00
|
|
|
<span className="font-medium">Contatti sbloccati</span>
|
|
|
|
|
</div>
|
|
|
|
|
<span className="text-sm">{openContattiCount} / 10</span>
|
|
|
|
|
</div>
|
2025-08-29 16:18:32 +02:00
|
|
|
<Progress className="h-2" value={openContattiCount * 10} />
|
2025-08-28 18:27:07 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<ServizioDuration decorrenza={servizio.decorrenza} />
|
|
|
|
|
|
|
|
|
|
{annuncioConfermato.length > 0 && (
|
|
|
|
|
<div className="flex flex-col gap-2">
|
|
|
|
|
<div className="flex items-center gap-2">
|
2025-10-10 16:18:43 +02:00
|
|
|
<PackageCheck className="size-6 text-primary" />
|
2025-08-28 18:27:07 +02:00
|
|
|
<span className="font-medium">Saldi in attesa:</span>
|
|
|
|
|
</div>
|
|
|
|
|
{servizio.annunci
|
|
|
|
|
.filter((a) => a.accettato_conferma_at !== null)
|
|
|
|
|
.map((a) => (
|
|
|
|
|
<div
|
|
|
|
|
className="flex items-center gap-2 rounded-md bg-sky-400 p-2"
|
2025-08-29 16:18:32 +02:00
|
|
|
key={a.annunci_id}
|
2025-08-28 18:27:07 +02:00
|
|
|
>
|
|
|
|
|
<h3>
|
|
|
|
|
{a.codice} - confermato il:{" "}
|
|
|
|
|
{/** biome-ignore lint/style/noNonNullAssertion: <already checked above> */}
|
|
|
|
|
{new Date(a.accettato_conferma_at!).toLocaleDateString(
|
|
|
|
|
"it",
|
|
|
|
|
{
|
|
|
|
|
day: "2-digit",
|
|
|
|
|
hour: "2-digit",
|
|
|
|
|
minute: "2-digit",
|
2025-08-29 16:18:32 +02:00
|
|
|
month: "2-digit",
|
|
|
|
|
year: "numeric",
|
2025-08-28 18:27:07 +02:00
|
|
|
},
|
|
|
|
|
)}
|
|
|
|
|
</h3>
|
|
|
|
|
<SaldoButton
|
|
|
|
|
annuncioId={a.annunci_id}
|
2025-08-29 16:18:32 +02:00
|
|
|
className="border-none"
|
|
|
|
|
variant={"outline"}
|
2025-08-28 18:27:07 +02:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
<div className="space-y-2">
|
|
|
|
|
<AnnunciInConferma annunci={annunciInConferma} />
|
|
|
|
|
<AnnunciSelezionati
|
|
|
|
|
annunci={annunciNotInConferma}
|
2025-08-29 16:18:32 +02:00
|
|
|
isConfirming={annunciInConferma.length > 0}
|
2025-08-28 18:27:07 +02:00
|
|
|
/>
|
|
|
|
|
<AnnunciCompatibili />
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
}
|
2025-08-29 16:18:32 +02:00
|
|
|
header={
|
|
|
|
|
<>
|
|
|
|
|
{/* <div className="flex w-full flex-col gap-2">
|
|
|
|
|
<CardTitle className="flex items-center gap-2 text-xl sm:text-2xl">
|
|
|
|
|
<Package className="text-primary size-6" />
|
|
|
|
|
Cerco Affitto {servizio.tipologia}
|
|
|
|
|
</CardTitle>
|
|
|
|
|
|
|
|
|
|
<CardDescription className="text-foreground/70 space-y-2 pl-2">
|
|
|
|
|
<p>
|
|
|
|
|
aggiunto il{" "}
|
|
|
|
|
{servizio.created_at.toLocaleDateString("it", {
|
|
|
|
|
year: "numeric",
|
|
|
|
|
month: "2-digit",
|
|
|
|
|
day: "2-digit",
|
|
|
|
|
})}
|
|
|
|
|
</p>
|
|
|
|
|
</CardDescription>
|
|
|
|
|
</div> */}
|
|
|
|
|
|
|
|
|
|
<ServizioActions2 />
|
|
|
|
|
</>
|
|
|
|
|
}
|
2025-08-28 18:27:07 +02:00
|
|
|
/>
|
|
|
|
|
);
|
2025-08-24 15:47:08 +02:00
|
|
|
};
|
|
|
|
|
|
2025-08-04 17:45:44 +02:00
|
|
|
const ServizioMain = () => {
|
2025-08-28 18:27:07 +02:00
|
|
|
const { servizio, isAdmin, userId } = useServizio();
|
|
|
|
|
const utils = api.useUtils();
|
|
|
|
|
const { mutate: updateServizio } = api.servizio.updateServizio.useMutation({
|
2025-08-29 16:18:32 +02:00
|
|
|
onError: (error) => {
|
|
|
|
|
toast.error(error.message);
|
|
|
|
|
},
|
2025-08-28 18:27:07 +02:00
|
|
|
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 (
|
|
|
|
|
<ServizioCard
|
|
|
|
|
cardClassName="bg-neutral-100 border-neutral-300"
|
2025-08-29 16:18:32 +02:00
|
|
|
content={
|
|
|
|
|
<>
|
2025-10-10 16:18:43 +02:00
|
|
|
<p className="font-medium text-lg">Servizio interrotto</p>
|
2025-08-29 16:18:32 +02:00
|
|
|
<p>
|
|
|
|
|
Non è possibile riutilizzare questo servizio, poichè è stato
|
|
|
|
|
interrotto.
|
|
|
|
|
</p>
|
|
|
|
|
</>
|
|
|
|
|
}
|
2025-08-28 18:27:07 +02:00
|
|
|
header={
|
|
|
|
|
<>
|
|
|
|
|
<div className="flex flex-col gap-4">
|
|
|
|
|
<CardTitle className="flex items-center gap-2 text-xl sm:text-2xl">
|
2025-10-10 16:18:43 +02:00
|
|
|
<Package className="size-6 text-primary" />
|
2025-08-28 18:27:07 +02:00
|
|
|
Cerco Affitto {servizio.tipologia}
|
|
|
|
|
</CardTitle>
|
|
|
|
|
|
2025-10-10 16:18:43 +02:00
|
|
|
<CardDescription className="space-y-2 pl-2 text-foreground/70">
|
2025-08-28 18:27:07 +02:00
|
|
|
<p>
|
|
|
|
|
aggiunto il{" "}
|
|
|
|
|
{servizio.created_at.toLocaleDateString("it", {
|
|
|
|
|
day: "2-digit",
|
2025-08-29 16:18:32 +02:00
|
|
|
month: "2-digit",
|
|
|
|
|
year: "numeric",
|
2025-08-28 18:27:07 +02:00
|
|
|
})}
|
|
|
|
|
</p>
|
|
|
|
|
</CardDescription>
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!servizio.isOkAcconto || servizio.decorrenza === null) {
|
|
|
|
|
return (
|
|
|
|
|
<ServizioCard
|
|
|
|
|
content={
|
|
|
|
|
<div className="flex flex-col gap-4">
|
|
|
|
|
<div className="flex flex-wrap gap-3">
|
|
|
|
|
<Link
|
|
|
|
|
aria-label="Attiva Servizio"
|
2025-08-29 16:18:32 +02:00
|
|
|
href={`/servizio/onboard/${servizio.servizio_id}`}
|
2025-08-28 18:27:07 +02:00
|
|
|
>
|
|
|
|
|
<Button>Procedi all'attivazione</Button>
|
|
|
|
|
</Link>
|
|
|
|
|
{isAdmin && (
|
|
|
|
|
<Button
|
|
|
|
|
onClick={() =>
|
|
|
|
|
updateServizio({
|
|
|
|
|
data: {
|
|
|
|
|
decorrenza: new Date(),
|
2025-08-29 16:18:32 +02:00
|
|
|
isOkAcconto: true,
|
2025-08-28 18:27:07 +02:00
|
|
|
},
|
2025-08-29 16:18:32 +02:00
|
|
|
servizioId: servizio.servizio_id,
|
2025-08-28 18:27:07 +02:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
variant="success"
|
|
|
|
|
>
|
|
|
|
|
Attiva Manualmente (Azione Admin)
|
|
|
|
|
</Button>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
{isAdmin && (
|
|
|
|
|
<AnnunciSelezionati
|
|
|
|
|
annunci={servizio.annunci}
|
2025-08-29 16:18:32 +02:00
|
|
|
isConfirming={false}
|
2025-08-28 18:27:07 +02:00
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
}
|
2025-08-29 16:18:32 +02:00
|
|
|
header={
|
|
|
|
|
<>
|
|
|
|
|
<div className="flex w-full flex-col gap-4">
|
|
|
|
|
<CardTitle className="flex items-center gap-2 text-xl sm:text-2xl">
|
2025-10-10 16:18:43 +02:00
|
|
|
<Package className="size-6 text-primary" />
|
2025-08-29 16:18:32 +02:00
|
|
|
Cerco Affitto {servizio.tipologia}
|
|
|
|
|
</CardTitle>
|
2025-10-10 16:18:43 +02:00
|
|
|
<CardDescription className="pl-2 text-foreground/70">
|
2025-08-29 16:18:32 +02:00
|
|
|
<p>Servizio non attivo</p>
|
|
|
|
|
</CardDescription>
|
|
|
|
|
</div>
|
|
|
|
|
<ServizioActions />
|
|
|
|
|
</>
|
|
|
|
|
}
|
2025-08-28 18:27:07 +02:00
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
const annuncioConfermato = servizio.annunci.filter(
|
|
|
|
|
(a) => a.accettato_conferma_at !== null,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (servizio.isOkSaldo) {
|
|
|
|
|
return (
|
|
|
|
|
<ServizioCard
|
2025-08-29 16:18:32 +02:00
|
|
|
content={
|
|
|
|
|
<>
|
|
|
|
|
{annuncioConfermato.map((data) => {
|
|
|
|
|
return (
|
|
|
|
|
<ServizioAnnuncioProvider data={data} key={data.id}>
|
|
|
|
|
<AnnuncioCard />
|
|
|
|
|
</ServizioAnnuncioProvider>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</>
|
|
|
|
|
}
|
2025-08-28 18:27:07 +02:00
|
|
|
header={
|
|
|
|
|
<>
|
|
|
|
|
<div className="flex w-full flex-wrap items-center gap-2">
|
|
|
|
|
<CardTitle className="flex items-center gap-2 text-xl sm:text-2xl">
|
2025-10-10 16:18:43 +02:00
|
|
|
<Package className="size-6 text-primary" />
|
2025-08-28 18:27:07 +02:00
|
|
|
Cerco Affitto {servizio.tipologia}
|
|
|
|
|
</CardTitle>
|
|
|
|
|
|
2025-10-10 16:18:43 +02:00
|
|
|
<CardDescription className="space-y-2 pl-2 text-foreground/70">
|
2025-08-28 18:27:07 +02:00
|
|
|
<p>
|
|
|
|
|
aggiunto il{" "}
|
|
|
|
|
{servizio.created_at.toLocaleDateString("it", {
|
|
|
|
|
day: "2-digit",
|
2025-08-29 16:18:32 +02:00
|
|
|
month: "2-digit",
|
|
|
|
|
year: "numeric",
|
2025-08-28 18:27:07 +02:00
|
|
|
})}
|
|
|
|
|
</p>
|
|
|
|
|
</CardDescription>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<ServizioActions />
|
|
|
|
|
</>
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const openContattiCount = servizio.annunci.filter(
|
|
|
|
|
(a) => a.open_contatti_at !== null,
|
|
|
|
|
).length;
|
|
|
|
|
|
|
|
|
|
const annunciInConferma = servizio.annunci.filter(
|
|
|
|
|
(a) => a.user_confirmed_at !== null,
|
|
|
|
|
);
|
|
|
|
|
const annunciNotInConferma = servizio.annunci.filter(
|
|
|
|
|
(a) => a.user_confirmed_at === null,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<ServizioCard
|
|
|
|
|
content={
|
|
|
|
|
<>
|
|
|
|
|
<div className="flex flex-col gap-2">
|
|
|
|
|
<div className="flex items-center justify-between">
|
|
|
|
|
<div className="flex items-center gap-2">
|
2025-10-10 16:18:43 +02:00
|
|
|
<UserCircle className="size-6 text-primary" />
|
2025-08-28 18:27:07 +02:00
|
|
|
<span className="font-medium">Contatti sbloccati</span>
|
|
|
|
|
</div>
|
|
|
|
|
<span className="text-sm">{openContattiCount} / 10</span>
|
|
|
|
|
</div>
|
2025-08-29 16:18:32 +02:00
|
|
|
<Progress className="h-2" value={openContattiCount * 10} />
|
2025-08-28 18:27:07 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<ServizioDuration decorrenza={servizio.decorrenza} />
|
|
|
|
|
|
|
|
|
|
{annuncioConfermato.length > 0 && (
|
|
|
|
|
<div className="flex flex-col gap-2">
|
|
|
|
|
<div className="flex items-center gap-2">
|
2025-10-10 16:18:43 +02:00
|
|
|
<PackageCheck className="size-6 text-primary" />
|
2025-08-28 18:27:07 +02:00
|
|
|
<span className="font-medium">Saldi in attesa:</span>
|
|
|
|
|
</div>
|
|
|
|
|
{servizio.annunci
|
|
|
|
|
.filter((a) => a.accettato_conferma_at !== null)
|
|
|
|
|
.map((a) => (
|
|
|
|
|
<div
|
|
|
|
|
className="flex items-center gap-2 rounded-md bg-sky-400 p-2"
|
2025-08-29 16:18:32 +02:00
|
|
|
key={a.annunci_id}
|
2025-08-28 18:27:07 +02:00
|
|
|
>
|
|
|
|
|
<h3>
|
|
|
|
|
{a.codice} - confermato il:{" "}
|
|
|
|
|
{/** biome-ignore lint/style/noNonNullAssertion: <already checked> */}
|
|
|
|
|
{new Date(a.accettato_conferma_at!).toLocaleDateString(
|
|
|
|
|
"it",
|
|
|
|
|
{
|
|
|
|
|
day: "2-digit",
|
|
|
|
|
hour: "2-digit",
|
|
|
|
|
minute: "2-digit",
|
2025-08-29 16:18:32 +02:00
|
|
|
month: "2-digit",
|
|
|
|
|
year: "numeric",
|
2025-08-28 18:27:07 +02:00
|
|
|
},
|
|
|
|
|
)}
|
|
|
|
|
</h3>
|
|
|
|
|
<SaldoButton
|
|
|
|
|
annuncioId={a.annunci_id}
|
2025-08-29 16:18:32 +02:00
|
|
|
className="border-none"
|
|
|
|
|
variant={"outline"}
|
2025-08-28 18:27:07 +02:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
<div className="space-y-2">
|
|
|
|
|
<AnnunciInConferma annunci={annunciInConferma} />
|
|
|
|
|
<AnnunciSelezionati
|
|
|
|
|
annunci={annunciNotInConferma}
|
2025-08-29 16:18:32 +02:00
|
|
|
isConfirming={annunciInConferma.length > 0}
|
2025-08-28 18:27:07 +02:00
|
|
|
/>
|
|
|
|
|
<AnnunciCompatibili />
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
}
|
2025-08-29 16:18:32 +02:00
|
|
|
header={
|
|
|
|
|
<>
|
|
|
|
|
<div className="flex w-full flex-col gap-2">
|
|
|
|
|
<CardTitle className="flex items-center gap-2 text-xl sm:text-2xl">
|
2025-10-10 16:18:43 +02:00
|
|
|
<Package className="size-6 text-primary" />
|
2025-08-29 16:18:32 +02:00
|
|
|
Cerco Affitto {servizio.tipologia}
|
|
|
|
|
</CardTitle>
|
|
|
|
|
|
2025-10-10 16:18:43 +02:00
|
|
|
<CardDescription className="space-y-2 pl-2 text-foreground/70">
|
2025-08-29 16:18:32 +02:00
|
|
|
<p>
|
|
|
|
|
aggiunto il{" "}
|
|
|
|
|
{servizio.created_at.toLocaleDateString("it", {
|
|
|
|
|
day: "2-digit",
|
|
|
|
|
month: "2-digit",
|
|
|
|
|
year: "numeric",
|
|
|
|
|
})}
|
|
|
|
|
</p>
|
|
|
|
|
</CardDescription>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<ServizioActions />
|
|
|
|
|
</>
|
|
|
|
|
}
|
2025-08-28 18:27:07 +02:00
|
|
|
/>
|
|
|
|
|
);
|
2025-08-04 17:45:44 +02:00
|
|
|
};
|