cleanup
This commit is contained in:
parent
b23d706180
commit
f43bcec080
4 changed files with 49 additions and 46 deletions
|
|
@ -0,0 +1,7 @@
|
||||||
|
export const data = {
|
||||||
|
importNames: ["Import ABC", "Import DEF", "Import GHI"],
|
||||||
|
splitScheduleOptions: ["Yes", "No"],
|
||||||
|
clientOptions: ["Single", "Multiple"],
|
||||||
|
testingCenterOptions: ["testing center 1", "testing center 2", "testing center 3", "testing center 4"],
|
||||||
|
clientsOptions: ["client 1", "client 2", "client 3"],
|
||||||
|
};
|
||||||
30
components/Form/formSchemas.ts
Normal file
30
components/Form/formSchemas.ts
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
import { FormValues } from "./types";
|
||||||
|
import * as Yup from "yup";
|
||||||
|
|
||||||
|
export const initialValues: FormValues = {
|
||||||
|
importName: '',
|
||||||
|
manifestFile: null,
|
||||||
|
splitSchedule: '',
|
||||||
|
client: '',
|
||||||
|
testingCenter: '',
|
||||||
|
toleranceWindow: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
export const validationSchema = Yup.object({
|
||||||
|
importName: Yup.string()
|
||||||
|
.required('Import name is required')
|
||||||
|
.oneOf(["Import ABC", "Import DEF", "Import GHI"], "Invalid Import Name"),
|
||||||
|
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
|
||||||
|
toleranceWindow: Yup.boolean()
|
||||||
|
.required('Tolerance window selection is required'), // Assuming this is a boolean represented by a toggle
|
||||||
|
});
|
||||||
|
|
@ -4,7 +4,7 @@ import React, { useState } from "react";
|
||||||
|
|
||||||
//Dependencies
|
//Dependencies
|
||||||
import { Formik, Form } from "formik";
|
import { Formik, Form } from "formik";
|
||||||
import * as Yup from "yup";
|
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
|
||||||
//Input fields
|
//Input fields
|
||||||
|
|
@ -15,51 +15,9 @@ import ToggleField from "./ToggleField";
|
||||||
import StatusField from "./StatusField";
|
import StatusField from "./StatusField";
|
||||||
import ClientField from "./ClientField";
|
import ClientField from "./ClientField";
|
||||||
|
|
||||||
interface FormValues {
|
import { FormValues } from "./types";
|
||||||
importName: string;
|
import { data } from "./data";
|
||||||
manifestFile: File | null;
|
import { initialValues, validationSchema } from "./formSchemas";
|
||||||
splitSchedule: string;
|
|
||||||
client: string;
|
|
||||||
testingCenter: string;
|
|
||||||
toleranceWindow: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
const initialValues: FormValues = {
|
|
||||||
importName: '',
|
|
||||||
manifestFile: null,
|
|
||||||
splitSchedule: '',
|
|
||||||
client: '',
|
|
||||||
testingCenter: '',
|
|
||||||
toleranceWindow: false,
|
|
||||||
};
|
|
||||||
|
|
||||||
const validationSchema = Yup.object({
|
|
||||||
importName: Yup.string()
|
|
||||||
.required('Import name is required')
|
|
||||||
.oneOf(["Import ABC", "Import DEF", "Import GHI"], "Invalid Import Name"),
|
|
||||||
manifestFile: Yup.mixed()
|
|
||||||
.required('A file is required')
|
|
||||||
.nullable(), // Allows for null values, adjust based on your logic for file handling
|
|
||||||
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
|
|
||||||
toleranceWindow: Yup.boolean()
|
|
||||||
.required('Tolerance window selection is required'), // Assuming this is a boolean represented by a toggle
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
const data = {
|
|
||||||
importNames: ["Import ABC", "Import DEF", "Import GHI"],
|
|
||||||
splitScheduleOptions: ["Yes", "No"],
|
|
||||||
clientOptions: ["Single", "Multiple"],
|
|
||||||
testingCenterOptions: ["testing center 1", "testing center 2", "testing center 3", "testing center 4"],
|
|
||||||
clientsOptions: ["client 1", "client 2", "client 3"],
|
|
||||||
};
|
|
||||||
|
|
||||||
const FormComponent: React.FC = () => {
|
const FormComponent: React.FC = () => {
|
||||||
const [formSubmitted, setFormSubmitted] = useState(false);
|
const [formSubmitted, setFormSubmitted] = useState(false);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
export interface FormValues {
|
||||||
|
importName: string;
|
||||||
|
manifestFile: File | null;
|
||||||
|
splitSchedule: string;
|
||||||
|
client: string;
|
||||||
|
testingCenter: string;
|
||||||
|
toleranceWindow: boolean;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue