1
0
mirror of https://github.com/Fayorg/calendrier-avant.git synced 2026-05-27 17:18:38 +02:00

added michal's styles to the results page

This commit is contained in:
timhaller
2023-12-10 12:26:10 +01:00
parent bf49b94a03
commit 4157269251
28 changed files with 1099 additions and 338 deletions

View File

@@ -1,4 +1,4 @@
import {NextResponse} from "next/server";
import {NextRequest, NextResponse} from "next/server";
import prisma from "@/lib/prisma";
interface IBody {
@@ -80,5 +80,14 @@ export async function POST(req: Request){
createdAt: grade.createdAt
}
});
return NextResponse.json({message: 'Server error'}, {status: 500})
}
export async function GET(req: NextRequest){
const key = req.nextUrl.searchParams.get("key");
if(!key) return NextResponse.json({error: "No key provided"}, {status: 400});
const grades = await prisma.grade.findMany({})
return NextResponse.json(grades, {status: 200});
}

View File

@@ -5,6 +5,9 @@ import { useRouter } from 'next/navigation';
import { useState, useEffect } from 'react';
import useSWR from 'swr';
import { fetcher } from '@/lib/fetcher';
import Image from "next/image";
import Logo from "/images/logo.svg";
import LogOut from "@images/logout.svg";
export default function Play() {
const router = useRouter();
@@ -21,19 +24,19 @@ export default function Play() {
}, [router]);
return (
<div>
<h1>Calendrier-avant</h1>
<div className={"w-full h-[100vh] text-[#F0F0F0] bg-black p-12 flex flex-col items-center justify-center gap-y-28"}>
<Image src={Logo} alt={"Logo"} width={100} height={200} className={"mx-auto w-full md:w-[400px]"}/>
<TestCard data={data} error={error} isLoading={isLoading} />
{data && console.log(data)}
{data && data.status == 200 && password && <GradingForm password={password} data={data} />}
<div>
<button
onClick={(e) => {
onClick={() => {
localStorage.clear();
router.push('/');
}}
>
Se déconnecter
<Image src={LogOut} alt={"Logo"} width={100} height={200} className={"mx-auto w-full md:w-[400px]"}/>
</button>
</div>
</div>

View File

@@ -1,6 +1,7 @@
"use server";
import {Chart} from "@components/custom/chart";
import logo from "@images/logo.svg";
import Image from "next/image";
import Prisma from '@lib/prisma'
interface data {
@@ -9,12 +10,8 @@ interface data {
}
export default async function Page({ params }: { params: { id: string } }) {
const grades = await Prisma.grade.findMany({
where: {
testId: parseInt(params.id)
}
})
const grades = await Prisma.grade.findMany({ where: { testId: parseInt(params.id) }})
const allGrades = ['1', '1.5', '2', '2.5', '3', '3.5', '4', '4.5', '5', '5.5', '6']
let gradeOccurences = new Array(allGrades.length).fill(0)
const gradeList = grades.map((grade) => grade.grade)
@@ -35,7 +32,11 @@ export default async function Page({ params }: { params: { id: string } }) {
console.log(grade);
}
return <div>
<Chart data={data}/>
</div>
return (
<div className={"p-4 md:p-12 w-full h-screen bg-black"}>
<Image src={logo} alt={"Logo"} width={100} height={200} className={"mx-auto w-full md:w-[400px]"}/>
<Chart data={data}/>
</div>
)
}