Ajout de la gestion de la session utilisateur et d'un composant d'horloge dans le tableau de bord
This commit is contained in:
parent
032c4ed3f3
commit
4676f27293
@ -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 />
|
||||||
|
|||||||
25
front/components/ui/Clock.tsx
Normal file
25
front/components/ui/Clock.tsx
Normal 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>
|
||||||
|
);
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user