From 9f250364e4deaefb39f34322bdcb9da226acdfe2 Mon Sep 17 00:00:00 2001 From: Jesus Vasquez Date: Sun, 3 Mar 2024 23:32:46 -0500 Subject: [PATCH] work in progress --- components/Form/FileInput.tsx | 10 ++-- components/Form/formSchemas.ts | 10 +++- components/Form/index.tsx | 90 ++++++++++++++++++++-------------- components/Form/types.ts | 16 +++--- 4 files changed, 76 insertions(+), 50 deletions(-) diff --git a/components/Form/FileInput.tsx b/components/Form/FileInput.tsx index daed5b0..7a79146 100644 --- a/components/Form/FileInput.tsx +++ b/components/Form/FileInput.tsx @@ -45,12 +45,12 @@ const FileInput: React.FC = ({ label, ...props }) => { {label} -
e.preventDefault()}> -
- -

Drag & Drop Here or Browse

+
e.preventDefault()}> +
+ +

Drag & Drop Here or Browse

- +
diff --git a/components/Form/formSchemas.ts b/components/Form/formSchemas.ts index 38ac1d7..367c036 100644 --- a/components/Form/formSchemas.ts +++ b/components/Form/formSchemas.ts @@ -6,7 +6,10 @@ export const initialValues: FormValues = { manifestFile: null, splitSchedule: "", client: "", - testingCenter: "", + testingCenter1: "", + testingCenter2: "", + testingCenter3: "", + testingCenter4: "", toleranceWindow: false, } @@ -17,6 +20,9 @@ export const validationSchema = Yup.object({ manifestFile: Yup.mixed().required("A file is required").nullable(), // Allows for null values splitSchedule: Yup.string().required("This field is required").oneOf(["Yes", "No"], "Invalid Option"), client: Yup.string().required("Client selection is required").oneOf(["Single", "Multiple"], "Invalid Client Type"), - testingCenter: Yup.string().required("Testing center selection is required"), // Assuming a selection is required + testingCenter1: Yup.string().required("Testing center selection is required"), // Assuming a selection is required + testingCenter2: Yup.string().required("Testing center selection is required"), // Assuming a selection is required + testingCenter3: Yup.string().required("Testing center selection is required"), // Assuming a selection is required + testingCenter4: Yup.string().required("Testing center selection is required"), // Assuming a selection is required toleranceWindow: Yup.boolean().required("Tolerance window selection is required"), // Assuming this is a boolean represented by a toggle }) diff --git a/components/Form/index.tsx b/components/Form/index.tsx index 561cabb..e4b5397 100644 --- a/components/Form/index.tsx +++ b/components/Form/index.tsx @@ -37,13 +37,14 @@ const FormComponent: React.FC = () => { } return ( + <> { + console.log("Form values:", values); // Log form values on submit try { - console.log(values) - await submitForm(values) + //await submitForm(values) setFormSubmitted(true) } catch (error) { console.error("Error submitting form:", error) @@ -52,43 +53,58 @@ const FormComponent: React.FC = () => { } }} > - {(formik) => ( -
-
-
- - - {data.importNames.map((option) => ( - - ))} - - - - - Tolerance Window: - + {(formik) => { + console.log("Form errors:", formik.errors); // Log form errors on every render + console.log("Form values:", formik.values); // Log current form values on every render + + return ( + +
+
+ + + {data.importNames.map((option) => ( + + ))} + + {/* */} + + + Tolerance Window: + +
+
+ + + + +
-
- - - - -
-
- - - )} + + + ) + } + + } + {formSubmitted &&
Success
} + + ) } diff --git a/components/Form/types.ts b/components/Form/types.ts index fea6431..e7d0660 100644 --- a/components/Form/types.ts +++ b/components/Form/types.ts @@ -1,8 +1,12 @@ export interface FormValues { - importName: string - manifestFile: File | null - splitSchedule: string - client: string - testingCenter: string - toleranceWindow: boolean + importName: string; + manifestFile: File | null; + splitSchedule: string; + client: string; + testingCenter1: string; + testingCenter2: string; + testingCenter3: string; + testingCenter4: string; + toleranceWindow: boolean; } +