2025-08-04 17:45:44 +02:00
|
|
|
import Head from "next/head";
|
2025-11-10 16:27:15 +01:00
|
|
|
import { DocumentiPersonali } from "~/components/area-riservata/documenti_personali";
|
2025-08-04 17:45:44 +02:00
|
|
|
import { AreaRiservataLayout } from "~/components/Layout";
|
2025-08-28 18:27:07 +02:00
|
|
|
import { LoadingPage } from "~/components/loading";
|
2025-08-04 17:45:44 +02:00
|
|
|
import { Status500 } from "~/components/status-page";
|
2025-08-28 18:27:07 +02:00
|
|
|
import {
|
|
|
|
|
Card,
|
|
|
|
|
CardContent,
|
|
|
|
|
CardDescription,
|
|
|
|
|
CardHeader,
|
|
|
|
|
CardTitle,
|
|
|
|
|
} from "~/components/ui/card";
|
2025-08-04 17:45:44 +02:00
|
|
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "~/components/ui/tabs";
|
2025-08-28 18:27:07 +02:00
|
|
|
import { UserAvatar } from "~/components/user_avatar";
|
|
|
|
|
import { ChangePasswordForm } from "~/forms/FormChangePassword";
|
2025-08-04 17:45:44 +02:00
|
|
|
import { ProfileFormAccount } from "~/forms/FormProfilo_Account";
|
|
|
|
|
import { ProfileFormAnagrafica } from "~/forms/FormProfilo_Anagrafica";
|
2025-08-28 18:27:07 +02:00
|
|
|
import type { NextPageWithLayout } from "~/pages/_app";
|
2025-11-13 15:45:55 +01:00
|
|
|
import { CatastoProvider } from "~/providers/CatastoProvider";
|
2025-08-20 14:04:23 +02:00
|
|
|
import { useEnforcedSession } from "~/providers/SessionProvider";
|
2025-08-28 18:27:07 +02:00
|
|
|
import { api } from "~/utils/api";
|
2025-08-04 17:45:44 +02:00
|
|
|
|
|
|
|
|
const Dashboard: NextPageWithLayout = () => {
|
2025-11-10 16:27:15 +01:00
|
|
|
const { user } = useEnforcedSession();
|
|
|
|
|
|
2025-08-28 18:27:07 +02:00
|
|
|
const { data: userData, isLoading } = api.users.getClientProfilo.useQuery({
|
2025-11-10 16:27:15 +01:00
|
|
|
userId: user.id,
|
2025-08-28 18:27:07 +02:00
|
|
|
});
|
|
|
|
|
const session = useEnforcedSession();
|
|
|
|
|
if (isLoading) return <LoadingPage />;
|
|
|
|
|
if (!userData) return <Status500 />;
|
2025-08-04 17:45:44 +02:00
|
|
|
|
2025-08-28 18:27:07 +02:00
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<Head>
|
2026-01-19 10:23:16 +01:00
|
|
|
<title>Profilo - Infoalloggi.it</title>
|
2025-08-28 18:27:07 +02:00
|
|
|
</Head>
|
2025-08-04 17:45:44 +02:00
|
|
|
|
2025-08-28 18:27:07 +02:00
|
|
|
<div className="mx-auto w-full max-w-5xl grow p-4">
|
|
|
|
|
<div className="flex p-1 py-2">
|
|
|
|
|
<UserAvatar
|
|
|
|
|
userId={session.user.id}
|
2025-08-29 16:18:32 +02:00
|
|
|
username={session.user.username}
|
2025-08-28 18:27:07 +02:00
|
|
|
/>
|
2025-08-04 17:45:44 +02:00
|
|
|
|
2025-08-28 18:27:07 +02:00
|
|
|
<div className="flex flex-col items-start justify-center pl-4">
|
2025-12-29 16:09:51 +01:00
|
|
|
<h1 className="font-bold text-2xl">Profilo Utente</h1>
|
2025-08-28 18:27:07 +02:00
|
|
|
<p className="text-muted-foreground text-sm">
|
|
|
|
|
Gestisci le tue informazioni personali e le preferenze di account.
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="space-y-4 pt-4">
|
|
|
|
|
<div className="flex flex-col-reverse gap-4 sm:flex-row">
|
|
|
|
|
<div className="w-full pb-10">
|
2025-08-29 16:18:32 +02:00
|
|
|
<Tabs className="w-full" defaultValue="account">
|
2025-08-28 18:27:07 +02:00
|
|
|
<TabsList className="mb-2">
|
|
|
|
|
<TabsTrigger value="account">Account</TabsTrigger>
|
|
|
|
|
<TabsTrigger value="anagrafica">Anagrafica</TabsTrigger>
|
2025-11-10 16:27:15 +01:00
|
|
|
<TabsTrigger value="documenti">Documenti</TabsTrigger>
|
2025-08-28 18:27:07 +02:00
|
|
|
</TabsList>
|
2025-08-29 16:18:32 +02:00
|
|
|
<TabsContent className="flex flex-col gap-8" value="account">
|
2025-08-28 18:27:07 +02:00
|
|
|
<Card>
|
|
|
|
|
<CardHeader>
|
|
|
|
|
<CardTitle>Dati Account</CardTitle>
|
|
|
|
|
<CardDescription className="sr-only">
|
|
|
|
|
Card Description
|
|
|
|
|
</CardDescription>
|
|
|
|
|
</CardHeader>
|
|
|
|
|
<CardContent>
|
|
|
|
|
<ProfileFormAccount
|
|
|
|
|
cognome={userData.cognome}
|
|
|
|
|
email={userData.email}
|
2025-08-29 16:18:32 +02:00
|
|
|
id={userData.id}
|
|
|
|
|
nome={userData.nome}
|
2025-08-28 18:27:07 +02:00
|
|
|
telefono={userData.telefono}
|
|
|
|
|
/>
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
<Card>
|
|
|
|
|
<CardHeader>
|
|
|
|
|
<CardTitle>Cambia Password</CardTitle>
|
|
|
|
|
<CardDescription className="sr-only">
|
|
|
|
|
Card Description
|
|
|
|
|
</CardDescription>
|
|
|
|
|
</CardHeader>
|
|
|
|
|
<CardContent>
|
|
|
|
|
<ChangePasswordForm />
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
<div className="flex flex-col gap-2 p-2">
|
|
|
|
|
<h4 className="font-medium">Ti sei registrato il:</h4>
|
2026-01-26 17:45:52 +01:00
|
|
|
<p>{userData.created_at?.toLocaleString("it-IT")}</p>
|
2025-08-28 18:27:07 +02:00
|
|
|
</div>
|
|
|
|
|
</TabsContent>
|
2025-08-29 16:18:32 +02:00
|
|
|
<TabsContent className="h-full space-y-6" value="anagrafica">
|
2025-08-28 18:27:07 +02:00
|
|
|
<Card>
|
|
|
|
|
<CardHeader>
|
|
|
|
|
<CardTitle>Dati Anagrafici</CardTitle>
|
|
|
|
|
<CardDescription className="sr-only">
|
|
|
|
|
Card Description
|
|
|
|
|
</CardDescription>
|
|
|
|
|
</CardHeader>
|
|
|
|
|
<CardContent>
|
2025-11-13 15:45:55 +01:00
|
|
|
<CatastoProvider>
|
|
|
|
|
<ProfileFormAnagrafica userData={userData} />
|
|
|
|
|
</CatastoProvider>
|
2025-08-28 18:27:07 +02:00
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
</TabsContent>
|
2025-11-10 16:27:15 +01:00
|
|
|
<TabsContent className="h-full space-y-6" value="documenti">
|
|
|
|
|
<DocumentiPersonali userData={userData} />
|
|
|
|
|
</TabsContent>
|
2025-08-28 18:27:07 +02:00
|
|
|
</Tabs>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
);
|
2025-08-04 17:45:44 +02:00
|
|
|
};
|
|
|
|
|
export default Dashboard;
|
|
|
|
|
|
|
|
|
|
Dashboard.getLayout = function getLayout(page) {
|
2025-08-28 18:27:07 +02:00
|
|
|
return <AreaRiservataLayout>{page}</AreaRiservataLayout>;
|
2025-08-04 17:45:44 +02:00
|
|
|
};
|