From b7af6fcdb8e778a479040fec3fdc28f0f889444f Mon Sep 17 00:00:00 2001 From: amjed-ali-k Date: Sat, 28 Oct 2023 22:10:18 +0530 Subject: [PATCH] clean: removed exam hall listing and page --- .../secure/exam-seating/exams/all/route.ts | 17 -- .../exam/_components/ExamListTable.tsx | 218 ------------------ .../{new => }/_components/NewExamForm.tsx | 2 +- .../exam/{new => }/_components/PDFgen.tsx | 2 +- .../tools/exam-seating/exam/new/page.tsx | 19 -- .../tools/exam-seating/exam/page.tsx | 29 +-- src/components/Navigation.tsx | 6 +- 7 files changed, 10 insertions(+), 283 deletions(-) delete mode 100644 src/app/api/secure/exam-seating/exams/all/route.ts delete mode 100644 src/app/dashboard/tools/exam-seating/exam/_components/ExamListTable.tsx rename src/app/dashboard/tools/exam-seating/exam/{new => }/_components/NewExamForm.tsx (99%) rename src/app/dashboard/tools/exam-seating/exam/{new => }/_components/PDFgen.tsx (99%) delete mode 100644 src/app/dashboard/tools/exam-seating/exam/new/page.tsx diff --git a/src/app/api/secure/exam-seating/exams/all/route.ts b/src/app/api/secure/exam-seating/exams/all/route.ts deleted file mode 100644 index 585f1f2..0000000 --- a/src/app/api/secure/exam-seating/exams/all/route.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { NextRequest, NextResponse } from "next/server"; -import { prisma } from "@/server/db/prisma"; -import { getUserId } from "@/components/auth/server"; - -export async function GET(request: NextRequest) { - const userId = await getUserId(request); - if (!userId) - return NextResponse.json({ message: "Unauthenticated" }, { status: 401 }); - - const results = await prisma.examsForSeatingArrangement.findMany({ - where: { - createdById: userId, - }, - }); - - return NextResponse.json(results); -} diff --git a/src/app/dashboard/tools/exam-seating/exam/_components/ExamListTable.tsx b/src/app/dashboard/tools/exam-seating/exam/_components/ExamListTable.tsx deleted file mode 100644 index f21815c..0000000 --- a/src/app/dashboard/tools/exam-seating/exam/_components/ExamListTable.tsx +++ /dev/null @@ -1,218 +0,0 @@ -"use client"; - -import * as React from "react"; -import dayjs from "dayjs"; - -import { CaretSortIcon, DotsHorizontalIcon } from "@radix-ui/react-icons"; -import { - ColumnDef, - SortingState, - flexRender, - getCoreRowModel, - getPaginationRowModel, - getSortedRowModel, - useReactTable, -} from "@tanstack/react-table"; -import { Button } from "@/components/ui/button"; -import { - DropdownMenu, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuLabel, - DropdownMenuTrigger, -} from "@/components/ui/dropdown-menu"; -import { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, -} from "@/components/ui/table"; -import { useGet } from "@/lib/swr"; -import axios from "axios"; -import { mutate } from "swr"; -import { Skeleton } from "@/components/ui/skeleton"; -import { ExamsForSeatingArrangement } from "@prisma/client"; - -export const columns: ColumnDef[] = [ - { - accessorKey: "name", - header: "Exam Name", - }, - { - accessorKey: "createdAt", - header: ({ column }) => { - return ( - - ); - }, - cell: (value) => ( -
- {dayjs(value.getValue() as string).format("DD-MM-YY hh:mm A")} -
- ), - }, - { - accessorKey: "date", - header: "Date", - }, - - { - id: "id", - enableHiding: false, - cell: ({ row }) => { - return ( - - - - - - Actions - Edit - - axios - .delete("/api/secure/exam-seating/exams", { - data: { - id: row.original.id, - }, - }) - .then(() => { - mutate("/api/secure/exam-seating/exams/all"); - }) - } - > - Delete - - {/* */} - - - ); - }, - }, -]; - -export function ExamListTable() { - const { data: apiData, isLoading } = useGet( - "/api/secure/exam-seating/exams/all" - ); - - const data = React.useMemo(() => { - return apiData ?? []; - }, [apiData]) as ExamsForSeatingArrangement[]; - - const [sorting, setSorting] = React.useState([]); - const [rowSelection, setRowSelection] = React.useState({}); - const table = useReactTable({ - data, - columns, - onSortingChange: setSorting, - getCoreRowModel: getCoreRowModel(), - getPaginationRowModel: getPaginationRowModel(), - getSortedRowModel: getSortedRowModel(), - onRowSelectionChange: setRowSelection, - state: { - sorting, - rowSelection, - }, - }); - - return ( -
-
- - - {table.getHeaderGroups().map((headerGroup) => ( - - {headerGroup.headers.map((header) => { - return ( - - {header.isPlaceholder - ? null - : flexRender( - header.column.columnDef.header, - header.getContext() - )} - - ); - })} - - ))} - - - {isLoading ? ( - - - - - - - - - ) : table.getRowModel().rows?.length > 0 ? ( - table.getRowModel().rows.map((row) => ( - - {row.getVisibleCells().map((cell) => ( - - {flexRender( - cell.column.columnDef.cell, - cell.getContext() - )} - - ))} - - )) - ) : ( - - - No results. - - - )} - -
-
-
-
- {table.getFilteredSelectedRowModel().rows.length} of{" "} - {table.getFilteredRowModel().rows.length} row(s) selected. -
-
- - -
-
-
- ); -} diff --git a/src/app/dashboard/tools/exam-seating/exam/new/_components/NewExamForm.tsx b/src/app/dashboard/tools/exam-seating/exam/_components/NewExamForm.tsx similarity index 99% rename from src/app/dashboard/tools/exam-seating/exam/new/_components/NewExamForm.tsx rename to src/app/dashboard/tools/exam-seating/exam/_components/NewExamForm.tsx index 650d45d..0c1e52c 100644 --- a/src/app/dashboard/tools/exam-seating/exam/new/_components/NewExamForm.tsx +++ b/src/app/dashboard/tools/exam-seating/exam/_components/NewExamForm.tsx @@ -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 "../../new-class/_components/newClass"; import { GenerateAttendanceSheet, GenerateHallsAssignment, diff --git a/src/app/dashboard/tools/exam-seating/exam/new/_components/PDFgen.tsx b/src/app/dashboard/tools/exam-seating/exam/_components/PDFgen.tsx similarity index 99% rename from src/app/dashboard/tools/exam-seating/exam/new/_components/PDFgen.tsx rename to src/app/dashboard/tools/exam-seating/exam/_components/PDFgen.tsx index 17f430d..d8785b2 100644 --- a/src/app/dashboard/tools/exam-seating/exam/new/_components/PDFgen.tsx +++ b/src/app/dashboard/tools/exam-seating/exam/_components/PDFgen.tsx @@ -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 "../../new-class/_components/newClass"; import { AllocatedSeat } from "@/lib/examTools/hallSort"; import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; diff --git a/src/app/dashboard/tools/exam-seating/exam/new/page.tsx b/src/app/dashboard/tools/exam-seating/exam/new/page.tsx deleted file mode 100644 index 31a2531..0000000 --- a/src/app/dashboard/tools/exam-seating/exam/new/page.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import React from "react"; -import NewExamForm from "./_components/NewExamForm"; - -async function page() { - return ( -
-
-

- Add new exam -

-
-
- -
-
- ); -} - -export default page; diff --git a/src/app/dashboard/tools/exam-seating/exam/page.tsx b/src/app/dashboard/tools/exam-seating/exam/page.tsx index 1b53919..f27b35c 100644 --- a/src/app/dashboard/tools/exam-seating/exam/page.tsx +++ b/src/app/dashboard/tools/exam-seating/exam/page.tsx @@ -1,35 +1,16 @@ import React from "react"; -import { Button } from "@/components/ui/button"; -import { Plus } from "lucide-react"; -import Link from "next/link"; -import { ExamListTable } from "./_components/ExamListTable"; +import NewExamForm from "./_components/NewExamForm"; async function page() { return ( -
+
-

- Add Exams +

+ Generate Exam Seating Plan

-

- Here you can see the list of{" "} - - exams and seat plans - {" "} - you created. You can create a new exam along with seat arrangement by - clicking Add new exam button. -

-
- - - -
- +
); diff --git a/src/components/Navigation.tsx b/src/components/Navigation.tsx index becac98..c2c947d 100644 --- a/src/components/Navigation.tsx +++ b/src/components/Navigation.tsx @@ -190,15 +190,15 @@ export function NavBar() { Student directory and their batches - Create seating arrangements for each exams + Generate printable seating arrangements and files for exam