Skip to content

Commit

Permalink
focus
Browse files Browse the repository at this point in the history
  • Loading branch information
iprime2 committed Oct 17, 2024
1 parent c08fd73 commit 5ae25dc
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 48 deletions.
4 changes: 2 additions & 2 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Visitors" ALTER COLUMN "query" DROP NOT NULL;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Visitors" ALTER COLUMN "attendedBy" DROP NOT NULL;
4 changes: 2 additions & 2 deletions backend/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 8 additions & 6 deletions backend/src/modules/visitors/dto/create-visitor.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
14 changes: 7 additions & 7 deletions backend/src/modules/visitors/visitors.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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: '',
Expand All @@ -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: '',
Expand Down
22 changes: 14 additions & 8 deletions frontend/app/(admin)/admin/layout.tsx
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -7,14 +9,18 @@ export default function AdminLayout({
children: React.ReactNode;
}>) {
return (
<div className="flex w-full h-screen">
<div className="hidden h-full md:flex md:w-60 md:flex-col md:fixed md:inset-y-0">
<Sidebar />
<>
<FeedbackModal />
<FileUploadModal />
<div className="flex w-full h-screen">
<div className="hidden h-full md:flex md:w-60 md:flex-col md:fixed md:inset-y-0">
<Sidebar />
</div>
<main className="w-full md:pl-60">
<Navbar type="admin" />
{children}
</main>
</div>
<main className="w-full md:pl-60">
<Navbar type="admin" />
{children}
</main>
</div>
</>
);
}
10 changes: 5 additions & 5 deletions frontend/app/(public)/(visitorform)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 0 additions & 4 deletions frontend/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -27,8 +25,6 @@ export default function RootLayout({
<html lang="en">
<Provider>
<Toaster />
<FeedbackModal />
<FileUploadModal />
<body className={roboto.className}>{children}</body>
</Provider>
</html>
Expand Down
27 changes: 13 additions & 14 deletions frontend/components/EntryForm.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -56,11 +56,7 @@ const EntryForm: FC<EntryFormPropsType> = ({ attendees, type }) => {
const feedbackModal = useFeedbackModal();
const [mounted, setMounted] = useState<boolean>(false);
const [visitorType, setVisitorType] = useState<string | null>(null);

useEffect(() => {
setMounted(true);
}, []);


const form = useForm<VisitorsFormValues>({
resolver: zodResolver(visitorFormSchema),
defaultValues: {
Expand All @@ -72,6 +68,15 @@ const EntryForm: FC<EntryFormPropsType> = ({ attendees, type }) => {
},
});

const { setFocus } = form;

useEffect(() => {
setMounted(true);
setFocus("visitorPrn");
}, [setFocus]);



if (!mounted) {
return null;
}
Expand Down Expand Up @@ -188,14 +193,13 @@ const EntryForm: FC<EntryFormPropsType> = ({ attendees, type }) => {
</Button>
</div>
</div>
{visitorType ? (
<Form {...form}>
<form
onSubmit={form.handleSubmit(onSubmit)}
className="w-full h-auto flex flex-col gap-4"
>
<div className="sm:flex sm:flex-col md:grid md:grid-cols-2 md:gap-2">
{visitorType === "studentEmployee" && (
{true && (
<FormField
// className="transition-all duration-100 ease-in-out"
control={form.control}
Expand All @@ -205,9 +209,9 @@ const EntryForm: FC<EntryFormPropsType> = ({ attendees, type }) => {
<FormLabel>Student PRN/ Employee ID</FormLabel>
<FormControl>
<Input
className="focus"
disabled={loading}
placeholder={"Enter Student PRN number / Employee ID"}
tabIndex={0}
{...field}
/>
</FormControl>
Expand Down Expand Up @@ -350,11 +354,6 @@ const EntryForm: FC<EntryFormPropsType> = ({ attendees, type }) => {
</div>
</form>
</Form>
) : (
<h2 className="sm:text-lg md:text-2xl mt-20 flex w-full item-center justify-center from-neutral-600">
Please choose the type of visitor.
</h2>
)}
</div>
);
};
Expand Down

0 comments on commit 5ae25dc

Please sign in to comment.