diff --git a/cypress/e2e/facility_spec/locations.cy.ts b/cypress/e2e/facility_spec/locations.cy.ts index f8006b126d4..59651c7c7c9 100644 --- a/cypress/e2e/facility_spec/locations.cy.ts +++ b/cypress/e2e/facility_spec/locations.cy.ts @@ -24,6 +24,8 @@ describe("Location Management Section", () => { cy.contains("Add New Location").click(); cy.get("[name='name']").type("Test Location"); cy.get("textarea[name='description']").type("Test Description"); + cy.get("#location-type").click(); + cy.get("#location-type-option-ICU").click(); cy.intercept(/\/api\/v1\/facility\/[\w-]+\/asset_location\//).as( "addLocation" ); diff --git a/src/Components/Assets/AssetTypes.tsx b/src/Components/Assets/AssetTypes.tsx index a894c87dcc5..041d3d0a81e 100644 --- a/src/Components/Assets/AssetTypes.tsx +++ b/src/Components/Assets/AssetTypes.tsx @@ -2,12 +2,19 @@ import { BedModel } from "../Facility/models"; import { PerformedByModel } from "../HCX/misc"; import { PatientModel } from "../Patient/models"; +export enum AssetLocationType { + OTHER = "OTHER", + WARD = "WARD", + ICU = "ICU", +} + export interface AssetLocationObject { id: string; name: string; description: string; created_date?: string; modified_date?: string; + location_type: AssetLocationType; middleware_address?: string; facility: { id: string; diff --git a/src/Components/Facility/AddLocationForm.tsx b/src/Components/Facility/AddLocationForm.tsx index e71b68cc95c..81d9bc0750c 100644 --- a/src/Components/Facility/AddLocationForm.tsx +++ b/src/Components/Facility/AddLocationForm.tsx @@ -12,6 +12,8 @@ import { Submit, Cancel } from "../Common/components/ButtonV2"; import TextFormField from "../Form/FormFields/TextFormField"; import TextAreaFormField from "../Form/FormFields/TextAreaFormField"; import Page from "../Common/components/Page"; +import { SelectFormField } from "../Form/FormFields/SelectFormField"; +import { AssetLocationType } from "../Assets/AssetTypes"; const Loading = lazy(() => import("../Common/Loading")); @@ -29,10 +31,12 @@ export const AddLocationForm = (props: LocationFormProps) => { const [description, setDescription] = useState(""); const [facilityName, setFacilityName] = useState(""); const [locationName, setLocationName] = useState(""); + const [locationType, setLocationType] = useState(""); const [errors, setErrors] = useState({ name: "", description: "", middlewareAddress: "", + locationType: "", }); const headerText = !locationId ? "Add Location" : "Update Location"; const buttonText = !locationId ? "Add Location" : "Update Location"; @@ -53,6 +57,7 @@ export const AddLocationForm = (props: LocationFormProps) => { setName(res?.data?.name || ""); setLocationName(res?.data?.name || ""); setDescription(res?.data?.description || ""); + setLocationType(res?.data?.location_type || ""); setMiddlewareAddress(res?.data?.middleware_address || ""); } setIsLoading(false); @@ -66,6 +71,7 @@ export const AddLocationForm = (props: LocationFormProps) => { name: "", description: "", middlewareAddress: "", + locationType: "", }; if (name.trim().length === 0) { @@ -73,6 +79,11 @@ export const AddLocationForm = (props: LocationFormProps) => { formValid = false; } + if (locationType.trim().length === 0) { + error.locationType = "Location Type is required"; + formValid = false; + } + if ( middlewareAddress && middlewareAddress.match( @@ -98,6 +109,7 @@ export const AddLocationForm = (props: LocationFormProps) => { name, description, middleware_address: middlewareAddress, + location_type: locationType, }; const res = await dispatchAction( @@ -172,6 +184,27 @@ export const AddLocationForm = (props: LocationFormProps) => { error={errors.description} /> +
+ title} + optionValue={({ value }) => value} + value={locationType} + required + onChange={({ value }) => setLocationType(value)} + error={errors.locationType} + /> +