diff --git a/src/Components/Facility/SetInventoryForm.tsx b/src/Components/Facility/SetInventoryForm.tsx index 9c5e849b7a0..27288c01520 100644 --- a/src/Components/Facility/SetInventoryForm.tsx +++ b/src/Components/Facility/SetInventoryForm.tsx @@ -1,19 +1,18 @@ -import { Card, CardContent, InputLabel } from "@material-ui/core"; import { useCallback, useReducer, useState, useEffect } from "react"; import { useDispatch } from "react-redux"; import loadable from "@loadable/component"; import { statusType, useAbortableEffect } from "../../Common/utils"; import { getItems, setMinQuantity, getAnyFacility } from "../../Redux/actions"; import * as Notification from "../../Utils/Notifications.js"; -import { - LegacySelectField, - LegacyTextInputField, -} from "../Common/HelperInputFields"; import { InventoryItemsModel } from "./models"; import { Cancel, Submit } from "../Common/components/ButtonV2"; import useAppHistory from "../../Common/hooks/useAppHistory"; +import Page from "../Common/components/Page"; +import Card from "../../CAREUI/display/Card"; +import { FieldChangeEvent } from "../Form/FormFields/Utils"; +import { SelectFormField } from "../Form/FormFields/SelectFormField"; +import TextFormField from "../Form/FormFields/TextFormField"; const Loading = loadable(() => import("../Common/Loading")); -const PageTitle = loadable(() => import("../Common/PageTitle")); const initForm = { id: "", @@ -48,7 +47,6 @@ export const SetInventoryForm = (props: any) => { const { facilityId } = props; const dispatchAction: any = useDispatch(); const [isLoading, setIsLoading] = useState(false); - // const [offset, setOffset] = useState(0); const [data, setData] = useState>([]); const [currentUnit, setCurrentUnit] = useState(); const [facilityName, setFacilityName] = useState(""); @@ -123,10 +121,8 @@ export const SetInventoryForm = (props: any) => { goBack(); }; - const handleChange = (e: any) => { - const form = { ...state.form }; - form[e.target.name] = e.target.value; - dispatch({ type: "set_form", form }); + const handleChange = ({ name, value }: FieldChangeEvent) => { + dispatch({ type: "set_form", form: { ...state.form, [name]: value } }); }; if (isLoading) { @@ -134,78 +130,59 @@ export const SetInventoryForm = (props: any) => { } return ( -
- -
- -
handleSubmit(e)}> - -
-
- - Inventory Name - - { - return { id: e.id, name: e.name }; - })} - onChange={handleChange} - optionKey="id" - optionValue="name" - /> -
- -
- Unit - -
- -
- Item Min Quantity - -
-
-
- goBack()} /> - -
-
-
-
-
-
+ + +
handleSubmit(e)} className="mt-6 flex flex-col"> + item.id} + optionLabel={(item) => item.name} + /> + +
+ + + +
+ +
+ goBack()} /> + +
+ +
+
); };