diff --git a/.env.example b/.env.example index 9299295..c736e24 100644 --- a/.env.example +++ b/.env.example @@ -1 +1,3 @@ DATABASE_URL='mysql://root:root@mydb.com/calendrier' +NEXTAUTH_SECRET=supersecret +NEXTAUTH_URL=http://localhost:3000 \ No newline at end of file diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 7d4949e..667c91a 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -75,7 +75,7 @@ jobs: id: build-and-push uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0 env: - DATABASE_URL: ${{ secrets.DATABASE_URL }} + NEXT_TELEMETRY_DISABLED: 1 with: context: . push: ${{ github.event_name != 'pull_request' }} diff --git a/actions/grades.ts b/actions/grades.ts index 4d1f057..699fcf2 100644 --- a/actions/grades.ts +++ b/actions/grades.ts @@ -2,24 +2,7 @@ import prisma from "@/lib/prisma"; -export async function getGrade(testId: number, userId: number) { - const grade = await prisma.grade.findFirst({ - select: { - grade: true, - id: true, - testId: true, - createdAt: true, - }, - where: { - testId: testId, - userId: userId - } - }); - - return grade; -} - -export async function addGrade(testId: number, userId: number, grade: number, note: string | null) { +export async function addGrade(testId: number, userId: number, grade: number) { const newGrade = await prisma.grade.create({ data: { grade: grade, diff --git a/actions/mangeTest.ts b/actions/mangeTest.ts index ddc82db..cd64132 100644 --- a/actions/mangeTest.ts +++ b/actions/mangeTest.ts @@ -2,6 +2,7 @@ import prisma from "@/lib/prisma"; +// Only a test function export async function setTestActive(id: number, active: boolean) { const users = await prisma.users.findFirst(); @@ -11,7 +12,7 @@ export async function setTestActive(id: number, active: boolean) { } -export async function getActiveTest(date: Date) { +export async function getFirstActiveTest(date: Date) { return await prisma.test.findFirst({ select: { id: true, @@ -34,7 +35,7 @@ export async function getActiveTest(date: Date) { }); } -export async function getActiveTestWithGrade(date: Date, userId: number) { +export async function getFirstActiveTestWithGrade(date: Date, userId: number) { return await prisma.test.findFirst({ select: { id: true, diff --git a/actions/results.ts b/actions/results.ts index cd42c1d..b333c64 100644 --- a/actions/results.ts +++ b/actions/results.ts @@ -6,7 +6,7 @@ export interface Results { total: number; } -export async function getResults(testId: number) { +export async function getStudentResults(testId: number) { const grades = await prisma.grade.findMany({ where: { testId: testId, user: { isTeacher: false } } }); const allGrades = ['1', '1.5', '2', '2.5', '3', '3.5', '4', '4.5', '5', '5.5', '6']; diff --git a/app/page.tsx b/app/page.tsx index 05ac1f5..c1a6672 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,4 +1,4 @@ -import logo from '../images/logo.svg'; +import logo from '@/assets/images/logo.svg'; import Image from 'next/image'; import { LoginForm } from '@/components/forms/LoginForm'; import { getAuthServerSession } from '@/lib/authenticate'; diff --git a/app/play/TodayTest.tsx b/app/play/TodayTest.tsx index af33660..8f2eece 100644 --- a/app/play/TodayTest.tsx +++ b/app/play/TodayTest.tsx @@ -1,6 +1,6 @@ 'use client'; -import { getActiveTestWithGrade } from '@/actions/mangeTest'; +import { getFirstActiveTestWithGrade } from '@/actions/mangeTest'; import { TestCard } from '@/components/custom'; import { Session } from 'next-auth'; import { signOut } from 'next-auth/react'; @@ -14,7 +14,7 @@ export function TodayTest({ session }: { session: Session }) { const [activeTest, setActiveTest] = useState<{ data: any | null; error: Error | null; isLoading: boolean }>({ isLoading: true, data: null, error: null }); useEffect(() => { - getActiveTestWithGrade(new Date(), session.user.id) + getFirstActiveTestWithGrade(new Date(), session.user.id) .catch((err) => setActiveTest({ data: null, error: err, isLoading: false })) .then((data) => setActiveTest({ data, error: null, isLoading: false })); }, [session.user.id]); diff --git a/app/play/page.tsx b/app/play/page.tsx index 00cabc9..22cfb17 100644 --- a/app/play/page.tsx +++ b/app/play/page.tsx @@ -1,8 +1,8 @@ import Image from 'next/image'; -import Logo from '/images/logo.svg'; +import Logo from '@images/logo.svg'; import { getAuthServerSession } from '@/lib/authenticate'; import { redirect } from 'next/navigation'; -import { getActiveTest } from '@/actions/mangeTest'; +import { getFirstActiveTest } from '@/actions/mangeTest'; import { TodayTest } from './TodayTest'; export default async function Play() { @@ -12,24 +12,10 @@ export default async function Play() { redirect('/'); } - const now = new Date(); - const todayTest = await getActiveTest(now); - return (