diff --git a/src/components/ExamEditor/SettingsEditor/level.tsx b/src/components/ExamEditor/SettingsEditor/level.tsx index 20c8fd81..376113d3 100644 --- a/src/components/ExamEditor/SettingsEditor/level.tsx +++ b/src/components/ExamEditor/SettingsEditor/level.tsx @@ -215,12 +215,12 @@ const LevelSettings: React.FC = () => { }); const requestBody = await (async () => { - const handledExam = await getExamById("writing", result.data.id); + const handledExam = await getExamById("level", result.data.id); return { examAuthor: handledExam?.createdBy ?? "Unknown Author", examEntities: handledExam?.entities ?? [], examId: handledExam?.id ?? "Unknown ID", - examModule: "writing" + examModule: "level" }; })(); await axios diff --git a/src/components/ExamEditor/SettingsEditor/listening/index.tsx b/src/components/ExamEditor/SettingsEditor/listening/index.tsx index efbdfb6d..182f1d3f 100644 --- a/src/components/ExamEditor/SettingsEditor/listening/index.tsx +++ b/src/components/ExamEditor/SettingsEditor/listening/index.tsx @@ -153,12 +153,12 @@ const ListeningSettings: React.FC = () => { toast.success(`Submitted Exam ID: ${result.data.id}`); const requestBody = await (async () => { - const handledExam = await getExamById("writing", result.data.id); + const handledExam = await getExamById("listening", result.data.id); return { examAuthor: handledExam?.createdBy ?? "Unknown Author", examEntities: handledExam?.entities ?? [], examId: handledExam?.id ?? "Unknown ID", - examModule: "writing" + examModule: "listening" }; })(); await axios diff --git a/src/components/ExamEditor/SettingsEditor/speaking/index.tsx b/src/components/ExamEditor/SettingsEditor/speaking/index.tsx index 0b9570b8..bdd86048 100644 --- a/src/components/ExamEditor/SettingsEditor/speaking/index.tsx +++ b/src/components/ExamEditor/SettingsEditor/speaking/index.tsx @@ -197,12 +197,12 @@ const SpeakingSettings: React.FC = () => { }); const requestBody = await (async () => { - const handledExam = await getExamById("writing", result.data.id); + const handledExam = await getExamById("speaking", result.data.id); return { examAuthor: handledExam?.createdBy ?? "Unknown Author", examEntities: handledExam?.entities ?? [], examId: handledExam?.id ?? "Unknown ID", - examModule: "writing" + examModule: "speaking" }; })(); await axios diff --git a/src/pages/approval-workflows/[id]/index.tsx b/src/pages/approval-workflows/[id]/index.tsx index c4a6bb3e..995c51b3 100644 --- a/src/pages/approval-workflows/[id]/index.tsx +++ b/src/pages/approval-workflows/[id]/index.tsx @@ -334,7 +334,7 @@ export default function Home({ user, initialWorkflow, id, workflowAssignees, wor variant="solid" onClick={handleEditExam} padding="px-6 py-2" - disabled={!currentWorkflow.steps[currentStepIndex].assignees.includes(user.id) || editExamIsLoading} + disabled={(!currentWorkflow.steps[currentStepIndex].assignees.includes(user.id) && user.type !== "admin" && user.type !== "developer") || editExamIsLoading} className="w-[240px] text-lg flex items-center justify-center gap-2 text-left" > {editExamIsLoading ? ( @@ -475,7 +475,7 @@ export default function Home({ user, initialWorkflow, id, workflowAssignees, wor type="submit" color="purple" variant="solid" - disabled={!selectedStep.assignees.includes(user.id) || isLoading} + disabled={(!selectedStep.assignees.includes(user.id) && user.type !== "admin" && user.type !== "developer") || isLoading} onClick={handleApproveStep} padding="px-6 py-2" className="mb-3 w-full text-lg flex items-center justify-center gap-2 text-left" @@ -496,7 +496,7 @@ export default function Home({ user, initialWorkflow, id, workflowAssignees, wor type="submit" color="red" variant="solid" - disabled={!selectedStep.assignees.includes(user.id) || isLoading} + disabled={(!selectedStep.assignees.includes(user.id) && user.type !== "admin" && user.type !== "developer") || isLoading} onClick={handleRejectStep} padding="px-6 py-2" className="mb-3 w-1/2 text-lg flex items-center justify-center gap-2 text-left" diff --git a/src/pages/approval-workflows/create.tsx b/src/pages/approval-workflows/create.tsx index 1e939d0b..afb60b98 100644 --- a/src/pages/approval-workflows/create.tsx +++ b/src/pages/approval-workflows/create.tsx @@ -31,19 +31,27 @@ export const getServerSideProps = withIronSessionSsr(async ({ req, res }) => { const user = await requestUser(req, res) if (!user) return redirect("/login") - if (shouldRedirectHome(user) || !["admin", "developer", "teacher", "corporate", "mastercorporate"].includes(user.type)) + if (shouldRedirectHome(user) || !["admin", "developer", "corporate", "mastercorporate"].includes(user.type)) return redirect("/") const userEntitiesWithLabel = await getEntities(user.entities.map(entity => entity.id)); const allConfiguredWorkflows = await getApprovalWorkflowsByEntities("configured-workflows", userEntitiesWithLabel.map(entity => entity.id)); + const approverTypes = ["teacher", "corporate", "mastercorporate"]; + + if (user.type === "developer") { + approverTypes.push("developer"); + } + + const userEntitiesApprovers = await getEntitiesUsers(userEntitiesWithLabel.map(entity => entity.id), { type: { $in: approverTypes } }) as (TeacherUser | CorporateUser | MasterCorporateUser | DeveloperUser)[]; + return { props: serialize({ user, allConfiguredWorkflows, userEntitiesWithLabel, - userEntitiesApprovers: await getEntitiesUsers(userEntitiesWithLabel.map(entity => entity.id), { type: { $in: ["teacher", "corporate", "mastercorporate", "developer"] } }) as (TeacherUser | CorporateUser | MasterCorporateUser | DeveloperUser)[], + userEntitiesApprovers, }), }; }, sessionOptions); @@ -129,7 +137,7 @@ export default function Home({ user, allConfiguredWorkflows, userEntitiesWithLab for (const step of workflow.steps) { if (step.assignees.every(x => !x)) { toast.warning("There are empty steps in at least one of the configured workflows."); - setIsLoading(false); + setIsLoading(false); return; } } @@ -211,9 +219,9 @@ export default function Home({ user, allConfiguredWorkflows, userEntitiesWithLab const handleCloneWorkflow = (id: string) => { const workflowToClone = workflows.find(wf => wf.id === id); if (!workflowToClone) return; - + const newId = uuidv4(); - + const clonedWorkflow: EditableApprovalWorkflow = { ...workflowToClone, id: newId, @@ -222,7 +230,7 @@ export default function Home({ user, allConfiguredWorkflows, userEntitiesWithLab assignees: step.firstStep ? [null] : [...step.assignees], // we can't have more than one form intaker per teacher per entity })), }; - + setWorkflows(prev => { const updatedWorkflows = [...prev, clonedWorkflow]; setSelectedWorkflowId(newId); @@ -280,7 +288,7 @@ export default function Home({ user, allConfiguredWorkflows, userEntitiesWithLab - +