From 4211faeeee8d58133dfcdb21d3f972b03bde2823 Mon Sep 17 00:00:00 2001 From: kamini08 Date: Fri, 16 Aug 2024 21:37:38 +0530 Subject: [PATCH] set default input values and prevent duplicate data submission --- components/forms/formContext.tsx | 16 ++- components/forms/sihForm.tsx | 193 ++++++++++++++++++++++--------- public/images/sih.png | Bin 0 -> 23584 bytes 3 files changed, 149 insertions(+), 60 deletions(-) create mode 100644 public/images/sih.png diff --git a/components/forms/formContext.tsx b/components/forms/formContext.tsx index 2d72d6b..1dc1975 100644 --- a/components/forms/formContext.tsx +++ b/components/forms/formContext.tsx @@ -10,6 +10,11 @@ interface ITeamInfo { name: string; email: string; phone: string; + role: string; + enrollment_id: string; + course: string; + year_of_study: string; + branch: string; }; } @@ -58,15 +63,20 @@ export const FormProvider: React.FC<{ children: React.ReactNode }> = ({ const [formData, setFormData] = useState({ team_info: { team_name: "", - college_name: "", - team_size: 6, + college_name: "DSCE", + team_size: 5, team_leader: { name: "", email: "", phone: "", + enrollment_id: "", + role: "", + course: "", + year_of_study: "", + branch: "", }, }, - team_members: Array.from({ length: 6 }, () => ({ + team_members: Array.from({ length: 5 }, () => ({ name: "", email: "", phone: "", diff --git a/components/forms/sihForm.tsx b/components/forms/sihForm.tsx index bef5b8c..e4f9de5 100644 --- a/components/forms/sihForm.tsx +++ b/components/forms/sihForm.tsx @@ -16,7 +16,6 @@ import { useRouter } from "next/navigation"; const SIHMultiStepForm: React.FC = () => { const { formData, setFormData } = useFormContext(); const [step, setStep] = useState(1); - formData.team_members.length = formData.team_info.team_size; const [isSuccess, setSuccess] = useState(false); const { register, @@ -89,13 +88,13 @@ const SIHMultiStepForm: React.FC = () => { -

+

Registration Successfull!

You have successfully registered for Smart India Hackathon.

-

+

Join the Whatsapp Group for further updates immediately.

@@ -116,7 +115,7 @@ const SIHMultiStepForm: React.FC = () => {
SIH

SIH Registration Form

@@ -147,7 +146,7 @@ const SIHMultiStepForm: React.FC = () => {
{
{
{
- - - {errors.team_info?.college_name && ( -

- {errors.team_info.college_name.message} -

- )} -
+ + + {errors.team_info?.team_leader?.role && ( +

+ {errors.team_info.team_leader.role.message} +

+ )} +
-
- - - {errors.team_info?.team_size && ( -

- {errors.team_info.team_size.message} -

- )} -
+
+ + + {errors.team_info?.team_leader?.enrollment_id && ( +

+ {errors.team_info.team_leader.enrollment_id.message} +

+ )} +
+ +
+ + + {errors.team_info?.team_leader?.course && ( +

+ {errors.team_info.team_leader.course.message} +

+ )} +
+ +
+ + + {errors.team_info?.team_leader?.year_of_study && ( +

+ {errors.team_info.team_leader.year_of_study.message} +

+ )} +
+ +
+ + + {errors.team_info?.team_leader?.branch && ( +

+ {errors.team_info.team_leader.branch.message} +

+ )} +