2025-08-04 17:45:44 +02:00
|
|
|
import { AccordionComp } from "~/components/accordionComp";
|
2025-08-28 18:27:07 +02:00
|
|
|
import { LoadingPage } from "~/components/loading";
|
|
|
|
|
import { TabRicerca } from "~/components/tables/ricerca-table";
|
2025-08-05 19:23:55 +02:00
|
|
|
import TimeserieBarChart from "~/components/timeserieBarChart";
|
2025-08-28 18:27:07 +02:00
|
|
|
import TimeserieBarChartStacked from "~/components/timeserieBarChartStacked";
|
2025-08-05 19:23:55 +02:00
|
|
|
import {
|
2025-08-28 18:27:07 +02:00
|
|
|
Card,
|
|
|
|
|
CardContent,
|
|
|
|
|
CardDescription,
|
|
|
|
|
CardHeader,
|
|
|
|
|
CardTitle,
|
2025-08-05 19:23:55 +02:00
|
|
|
} from "~/components/ui/card";
|
2025-08-28 18:27:07 +02:00
|
|
|
import { useTranslation } from "~/providers/I18nProvider";
|
|
|
|
|
import type { UsersId } from "~/schemas/public/Users";
|
|
|
|
|
import { api } from "~/utils/api";
|
2025-08-04 17:45:44 +02:00
|
|
|
|
|
|
|
|
export const AdminDashboard = () => {
|
2025-08-28 18:27:07 +02:00
|
|
|
const { data: stats, isLoading } = api.stats.adminDashStats.useQuery();
|
2025-08-04 17:45:44 +02:00
|
|
|
|
2025-08-28 18:27:07 +02:00
|
|
|
if (isLoading) return <LoadingPage />;
|
|
|
|
|
return (
|
|
|
|
|
<div className="mx-1 flex-1 overflow-auto">
|
|
|
|
|
<div className="mx-auto pt-4 pb-8">
|
|
|
|
|
<div className="mx-3 items-start justify-between pb-3 md:flex">
|
|
|
|
|
<div className="flex max-w-lg items-center gap-3">
|
|
|
|
|
<h3 className="text-2xl font-bold">Admin Dashboard</h3>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
{!stats ? (
|
|
|
|
|
<div className="text-red-500">Errore caricamento statistiche</div>
|
|
|
|
|
) : (
|
|
|
|
|
<div className="grid grid-cols-1 gap-4 px-2 pt-4 sm:grid-cols-2 sm:px-4">
|
|
|
|
|
<Card className="">
|
|
|
|
|
<CardHeader>
|
|
|
|
|
<CardTitle>Utenti</CardTitle>
|
|
|
|
|
<CardDescription>
|
|
|
|
|
Numero totale di utenti registrati
|
|
|
|
|
</CardDescription>
|
|
|
|
|
</CardHeader>
|
2025-08-05 19:23:55 +02:00
|
|
|
|
2025-08-28 18:27:07 +02:00
|
|
|
<CardContent className="flex h-full items-center justify-center text-6xl font-bold">
|
|
|
|
|
{stats.userCount}
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
<TimeserieBarChart
|
|
|
|
|
title="Utenti registrati"
|
|
|
|
|
timeserie={stats.userTimeserie}
|
|
|
|
|
/>
|
2025-08-05 19:23:55 +02:00
|
|
|
|
2025-08-28 18:27:07 +02:00
|
|
|
<TimeserieBarChartStacked
|
|
|
|
|
title="Servizi creati"
|
|
|
|
|
valueALabel={stats.serviziTimeserie.valueALabel}
|
|
|
|
|
valueBLabel={stats.serviziTimeserie.valueBLabel}
|
|
|
|
|
timeserie={stats.serviziTimeserie.data}
|
|
|
|
|
/>
|
2025-08-05 19:23:55 +02:00
|
|
|
|
2025-08-28 18:27:07 +02:00
|
|
|
<TimeserieBarChart
|
|
|
|
|
title="Contatti generati"
|
|
|
|
|
timeserie={stats.contattiTimeserie}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
2025-08-04 17:45:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const UserDashboard = ({ userId }: { userId: UsersId }) => {
|
2025-08-28 18:27:07 +02:00
|
|
|
// const { data: servizi, isLoading: loadingServizi } =
|
|
|
|
|
// api.servizio.getAllServizioAnnunci.useQuery({ userId });
|
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
return (
|
|
|
|
|
<div className="mx-1 flex-1 overflow-auto">
|
|
|
|
|
<div className="mx-auto pt-4">
|
|
|
|
|
<div className="mx-3 items-start justify-between md:flex">
|
|
|
|
|
<div className="flex max-w-lg items-center gap-3">
|
|
|
|
|
<h3 className="text-2xl font-bold">Le tue ricerche</h3>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-08-04 17:45:44 +02:00
|
|
|
|
2025-08-28 18:27:07 +02:00
|
|
|
<div className="flex flex-col space-y-5 px-2">
|
|
|
|
|
<TabRicerca userId={userId} isAdmin={false} />
|
|
|
|
|
{/* {loadingServizi ? (
|
2025-08-04 17:45:44 +02:00
|
|
|
<LoadingPage />
|
|
|
|
|
) : (
|
|
|
|
|
servizi?.map((servizio, idx) => (
|
|
|
|
|
<ServizioContainer
|
|
|
|
|
key={idx}
|
|
|
|
|
servizio={servizio}
|
|
|
|
|
userId={userId}
|
|
|
|
|
isAdmin={false}
|
|
|
|
|
/>
|
|
|
|
|
))
|
2025-08-24 15:47:08 +02:00
|
|
|
)} */}
|
2025-08-28 18:27:07 +02:00
|
|
|
</div>
|
|
|
|
|
<AccordionComp
|
|
|
|
|
texts={t.area_riservata.dash_accordion_minifaq}
|
|
|
|
|
className="w-full max-w-full px-2 pt-4"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
2025-08-04 17:45:44 +02:00
|
|
|
};
|