diff --git a/backend/package.json b/backend/package.json index 9e1e255..1ce2485 100644 --- a/backend/package.json +++ b/backend/package.json @@ -30,7 +30,7 @@ "@nestjs/mapped-types": "^2.0.5", "@nestjs/passport": "^10.0.3", "@nestjs/platform-express": "^10.4.4", - "@prisma/client": "^5.20.0", + "@prisma/client": "^5.21.0", "bcrypt": "^5.1.1", "bcryptjs": "^2.4.3", "class-transformer": "^0.5.1", @@ -41,7 +41,6 @@ "node-cron": "^3.0.3", "passport": "^0.7.0", "passport-jwt": "^4.0.1", - "prisma": "^5.20.0", "reflect-metadata": "^0.2.0", "rxjs": "^7.8.1", "xlsx": "^0.18.5" @@ -66,6 +65,7 @@ "eslint-plugin-prettier": "^5.0.0", "jest": "^29.5.0", "prettier": "^3.0.0", + "prisma": "^5.21.0", "source-map-support": "^0.5.21", "supertest": "^7.0.0", "ts-jest": "^29.1.0", diff --git a/backend/prisma/migrations/20241017111836_query_null/migration.sql b/backend/prisma/migrations/20241017111836_query_null/migration.sql new file mode 100644 index 0000000..90c1f94 --- /dev/null +++ b/backend/prisma/migrations/20241017111836_query_null/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "Visitors" ALTER COLUMN "query" DROP NOT NULL; diff --git a/backend/prisma/migrations/20241017113127_attended_by_null/migration.sql b/backend/prisma/migrations/20241017113127_attended_by_null/migration.sql new file mode 100644 index 0000000..70d22ea --- /dev/null +++ b/backend/prisma/migrations/20241017113127_attended_by_null/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "Visitors" ALTER COLUMN "attendedBy" DROP NOT NULL; diff --git a/backend/prisma/schema.prisma b/backend/prisma/schema.prisma index bf7a4f0..e17a7c5 100644 --- a/backend/prisma/schema.prisma +++ b/backend/prisma/schema.prisma @@ -54,10 +54,10 @@ model Visitors { visitorPrn String? mobile String type String - attendedBy String + attendedBy String? attendeeId String attendee Attendee @relation("visitorToAttendee", fields: [attendeeId], references: [id]) - query String + query String? status String @default("open") remark String? in Boolean @default(true) diff --git a/backend/src/modules/visitors/dto/create-visitor.dto.ts b/backend/src/modules/visitors/dto/create-visitor.dto.ts index fbf41da..c1eb8cb 100644 --- a/backend/src/modules/visitors/dto/create-visitor.dto.ts +++ b/backend/src/modules/visitors/dto/create-visitor.dto.ts @@ -12,12 +12,14 @@ export class CreateVisitorDto { @IsString() @IsOptional() mobile?: string; - + @IsString() - @IsNotEmpty() - attendeeId: string; - + @IsOptional() + // @IsNotEmpty() + attendeeId?: string; + @IsString() - @IsNotEmpty() - query: string; + @IsOptional() + // @IsNotEmpty() + query?: string; } diff --git a/backend/src/modules/visitors/visitors.service.ts b/backend/src/modules/visitors/visitors.service.ts index d46bb40..7fd007a 100644 --- a/backend/src/modules/visitors/visitors.service.ts +++ b/backend/src/modules/visitors/visitors.service.ts @@ -12,9 +12,9 @@ export class VisitorsService { const attendee = await this.prisma.attendee.findUnique({where:{id:attendeeId}}); - if(!attendee){ - throw new BadRequestException("Attendee doesn't exists"); - } + // if(!attendee){ + // throw new BadRequestException("Attendee doesn't exists"); + // } // Check if the visitor is already checked in using PRN if (visitorPrn) { @@ -37,8 +37,8 @@ export class VisitorsService { visitorName: member.name, mobile: member.mobile, type: member.type, - attendedBy: attendee.name, - attendeeId: attendeeId, + attendedBy: attendee?.name || "NAN", + attendeeId: attendeeId || "", query, status: 'open', remark: '', @@ -54,8 +54,8 @@ export class VisitorsService { visitorName, mobile: mobile || "", type: 'visitor', - attendedBy: attendee.name, - attendeeId: attendeeId, + attendedBy: attendee?.name || "NAN", + attendeeId: attendeeId || "", query, status: 'open', remark: '', diff --git a/frontend/app/(admin)/admin/layout.tsx b/frontend/app/(admin)/admin/layout.tsx index 2946a20..c4eb9b9 100644 --- a/frontend/app/(admin)/admin/layout.tsx +++ b/frontend/app/(admin)/admin/layout.tsx @@ -1,3 +1,5 @@ +import FeedbackModal from "@/components/modal/FeedbackModal"; +import FileUploadModal from "@/components/modal/FileUploadModal"; import Navbar from "@/components/Navbar"; import Sidebar from "@/components/Sidebar"; @@ -7,14 +9,18 @@ export default function AdminLayout({ children: React.ReactNode; }>) { return ( -
-
- + <> + + +
+
+ +
+
+ + {children} +
-
- - {children} -
-
+ ); } diff --git a/frontend/app/(public)/(visitorform)/page.tsx b/frontend/app/(public)/(visitorform)/page.tsx index 60b75a4..05c3d72 100644 --- a/frontend/app/(public)/(visitorform)/page.tsx +++ b/frontend/app/(public)/(visitorform)/page.tsx @@ -20,11 +20,11 @@ const VisitorsPage = async () => { const response = await axiosInstance.get("/attendees"); if (response.status === 200) { setAttendees(response.data); - toast({ - title: "Success!", - description: "Attendees data fetched!", - variant: "success", - }); + // toast({ + // title: "Success!", + // description: "Attendees data fetched!", + // variant: "success", + // }); } } catch (error: any) { if (error?.response?.data) { diff --git a/frontend/app/layout.tsx b/frontend/app/layout.tsx index 535812e..60c6cab 100644 --- a/frontend/app/layout.tsx +++ b/frontend/app/layout.tsx @@ -5,8 +5,6 @@ import cron from "node-cron"; import "./globals.css"; import { Toaster } from "@/components/ui/toaster"; import Provider from "@/providers/Provider"; -import FeedbackModal from "@/components/modal/FeedbackModal"; -import FileUploadModal from "@/components/modal/FileUploadModal"; const roboto = Roboto({ weight: "400", @@ -27,8 +25,6 @@ export default function RootLayout({ - - {children} diff --git a/frontend/components/EntryForm.tsx b/frontend/components/EntryForm.tsx index f9560a1..a606d03 100644 --- a/frontend/components/EntryForm.tsx +++ b/frontend/components/EntryForm.tsx @@ -1,6 +1,6 @@ "use client"; -import React, { FC, ReactNode, useEffect, useState } from "react"; +import React, { FC, ReactNode, useEffect, useRef, useState } from "react"; import * as z from "zod"; import { zodResolver } from "@hookform/resolvers/zod"; import { useForm } from "react-hook-form"; @@ -56,11 +56,7 @@ const EntryForm: FC = ({ attendees, type }) => { const feedbackModal = useFeedbackModal(); const [mounted, setMounted] = useState(false); const [visitorType, setVisitorType] = useState(null); - - useEffect(() => { - setMounted(true); - }, []); - + const form = useForm({ resolver: zodResolver(visitorFormSchema), defaultValues: { @@ -72,6 +68,15 @@ const EntryForm: FC = ({ attendees, type }) => { }, }); + const { setFocus } = form; + + useEffect(() => { + setMounted(true); + setFocus("visitorPrn"); + }, [setFocus]); + + + if (!mounted) { return null; } @@ -188,14 +193,13 @@ const EntryForm: FC = ({ attendees, type }) => {
- {visitorType ? (
- {visitorType === "studentEmployee" && ( + {true && ( = ({ attendees, type }) => { Student PRN/ Employee ID @@ -350,11 +354,6 @@ const EntryForm: FC = ({ attendees, type }) => {
- ) : ( -

- Please choose the type of visitor. -

- )} ); };