Skip to content

Commit

Permalink
Day Scholar
Browse files Browse the repository at this point in the history
  • Loading branch information
Abh1noob committed Mar 16, 2024
1 parent 55512ba commit 63937ba
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
4 changes: 2 additions & 2 deletions devsoc24-portal-fe/src/app/profile/profile-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ interface SubmitProjectResponse {

import send from "@/assets/images/Send.svg";
import Image from "next/image";
import { useEffect } from "react";
import { useEffect, useState } from "react";
import { useRouter } from "next/navigation";
export default function Profile() {
const router = useRouter();
Expand Down Expand Up @@ -122,7 +122,7 @@ export default function Profile() {
<Form {...form}>
<form
onSubmit={form.handleSubmit(onSubmit)}
className="rounded-lg bg-white p-4 w-fit"
className="w-fit rounded-lg bg-white p-4"
>
<div className="flex justify-start gap-16 max-[931px]:flex-col max-[931px]:gap-6">
<div className="flex w-96 flex-col gap-6 max-[445px]:w-[87vw]">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import countries from "@/../public/countries.json";
import { personalDetailsSchema } from "@/schemas/signup";
import { personalDetailsSchema, vitianDetails } from "@/schemas/signup";
import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form";
import { type z } from "zod";
Expand Down Expand Up @@ -50,6 +50,8 @@ export default function PersonalDetails({
shouldUnregister: false,
});



useEffect(() => {
form.setValue("firstName", localStorage.getItem("first_name") ?? "");
form.setValue("lastName", localStorage.getItem("last_name") ?? "");
Expand Down
24 changes: 22 additions & 2 deletions devsoc24-portal-fe/src/components/forms/vitian-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ export default function VitianForm({
setGender(temp!);
}, []);

const [day, setDay] = useState(false);

// useEffect(() => {
// if (vitianForm.getValues("block") === "Day Scholar") {
// setDay(true);
// } else {
// setDay(false);
// }
// }, [vitianForm.getValues("block")]);

return (
<>
<ToastContainer />
Expand Down Expand Up @@ -170,7 +180,16 @@ export default function VitianForm({
<FormControl>
<div className="relative">
<Select
onValueChange={field.onChange}
onValueChange={(e) => {
field.onChange(e);
console.log(e);
if (e === "Day Scholar") {
vitianForm.setValue("roomNumber", "0");
setDay(true);
} else {
setDay(false);
}
}}
defaultValue={field.value}
>
<FormControl>
Expand Down Expand Up @@ -228,7 +247,8 @@ export default function VitianForm({
type="text"
placeholder="Room Number"
{...field}
// Value
disabled={day}
value={day ? "-" : field.value}
className={` ${
vitianForm.getFieldState("roomNumber").invalid
? "border-red-500 focus:border-input focus:!ring-red-500"
Expand Down

0 comments on commit 63937ba

Please sign in to comment.