Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #7610 Toggle Emergency Contact No. From Phone Number #7644

Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/Components/Patient/PatientRegister.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import useQuery from "../../Utils/request/useQuery.js";
import routes from "../../Redux/api.js";
import request from "../../Utils/request/request.js";
import SelectMenuV2 from "../Form/SelectMenuV2.js";
import Checkbox from "../Common/components/CheckBox.js";

const Loading = lazy(() => import("../Common/Loading"));
const PageTitle = lazy(() => import("../Common/PageTitle"));
Expand Down Expand Up @@ -221,6 +222,8 @@ export const PatientRegister = (props: PatientRegisterProps) => {
const [insuranceDetails, setInsuranceDetails] = useState<HCXPolicyModel[]>(
[],
);
const [isEmergencyNumberEnabled, setIsEmergencyNumberEnabled] =
useState(false);
const [insuranceDetailsError, setInsuranceDetailsError] =
useState<FieldError>();

Expand Down Expand Up @@ -1303,6 +1306,14 @@ export const PatientRegister = (props: PatientRegisterProps) => {
}}
types={["mobile", "landline"]}
/>
<Checkbox
label="Is the phone number an emergency number?"
className="font-bold"
checked={isEmergencyNumberEnabled}
onCheck={(checked) =>
setIsEmergencyNumberEnabled(checked)
}
rithviknishad marked this conversation as resolved.
Show resolved Hide resolved
/>
</div>
<div
data-testid="emergency-phone-number"
Expand All @@ -1313,6 +1324,12 @@ export const PatientRegister = (props: PatientRegisterProps) => {
label="Emergency contact number"
required
types={["mobile", "landline"]}
disabled={isEmergencyNumberEnabled}
value={
isEmergencyNumberEnabled
? field("phone_number").value
: initForm.emergency_phone_number
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will cause issues as the displayed value may not be the one that is sent in the POST request.

Update form state for emergency phone number instead of displaying a different value conditionally.

/>
</div>
<div data-testid="name" id="name-div">
Expand Down
Loading