-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: useForm and enable academic year selection
- Loading branch information
Showing
4 changed files
with
80 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,28 @@ | ||
import { auth } from "@/auth"; | ||
import { getAcademicYear } from "@/lib/config"; | ||
import { Stack, Title } from "@mantine/core"; | ||
import { redirect } from "next/navigation"; | ||
import React from "react"; | ||
|
||
import { UserSearch } from "./UserSearch"; | ||
import { getAcademicYearsInDB } from "@/lib/crud/academic-year"; | ||
|
||
export default async function Index() { | ||
const session = await auth(); | ||
|
||
if (!session) redirect("/auth/login"); | ||
|
||
// Get academic years | ||
const currentAcademicYear = await getAcademicYear(); | ||
const academicYears = await getAcademicYearsInDB(); | ||
|
||
return ( | ||
<Stack gap="lg"> | ||
<Title order={1}>DoCSoc Collection System</Title> | ||
<UserSearch /> | ||
<UserSearch | ||
currentAcademicYear={currentAcademicYear} | ||
validAcaemicYears={academicYears} | ||
/> | ||
</Stack> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
"use server"; | ||
|
||
import prisma from "../db"; | ||
|
||
export async function getAcademicYearsInDB() { | ||
return (await prisma.academicYear.findMany()).map((year) => year.year); | ||
} |