diff --git a/frontend/src/components/printBarcode/PrePrint.js b/frontend/src/components/printBarcode/PrePrint.js index 8645480fa3..b8bcaefc4a 100644 --- a/frontend/src/components/printBarcode/PrePrint.js +++ b/frontend/src/components/printBarcode/PrePrint.js @@ -1,4 +1,4 @@ -import { React, useState, useEffect } from "react"; +import { React, useState, useEffect, useRef } from "react"; import { FormattedMessage, useIntl, injectIntl } from "react-intl"; import { Checkbox, @@ -12,11 +12,12 @@ import { } from "@carbon/react"; import { getFromOpenElisServer } from "../utils/Utils"; import { sampleTypeTestsStructure } from "../data/SampleEntryTestsForTypeProvider"; +import AutoComplete from "../common/AutoComplete"; import "../Style.css"; const PrePrint = () => { const intl = useIntl(); - + const componentMounted = useRef(false); const [sampleTypes, setSampleTypes] = useState([]); const [selectedSampleTypeId, setSelectedSampleTypeId] = useState(null); @@ -33,6 +34,21 @@ const PrePrint = () => { const [source, setSource] = useState("about:blank"); const [renderBarcode, setRenderBarcode] = useState(false); + const [siteNames, setSiteNames] = useState([]); + + const getSiteList = (response) => { + if (componentMounted.current) { + setSiteNames(response); + } + }; + + useEffect(() => { + componentMounted.current = true; + getFromOpenElisServer("/rest/site-names", getSiteList); + return () => { + componentMounted.current = false; + }; + }, []); function findTestById(testId) { return sampleTypeTests.tests.find((test) => test.id === testId); @@ -169,7 +185,7 @@ const PrePrint = () => { <>
- +

@@ -179,21 +195,30 @@ const PrePrint = () => { min={1} max={100} defaultValue={1} + value={labelSets} onChange={(_, state) => setLabelSets(state.value)} - label={"Number of label sets"} + label={intl.formatMessage({ + id: "label.barcode.labelsets", + })} id="labelSets" - className="inputText" />
+ + + {" "} +

+
setOrderLabelsPerSet(state.value)} - label={"Number of order labels per set"} + label={intl.formatMessage({ + id: "label.barcode.orderlabel", + })} id="orderLabelsPerSet" - className="inputText" /> @@ -201,26 +226,46 @@ const PrePrint = () => { min={1} max={100} defaultValue={1} + value={specimenLabelsPerSet} onChange={(_, state) => setSpecimenLabelsPerSet(state.value)} - label={"Number of specimen labels per set"} + label={intl.formatMessage({ + id: "label.barcode.specimenlabel", + })} id="specimenLabelsPerSet" - className="inputText" /> + + {" "} +

+
+ + {" "} +

+
- setFacilityId(e.target.value)} - labelText={"Facility ID"} + setFacilityId(id)} + label={ + <> + {" "} + + } + style={{ width: "!important 100%" }} + suggestions={siteNames.length > 0 ? siteNames : []} />
@@ -235,7 +280,6 @@ const PrePrint = () => {