Updated the assignments active filter to work with the startDate

This commit is contained in:
Tiago Ribeiro
2024-11-07 12:08:28 +00:00
parent 0325bb68f5
commit fae7b729fe
3 changed files with 64 additions and 52 deletions

View File

@@ -18,26 +18,39 @@ import ExamEditor from "@/components/ExamEditor";
import MultipleAudioUploader from "@/components/ExamEditor/Shared/AudioEdit";
import { redirect, serialize } from "@/utils";
import { requestUser } from "@/utils/api";
import { Module } from "@/interfaces";
import { getExam, getExams } from "@/utils/exams.be";
import { Exam } from "@/interfaces/exam";
import { useEffect } from "react";
export const getServerSideProps = withIronSessionSsr(async ({req, res}) => {
export const getServerSideProps = withIronSessionSsr(async ({ req, res, query }) => {
const user = await requestUser(req, res)
if (!user) return redirect("/login")
if (shouldRedirectHome(user) || !checkAccess(user, ["admin", "mastercorporate", "developer", "corporate"]))
return redirect("/")
const { id, module } = query as { id?: string, module?: Module }
if (!id || !module) return { props: serialize({ user }) };
const exam = await getExam(module, id)
if (!exam) return redirect("/generation")
return {
props: serialize({user}),
props: serialize({ user, exam }),
};
}, sessionOptions);
export default function Generation({ user }: { user: User; }) {
export default function Generation({ user, exam }: { user: User; exam?: Exam }) {
const { title, currentModule, dispatch } = useExamEditorStore();
const updateRoot = (updates: Partial<ExamEditorStore>) => {
dispatch({ type: 'UPDATE_ROOT', payload: { updates } });
};
dispatch({ type: 'UPDATE_ROOT', payload: { updates } });
};
useEffect(() => {
if (exam) { }
}, [exam])
return (
<>
@@ -60,7 +73,7 @@ export default function Generation({ user }: { user: User; }) {
placeholder="Insert a title here"
name="title"
label="Title"
onChange={(title) => updateRoot({title})}
onChange={(title) => updateRoot({ title })}
roundness="xl"
defaultValue={title}
required
@@ -69,7 +82,7 @@ export default function Generation({ user }: { user: User; }) {
<label className="font-normal text-base text-mti-gray-dim">Module</label>
<RadioGroup
value={currentModule}
onChange={(currentModule) => updateRoot({currentModule})}
onChange={(currentModule) => updateRoot({ currentModule })}
className="flex flex-row -2xl:flex-wrap w-full gap-4 -md:justify-center justify-between">
{[...MODULE_ARRAY].map((x) => (
<Radio value={x} key={x}>