Skip to content

Commit

Permalink
fix(OH2-387): Fix exam options not scrolling
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveGT96 committed Nov 4, 2024
1 parent d24a20b commit aa8f417
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions src/components/accessories/laboratory/examForm/ExamForm.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import SelectField from "components/accessories/selectField/SelectField";
import { useFormik } from "formik";
import { useAppDispatch, useAppSelector } from "libraries/hooks/redux";
import { get, has } from "lodash";
Expand All @@ -10,19 +11,17 @@ import checkIcon from "../../../../assets/check-icon.png";
import warningIcon from "../../../../assets/warning-icon.png";
import { PATHS } from "../../../../consts";
import {
ExamDTO,
LaboratoryDTO,
LaboratoryDTOInOutPatientEnum,
LaboratoryDTOStatusEnum,
PatientDTO,
} from "../../../../generated";
import { renderDate } from "../../../../libraries/formatUtils/dataFormatting";
import {
formatAllFieldValues,
getFromFields,
parseDate,
} from "../../../../libraries/formDataHandling/functions";
import { scrollToElement } from "../../../../libraries/uiUtils/scrollToElement";
import { renderDate } from "../../../../libraries/formatUtils/dataFormatting";
import { getExamRows, getExams } from "../../../../state/exams";
import {
createLab,
Expand Down Expand Up @@ -140,7 +139,6 @@ const ExamForm: FC<ExamProps> = ({
dispatch(createLabReset());
dispatch(updateLabReset());
setActivityTransitionState("IDLE");
scrollToElement(null);
}, [dispatch]);

const rowTableHeaders: Array<{
Expand Down Expand Up @@ -177,20 +175,18 @@ const ExamForm: FC<ExamProps> = ({
const initialValues = getFromFields(fields, "value");
const [rowsData, setRowsData] = useState([...labToEditRows]);

const examOptionsSelector = (exams: ExamDTO[] | undefined) => {
if (exams) {
return exams.map((item) => {
return {
value: item.code ?? "",
label:
(item.description &&
item.description?.length > 30 &&
item.description.slice(0, 30) + "...") ||
(item.description ?? ""),
};
});
} else return [];
};
const examOptions = useAppSelector((state: IState) => {
return (state.exams.examList.data ?? []).map((item) => {
return {
value: item.code ?? "",
label:
(item.description &&
item.description?.length > 30 &&
item.description.slice(0, 30) + "...") ||
(item.description ?? ""),
};
});
});

const examList = useAppSelector((state: IState) => state.exams.examList.data);

Expand Down Expand Up @@ -384,14 +380,14 @@ const ExamForm: FC<ExamProps> = ({
/>
</div> */}
<div className="patientExamForm__item">
<AutocompleteField
<SelectField
fieldName="exam"
fieldValue={formik.values.exam}
label={t("lab.exam")}
isValid={isValid("exam")}
errorText={getErrorText("exam")}
onBlur={onBlurCallback("exam")}
options={examOptionsSelector(examList)}
options={examOptions}
isLoading={examsLoading}
disabled={isLoading}
/>
Expand Down

0 comments on commit aa8f417

Please sign in to comment.