diff --git a/services/frontend/src/components/Modal/Service/Labels.tsx b/services/frontend/src/components/Modal/Service/Labels.tsx index c7e8550..d3ac439 100644 --- a/services/frontend/src/components/Modal/Service/Labels.tsx +++ b/services/frontend/src/components/Modal/Service/Labels.tsx @@ -3,7 +3,7 @@ import { PlusIcon } from "@heroicons/react/outline"; import { Button, styled } from "@mui/joy"; import { useFormikContext } from "formik"; import Record from "../../Record"; -import { IEditServiceForm, IService } from "../../../types"; +import { IEditServiceForm } from "../../../types"; const Root = styled("div")` display: flex; diff --git a/services/frontend/src/components/Modal/Service/form-utils.ts b/services/frontend/src/components/Modal/Service/form-utils.ts index 51f4be0..f469f1e 100644 --- a/services/frontend/src/components/Modal/Service/form-utils.ts +++ b/services/frontend/src/components/Modal/Service/form-utils.ts @@ -1,6 +1,7 @@ import type { IEditServiceForm, IServiceNodeItem } from "../../../types"; import * as yup from "yup"; import lodash from "lodash"; +import { checkArray } from "../../../utils/forms"; const initialValues: IEditServiceForm = { imageName: "", @@ -96,15 +97,6 @@ export const getInitialValues = (node?: IServiceNodeItem): IEditServiceForm => { labels } = serviceConfig; - const checkArray = (array: any, name: string): T => { - if (!Array.isArray(array)) { - throw new Error( - `Looks like we encountered a bug. The current implementation expects "${name}" to be an array.` - ); - } - return array as unknown as T; - }; - const environment0: string[] = checkArray(environment, "environment"); const volumes0: string[] = checkArray(volumes, "volumes"); const ports0: string[] = checkArray(ports, "ports"); diff --git a/services/frontend/src/utils/forms.ts b/services/frontend/src/utils/forms.ts new file mode 100644 index 0000000..931a359 --- /dev/null +++ b/services/frontend/src/utils/forms.ts @@ -0,0 +1,8 @@ +export const checkArray = (array: any, name: string): T => { + if (!Array.isArray(array)) { + throw new Error( + `Looks like we encountered a bug. The current implementation expects "${name}" to be an array.` + ); + } + return array as unknown as T; +};