diff --git a/services/frontend/src/components/global/FormElements/InputField.tsx b/services/frontend/src/components/global/FormElements/InputField.tsx index f3d0480..dc3cc31 100644 --- a/services/frontend/src/components/global/FormElements/InputField.tsx +++ b/services/frontend/src/components/global/FormElements/InputField.tsx @@ -1,47 +1,48 @@ -import _ from "lodash"; +import lodash from "lodash"; import { useFormikContext } from "formik"; +import { FunctionComponent, ReactElement } from "react"; -interface Props { +export interface ITextFieldProps { name: string; help?: string; [key: string]: any; } -const TextField = (props: Props) => { - const { label, name, help, ...otherProps } = props; +const TextField: FunctionComponent = ( + props: ITextFieldProps +): ReactElement => { + const { label, name, help, required, ...otherProps } = props; const formik = useFormikContext(); - const error = _.get(formik.touched, name) && _.get(formik.errors, name); + const error = + lodash.get(formik.touched, name) && lodash.get(formik.errors, name); return ( -
-
-
- -
- - { -
- {error &&
{error}
} - {!error && help} -
- } -
-
+
+ {label && ( + + )} + + + +
+ {error && {error}} + {!error && help}
);