Skip to content

Commit

Permalink
fix(OH2-261): Fix search patient search form validation (#543)
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveGT96 authored Jan 16, 2024
1 parent 6642128 commit 449884b
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import React, {
} from "react";
import { useTranslation } from "react-i18next";
import { connect, useDispatch, useSelector } from "react-redux";
import { object, string } from "yup";
import { number, object, string } from "yup";
import SearchIcon from "../../../assets/SearchIcon";
import { PATHS } from "../../../consts";
import { formatAllFieldValues } from "../../../libraries/formDataHandling/functions";
Expand Down Expand Up @@ -50,7 +50,7 @@ const SearchPatientActivity: FunctionComponent<TProps> = ({

useEffect(() => {
dispatch(searchPatientReset());
}, []);
}, [dispatch]);

const errorMessage = useSelector<IState>(
(state) =>
Expand All @@ -68,10 +68,10 @@ const SearchPatientActivity: FunctionComponent<TProps> = ({
};

const validationSchema = object({
id: string().when(["firstName", "secondName", "birthDate", "address"], {
id: number().when(["firstName", "secondName", "birthDate", "address"], {
is: (firstName, secondName, birthDate, address) =>
!firstName && !secondName && !birthDate && !address,
then: string().required(),
then: number().required(),
}),
});

Expand Down Expand Up @@ -181,6 +181,7 @@ const SearchPatientActivity: FunctionComponent<TProps> = ({
isValid={isValid("id")}
errorText={getErrorText("id")}
onBlur={formik.handleBlur}
type={"number"}
/>
</div>
</div>
Expand Down

0 comments on commit 449884b

Please sign in to comment.