Ajout de la gestion de la session utilisateur et d'un composant d'horloge dans le tableau de bord

This commit is contained in:
Kevin 2025-02-24 16:19:37 +01:00
parent 032c4ed3f3
commit 4676f27293
2 changed files with 39 additions and 1 deletions

View File

@ -4,15 +4,28 @@ import { Podcast } from "@/components/podcast";
import { CalendarWidget } from "@/components/calendar-widget"; import { CalendarWidget } from "@/components/calendar-widget";
import { News } from "@/components/news"; import { News } from "@/components/news";
import { Todo } from "@/components/todo"; import { Todo } from "@/components/todo";
import { getServerSession } from "next-auth/next";
import { authOptions } from "./api/auth/[...nextauth]/route";
import { Clock } from "@/components/ui/Clock";
export const metadata = { export const metadata = {
title: "Enkun - Dashboard", title: "Enkun - Dashboard",
}; };
export default function Page() { export default async function Page() {
const session = await getServerSession(authOptions);
return ( return (
<div> <div>
<div className='container mx-auto p-4'> <div className='container mx-auto p-4'>
<div className='flex justify-between items-center align-middle mb-6 alig'>
{session?.user && (
<h1 className='text-2xl font-bold'>
Bienvenue, {session.user.first_name} !
</h1>
)}
<Clock />
</div>
<div className='grid grid-cols-12 gap-4'> <div className='grid grid-cols-12 gap-4'>
<div className='col-span-3'> <div className='col-span-3'>
<QuoteCard /> <QuoteCard />

View File

@ -0,0 +1,25 @@
"use client";
import { useState, useEffect } from "react";
export function Clock() {
const [time, setTime] = useState(new Date());
useEffect(() => {
const timer = setInterval(() => {
setTime(new Date());
}, 1000);
return () => clearInterval(timer);
}, []);
return (
<div className='text-4xl text-white'>
{time.toLocaleTimeString("fr-FR", {
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
})}
</div>
);
}