From ac58e0f266cd139ede37f83c13709d4aa3cfcc4e Mon Sep 17 00:00:00 2001
From: Rudra Patel <patelrudra2003@gmail.com>
Date: Wed, 23 Oct 2024 22:35:32 -0400
Subject: [PATCH] feat: Add id to doctors

---
 src/app/form/page.tsx       | 13 ++++++++++---
 src/types/EnrollmentForm.ts |  2 +-
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/app/form/page.tsx b/src/app/form/page.tsx
index b97ab83..f7ea063 100644
--- a/src/app/form/page.tsx
+++ b/src/app/form/page.tsx
@@ -101,6 +101,8 @@ export default function Form() {
 
   const searchParams = useSearchParams();
 
+  console.log(errors);
+
   useEffect(() => {
     const error = searchParams.get("error");
     if (error) {
@@ -109,7 +111,6 @@ export default function Form() {
   }, [searchParams, setError]);
 
   const onSubmit = async (data: GeneralInformationFormValues) => {
-    setError("root", { message: "" });
     // eslint-disable-next-line no-console
     console.log(data);
   };
@@ -452,7 +453,7 @@ export default function Form() {
               render={({ field }) => (
                 <RadioGroup
                   {...field}
-                  value={field.value ? String(field.value) : ""}
+                  value={field.value !== undefined ? String(field.value) : ""}
                   onChange={(e) => field.onChange(e.target.value === "true")}
                 >
                   <FormControlLabel
@@ -912,7 +913,13 @@ export default function Form() {
             </Box>
           ))}
           <Button
-            onClick={() => addDoctor({ name: "", phone: "" } as Doctor)}
+            onClick={() =>
+              addDoctor({
+                id: crypto.randomUUID(),
+                name: "",
+                phone: "",
+              } as Doctor)
+            }
             variant="outlined"
             color="primary"
             startIcon={<AddIcon />}
diff --git a/src/types/EnrollmentForm.ts b/src/types/EnrollmentForm.ts
index 76bdc49..c945236 100644
--- a/src/types/EnrollmentForm.ts
+++ b/src/types/EnrollmentForm.ts
@@ -11,7 +11,7 @@ const DoctorSchema = z.object({
       "Invalid phone number",
     )
     .transform((val) => parsePhoneNumber(val, "US").number.toString()),
-  id: z.number(),
+  id: z.string(),
 });
 
 export const generalInformationValidator = z