Skip to content

Commit

Permalink
feat: aded update option to batch
Browse files Browse the repository at this point in the history
  • Loading branch information
amjed-ali-k committed Oct 28, 2023
1 parent c9f39e3 commit 0d95796
Show file tree
Hide file tree
Showing 10 changed files with 776 additions and 4 deletions.
17 changes: 17 additions & 0 deletions src/app/api/secure/exam-seating/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,23 @@ export async function PUT(request: NextRequest) {
);
}

const hall = await prisma.examHall.findUnique({
where: {
id: body.data.id,
},
});

if (!hall) {
return NextResponse.json({ message: "Hall not found" }, { status: 404 });
}

if (hall.createdById !== userId) {
return NextResponse.json(
{ message: "You are not authorized to update this hall" },
{ status: 401 }
);
}

const results = await prisma.examHall.update({
where: {
id: body.data.id,
Expand Down
15 changes: 15 additions & 0 deletions src/app/api/secure/exam-seating/student-batches/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,21 @@ export async function PUT(request: NextRequest) {
);
}

const batch = await prisma.studentBatchForExam.findUnique({
where: {
id: body.data.id,
},
});

if (!batch)
return NextResponse.json({ message: "Invalid request" }, { status: 400 });

if (batch.createdById !== userId)
return NextResponse.json(
{ message: "You are not authorized to update this batch" },
{ status: 401 }
);

const results = await prisma.studentBatchForExam.update({
where: {
id: body.data.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { sum, flat, group, sift } from "radash";
import { assignHallsCustom } from "@/lib/examTools/customHallAsiign";
import { AllocatedSeat, allocateSeats } from "@/lib/examTools/hallSort";
import { SeatObjectType } from "../../new-class/_components/newClass";
import { SeatObjectType } from "../../hall/new/_components/newClass";
import {
GenerateAttendanceSheet,
GenerateHallsAssignment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import { ArrangedResult } from "./NewExamForm";
import React, { useMemo } from "react";
import { group, max } from "radash";
import { SeatType } from "../../new-class/_components/newClass";
import { SeatType } from "../../hall/new/_components/newClass";
import { AllocatedSeat } from "@/lib/examTools/hallSort";
import { useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
Expand Down
Loading

0 comments on commit 0d95796

Please sign in to comment.