mirror of
https://github.com/Fayorg/calendrier-avant.git
synced 2026-05-28 01:28:37 +02:00
add: dashboard tabs
This commit is contained in:
14
app/dashboard/Accounts.tsx
Normal file
14
app/dashboard/Accounts.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
import { getAccounts } from '@/actions/accounts';
|
||||
import prisma from '@/lib/prisma';
|
||||
|
||||
export async function Accounts() {
|
||||
const users = await getAccounts({ take: 2 });
|
||||
|
||||
console.log(users);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className="text-white">Accounts</h1>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import { setTestActive } from '@/actions/mangeTest';
|
||||
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger } from '@/components/ui/alert-dialog';
|
||||
|
||||
export default function ActiveCard() {
|
||||
return (
|
||||
<AlertDialog>
|
||||
<AlertDialogTrigger>Open</AlertDialogTrigger>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>Etes-vous sur de vouloir terminer ce test?</AlertDialogTitle>
|
||||
<AlertDialogDescription>Les votations ne seront plus ouverte pour ce test. Vous pouvez cependant le réactiver dans le dashboard.</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
||||
<AlertDialogAction onClick={() => setTestActive(1, true)}>Continue</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
);
|
||||
}
|
||||
7
app/dashboard/Simulation.tsx
Normal file
7
app/dashboard/Simulation.tsx
Normal file
@@ -0,0 +1,7 @@
|
||||
export function Simulation() {
|
||||
return (
|
||||
<div>
|
||||
<h1 className="text-white">Simulation</h1>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
22
app/dashboard/Tabs.tsx
Normal file
22
app/dashboard/Tabs.tsx
Normal file
@@ -0,0 +1,22 @@
|
||||
import { TabsContent, TabsList, TabsTrigger, Tabs as TabsShad } from '@/components/ui/tabs';
|
||||
import { Simulation } from './Simulation';
|
||||
import { Accounts } from './Accounts';
|
||||
|
||||
export function Tabs() {
|
||||
return (
|
||||
<TabsShad defaultValue="simulation" className="w-[400px]">
|
||||
<TabsList>
|
||||
<TabsTrigger value="simulation">Simulation</TabsTrigger>
|
||||
<TabsTrigger value="accounts">Comptes</TabsTrigger>
|
||||
{/* <TabsTrigger value="exercices">Exercices</TabsTrigger> */}
|
||||
<TabsTrigger value="statistics">Statistiques</TabsTrigger>
|
||||
</TabsList>
|
||||
<TabsContent value="simulation">
|
||||
<Simulation />
|
||||
</TabsContent>
|
||||
<TabsContent value="accounts">
|
||||
<Accounts />
|
||||
</TabsContent>
|
||||
</TabsShad>
|
||||
);
|
||||
}
|
||||
@@ -1,30 +1,21 @@
|
||||
import prisma from '@/lib/prisma';
|
||||
import ActiveCard from './ActiveCard';
|
||||
import { getAuthServerSession } from '@/lib/authenticate';
|
||||
import { redirect } from 'next/navigation';
|
||||
import { Tabs } from './Tabs';
|
||||
|
||||
export default async function Dashboard() {
|
||||
const authSession = await getAuthServerSession();
|
||||
console.log(authSession);
|
||||
if (!authSession) return redirect('/');
|
||||
const session = await getAuthServerSession();
|
||||
console.log(session?.user);
|
||||
if (!session || !(session.user.isAdmin || session.user.isTeacher)) return redirect('/');
|
||||
|
||||
const tests = await prisma.test.findMany({ select: { isActive: true, id: true, testOf: { select: { id: true, firstName: true, lastName: true, isTeacher: true } } } });
|
||||
|
||||
const activeTests = tests.filter((test) => test.isActive);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1>Dashboard</h1>
|
||||
<div className="border-2 border-white rounded-2xl bg-red-500 p-2">
|
||||
<h2>Test(s) Actif(s) :</h2>
|
||||
<ul>
|
||||
{activeTests.map((test) => (
|
||||
<li key={test.id}>
|
||||
{test.testOf.firstName + ' ' + test.testOf.lastName} <ActiveCard />
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
<div className="container flex flex-col gap-4 my-4">
|
||||
<h1 className="text-4xl text-white font-bold">Dashboard</h1>
|
||||
<Tabs />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user