diff --git a/actions/mangeTest.ts b/actions/mangeTest.ts new file mode 100644 index 0000000..74822da --- /dev/null +++ b/actions/mangeTest.ts @@ -0,0 +1,12 @@ +"use server"; + +import prisma from "@/lib/prisma"; + +export async function setTestActive(id: number, active: boolean) { + const users = await prisma.users.findFirst(); + + console.log(users); + + return true; + +} \ No newline at end of file diff --git a/app/dashboard/ActiveCard.tsx b/app/dashboard/ActiveCard.tsx new file mode 100644 index 0000000..4152d49 --- /dev/null +++ b/app/dashboard/ActiveCard.tsx @@ -0,0 +1,22 @@ +'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 ( + + Open + + + Etes-vous sur de vouloir terminer ce test? + Les votations ne seront plus ouverte pour ce test. Vous pouvez cependant le réactiver dans le dashboard. + + + Cancel + setTestActive(1, true)}>Continue + + + + ); +} diff --git a/app/dashboard/page.tsx b/app/dashboard/page.tsx new file mode 100644 index 0000000..7cf6c54 --- /dev/null +++ b/app/dashboard/page.tsx @@ -0,0 +1,25 @@ +import prisma from '@/lib/prisma'; +import ActiveCard from './ActiveCard'; + +export default async function Dashboard() { + const tests = await prisma.test.findMany({ select: { isActive: true, isPassed: true, id: true, testOf: { select: { id: true, firstName: true, lastName: true, isTeacher: true } } } }); + + const activeTests = tests.filter((test) => test.isActive); + const passedTests = tests.filter((test) => test.isPassed); + + return ( +
+

Dashboard

+
+

Test(s) Actif(s) :

+ +
+
+ ); +}