From f49ac41fc63b02860440b9430f317247abc0f8f9 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Mon, 12 Jun 2023 17:48:28 +0530 Subject: [PATCH 01/30] Tailwinds `SampleDetails.tsx` (#5631) * fixes #4981 * minor fix for resource date filters --------- --- cypress/e2e/resource_spec/filter.cy.ts | 34 ++- src/Components/Patient/SampleDetails.tsx | 331 +++++++++++------------ 2 files changed, 187 insertions(+), 178 deletions(-) diff --git a/cypress/e2e/resource_spec/filter.cy.ts b/cypress/e2e/resource_spec/filter.cy.ts index f977dfbfa8f..88fc5d172b9 100644 --- a/cypress/e2e/resource_spec/filter.cy.ts +++ b/cypress/e2e/resource_spec/filter.cy.ts @@ -63,16 +63,42 @@ describe("Resource filter", () => { it("filter by created date", () => { cy.intercept(/\/api\/v1\/resource/).as("resource_filter"); - cy.get("[name='created_date_after']").type("22/05/2020"); - cy.get("[name='created_date_before']").type("09/09/2021"); + cy.get("[name='created_date_after']").click(); + cy.get( + "[role='button'][aria-label='Move backward to switch to the previous month.']" + ).click(); + cy.get("td[tabindex='-1']") + .first() + .then(($td) => { + $td[0].click(); + + cy.get("td[tabindex='-1']") + .eq(14) + .then(($td2) => { + $td2[0].click(); + }); + }); cy.contains("Apply").click(); cy.wait("@resource_filter"); }); it("filter by modified date", () => { cy.intercept(/\/api\/v1\/resource/).as("resource_filter"); - cy.get("[name='modified_date_after']").type("22/05/2020"); - cy.get("[name='modified_date_before']").type("09/09/2021"); + cy.get("[name='modified_date_after']").click(); + cy.get( + "[role='button'][aria-label='Move backward to switch to the previous month.']" + ).click(); + cy.get("td[tabindex='-1']") + .first() + .then(($td) => { + $td[0].click(); + + cy.get("td[tabindex='-1']") + .eq(14) + .then(($td2) => { + $td2[0].click(); + }); + }); cy.contains("Apply").click(); cy.wait("@resource_filter"); }); diff --git a/src/Components/Patient/SampleDetails.tsx b/src/Components/Patient/SampleDetails.tsx index 9dcb7d0c50f..79a75141896 100644 --- a/src/Components/Patient/SampleDetails.tsx +++ b/src/Components/Patient/SampleDetails.tsx @@ -1,4 +1,3 @@ -import { Card, CardContent, Button } from "@material-ui/core"; import loadable from "@loadable/component"; import { useCallback, useState } from "react"; import { useDispatch } from "react-redux"; @@ -10,16 +9,17 @@ import { navigate } from "raviger"; import { GENDER_TYPES, TEST_TYPE_CHOICES } from "../../Common/constants"; import _ from "lodash"; import { formatDate } from "../../Utils/utils"; +import Card from "../../CAREUI/display/Card"; +import Page from "../Common/components/Page"; +import ButtonV2 from "../Common/components/ButtonV2"; const Loading = loadable(() => import("../Common/Loading")); -const PageTitle = loadable(() => import("../Common/PageTitle")); interface SampleDetailsProps { id: number; } -export const SampleDetails = (props: SampleDetailsProps) => { - const { id } = props; +export const SampleDetails = ({ id }: SampleDetailsProps) => { const dispatch: any = useDispatch(); const [isLoading, setIsLoading] = useState(false); const [sampleDetails, setSampleDetails] = useState({}); @@ -46,7 +46,7 @@ export const SampleDetails = (props: SampleDetailsProps) => { }, [dispatch, fetchData, id] ); - const yesornoBadge = (param: any) => + const yesOrNoBadge = (param: any) => param ? ( Yes ) : ( @@ -180,13 +180,13 @@ export const SampleDetails = (props: SampleDetailsProps) => { Contact with confirmed carrier:{" "} - {yesornoBadge(patientData?.contact_with_confirmed_carrier)} + {yesOrNoBadge(patientData?.contact_with_confirmed_carrier)}
Contact with suspected carrier:{" "} - {yesornoBadge(patientData?.contact_with_suspected_carrier)} + {yesOrNoBadge(patientData?.contact_with_suspected_carrier)}
{patientData?.estimated_contact_date && (
@@ -200,13 +200,13 @@ export const SampleDetails = (props: SampleDetailsProps) => { Has SARI (Severe Acute Respiratory illness)?:{" "} - {yesornoBadge(patientData?.has_SARI)} + {yesOrNoBadge(patientData?.has_SARI)}
Domestic/international Travel (within last 28 days):{" "} - {yesornoBadge(patientData?.past_travel)} + {yesOrNoBadge(patientData?.past_travel)}
{patientData?.countries_travelled && !!patientData?.countries_travelled.length && ( @@ -257,31 +257,25 @@ export const SampleDetails = (props: SampleDetailsProps) => { const renderFlow = (flow: FlowModel) => { return ( - - -
-
- Status: {" "} - {_.startCase(_.camelCase(flow.status))} -
-
- Label:{" "} - {_.capitalize(flow.notes)} -
-
- - Created On : - {" "} - {flow.created_date ? formatDate(flow.created_date) : "-"} -
-
- - Modified on: - {" "} - {flow.modified_date ? formatDate(flow.modified_date) : "-"} -
+ +
+
+ Status: {" "} + {_.startCase(_.camelCase(flow.status))} +
+
+ Label:{" "} + {_.capitalize(flow.notes)} +
+
+ Created On :{" "} + {flow.created_date ? formatDate(flow.created_date) : "-"} +
+
+ Modified on:{" "} + {flow.modified_date ? formatDate(flow.modified_date) : "-"}
- +
); }; @@ -291,162 +285,153 @@ export const SampleDetails = (props: SampleDetailsProps) => { } return ( -
- - {sampleDetails.patient && ( -
- -
- )} - - -
-
- Status: - {_.startCase(_.camelCase(sampleDetails.status))} -
-
- Result: - {_.startCase(_.camelCase(sampleDetails.result))} -
-
- Patient: - {sampleDetails.patient_name} -
- {sampleDetails.facility_object && ( -
- - Facility:{" "} - - {sampleDetails.facility_object.name} -
- )} -
- Tested on: - {sampleDetails.date_of_result - ? formatDate(sampleDetails.date_of_result) - : "-"} -
+ + + ICMR Specimen Referral Form + +
+ ) + } + > + +
+
+ Status: + {_.startCase(_.camelCase(sampleDetails.status))} +
+
+ Result: + {_.startCase(_.camelCase(sampleDetails.result))} +
+
+ Patient: + {sampleDetails.patient_name} +
+ {sampleDetails.facility_object && (
- Result on: - {sampleDetails.date_of_result - ? formatDate(sampleDetails.date_of_result) - : "-"} + Facility: + {sampleDetails.facility_object.name}
- {sampleDetails.fast_track && ( -
- - Fast track testing reason:{" "} - - {sampleDetails.fast_track} -
- )} - {sampleDetails.doctor_name && ( -
- - Doctor's Name:{" "} - - {_.startCase(_.camelCase(sampleDetails.doctor_name))} -
- )} - {sampleDetails.diagnosis && ( -
- - Diagnosis:{" "} - - {sampleDetails.diagnosis} -
- )} - {sampleDetails.diff_diagnosis && ( -
- - Differential diagnosis:{" "} - - {sampleDetails.diff_diagnosis} -
- )} - {sampleDetails.etiology_identified && ( -
- - Etiology identified:{" "} - - {sampleDetails.etiology_identified} -
- )} -
+ )} +
+ Tested on: + {sampleDetails.date_of_result + ? formatDate(sampleDetails.date_of_result) + : "-"} +
+
+ Result on: + {sampleDetails.date_of_result + ? formatDate(sampleDetails.date_of_result) + : "-"} +
+ {sampleDetails.fast_track && ( +
- Is Atypical presentation{" "} + Fast track testing reason:{" "} - {yesornoBadge(sampleDetails.is_atypical_presentation)} + {sampleDetails.fast_track}
-
+ )} + {sampleDetails.doctor_name && ( +
- Is unusual course{" "} + Doctor's Name:{" "} - {yesornoBadge(sampleDetails.is_unusual_course)} + {_.startCase(_.camelCase(sampleDetails.doctor_name))}
- {sampleDetails.atypical_presentation && ( -
- - Atypical presentation details:{" "} - - {sampleDetails.atypical_presentation} -
- )} -
- - SARI - Severe Acute Respiratory illness{" "} - - {yesornoBadge(sampleDetails.has_sari)} + )} + {sampleDetails.diagnosis && ( +
+ Diagnosis: + {sampleDetails.diagnosis}
-
+ )} + {sampleDetails.diff_diagnosis && ( +
- ARI - Acute Respiratory illness{" "} + Differential diagnosis:{" "} - {yesornoBadge(sampleDetails.has_ari)} + {sampleDetails.diff_diagnosis}
-
+ )} + {sampleDetails.etiology_identified && ( +
- Contact with confirmed carrier{" "} + Etiology identified:{" "} - {yesornoBadge(sampleDetails.patient_has_confirmed_contact)} + {sampleDetails.etiology_identified}
-
+ )} +
+ + Is Atypical presentation{" "} + + {yesOrNoBadge(sampleDetails.is_atypical_presentation)} +
+
+ + Is unusual course{" "} + + {yesOrNoBadge(sampleDetails.is_unusual_course)} +
+ {sampleDetails.atypical_presentation && ( +
- Contact with suspected carrier{" "} + Atypical presentation details:{" "} - {yesornoBadge(sampleDetails.patient_has_suspected_contact)} + {sampleDetails.atypical_presentation}
- {sampleDetails.patient_travel_history && - sampleDetails.patient_travel_history.length !== 0 && ( -
- - Countries travelled:{" "} - - {JSON.parse(sampleDetails.patient_travel_history).join(", ")} -
- )} - {sampleDetails.sample_type && ( + )} +
+ + SARI - Severe Acute Respiratory illness{" "} + + {yesOrNoBadge(sampleDetails.has_sari)} +
+
+ + ARI - Acute Respiratory illness{" "} + + {yesOrNoBadge(sampleDetails.has_ari)} +
+
+ + Contact with confirmed carrier{" "} + + {yesOrNoBadge(sampleDetails.patient_has_confirmed_contact)} +
+
+ + Contact with suspected carrier{" "} + + {yesOrNoBadge(sampleDetails.patient_has_suspected_contact)} +
+ {sampleDetails.patient_travel_history && + sampleDetails.patient_travel_history.length !== 0 && (
- Sample Type:{" "} + Countries travelled:{" "} - {_.startCase(_.camelCase(sampleDetails.sample_type))} + {JSON.parse(sampleDetails.patient_travel_history).join(", ")}
)} -
- + {sampleDetails.sample_type && ( +
+ + Sample Type:{" "} + + {_.startCase(_.camelCase(sampleDetails.sample_type))} +
+ )} +
@@ -454,13 +439,11 @@ export const SampleDetails = (props: SampleDetailsProps) => { {showPatientCard(sampleDetails.patient_object)}
- - {sampleDetails.flow && - sampleDetails.flow.map((flow: FlowModel) => renderFlow(flow))} +
+

Sample Test History

+ {sampleDetails.flow && + sampleDetails.flow.map((flow: FlowModel) => renderFlow(flow))} +
{ unspecified={true} audio={true} /> -
+ ); }; From e48cdab78ed136c6f2dcbaa1d31a1697a1013451 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Mon, 12 Jun 2023 17:49:30 +0530 Subject: [PATCH 02/30] Tailwinds `SampleFilters.tsx` (#5630) * fixes #4982 * minor fix for CYPRESS --------- --- cypress/e2e/sample_test_spec/filter.cy.ts | 15 +++- src/Common/constants.tsx | 20 ++--- src/Components/Patient/SampleFilters.tsx | 100 ++++++++++----------- src/Components/Patient/SampleViewAdmin.tsx | 2 +- 4 files changed, 69 insertions(+), 68 deletions(-) diff --git a/cypress/e2e/sample_test_spec/filter.cy.ts b/cypress/e2e/sample_test_spec/filter.cy.ts index 23bf48e8fd8..8fe8fa50b81 100644 --- a/cypress/e2e/sample_test_spec/filter.cy.ts +++ b/cypress/e2e/sample_test_spec/filter.cy.ts @@ -13,15 +13,24 @@ describe("Sample Filter", () => { }); it("Filter by Status", () => { - cy.get("[name='status']").select("APPROVED"); + cy.get("#status").click(); + cy.get("li[role='option']") + .contains(/^APPROVED$/) + .click(); }); it("Filter by Asset Type", () => { - cy.get("[name='result']").select("POSITIVE"); + cy.get("#result").click(); + cy.get("li[role='option']") + .contains(/^POSITIVE$/) + .click(); }); it("Filter by sample type", () => { - cy.get("[name='sample_type']").select("Biopsy"); + cy.get("#sample_type").click(); + cy.get("li[role='option']") + .contains(/^Biopsy$/) + .click(); }); afterEach(() => { diff --git a/src/Common/constants.tsx b/src/Common/constants.tsx index 258352a65fd..5736327e16e 100644 --- a/src/Common/constants.tsx +++ b/src/Common/constants.tsx @@ -465,16 +465,16 @@ export const BLOOD_GROUPS = [ ]; export const SAMPLE_TYPE_CHOICES = [ - { id: 0, text: "UNKNOWN" }, - { id: 1, text: "BA/ETA" }, - { id: 2, text: "TS/NPS/NS" }, - { id: 3, text: "Blood in EDTA" }, - { id: 4, text: "Acute Sera" }, - { id: 5, text: "Covalescent sera" }, - { id: 6, text: "Biopsy" }, - { id: 7, text: "AMR" }, - { id: 8, text: "Communicable Diseases" }, - { id: 9, text: "OTHER TYPE" }, + { id: "0", text: "UNKNOWN" }, + { id: "1", text: "BA/ETA" }, + { id: "2", text: "TS/NPS/NS" }, + { id: "3", text: "Blood in EDTA" }, + { id: "4", text: "Acute Sera" }, + { id: "5", text: "Covalescent sera" }, + { id: "6", text: "Biopsy" }, + { id: "7", text: "AMR" }, + { id: "8", text: "Communicable Diseases" }, + { id: "9", text: "OTHER TYPE" }, ]; export const ICMR_CATEGORY = [ diff --git a/src/Components/Patient/SampleFilters.tsx b/src/Components/Patient/SampleFilters.tsx index a7be9852642..db22e54ac80 100644 --- a/src/Components/Patient/SampleFilters.tsx +++ b/src/Components/Patient/SampleFilters.tsx @@ -1,5 +1,4 @@ import { useState, useEffect } from "react"; -import { LegacySelectField } from "../Common/HelperInputFields"; import { SAMPLE_TEST_STATUS, SAMPLE_TEST_RESULT, @@ -10,9 +9,12 @@ import { FacilitySelect } from "../Common/FacilitySelect"; import { FacilityModel } from "../Facility/models"; import { getAnyFacility } from "../../Redux/actions"; import { useDispatch } from "react-redux"; -import { CircularProgress } from "@material-ui/core"; import useMergeState from "../../Common/hooks/useMergeState"; import FiltersSlideover from "../../CAREUI/interactive/FiltersSlideover"; +import CircularProgress from "../Common/components/CircularProgress"; +import { FieldLabel } from "../Form/FormFields/FormField"; +import { SelectFormField } from "../Form/FormFields/SelectFormField"; +import { FieldChangeEvent } from "../Form/FormFields/Utils"; const clearFilterState = { status: "", @@ -36,13 +38,8 @@ export default function UserFilter(props: any) { const [isFacilityLoading, setFacilityLoading] = useState(false); const dispatch: any = useDispatch(); - const handleChange = (event: any) => { - const { name, value } = event.target; - - const filterData: any = { ...filterState }; - filterData[name] = value; - - setFilterState(filterData); + const handleChange = ({ name, value }: FieldChangeEvent) => { + setFilterState({ ...filterState, [name]: value }); }; const applyFilter = () => { @@ -70,6 +67,8 @@ export default function UserFilter(props: any) { fetchData(); }, [dispatch]); + console.log(filterState.sample_type); + return ( -
-
Status
- { - return { id, text: text.replaceAll("_", " ") }; - }), - ]} - onChange={handleChange} - errors="" - /> -
+ { + return { id, text: text.replaceAll("_", " ") }; + })} + optionValue={(option) => option.id} + optionLabel={(option) => option.text} + labelClassName="text-sm" + errorClassName="hidden" + /> -
-
Result
- -
+ option.id} + optionLabel={(option) => option.text} + labelClassName="text-sm" + errorClassName="hidden" + /> -
-
Sample Test Type
- -
+ option.id} + optionLabel={(option) => option.text} + labelClassName="text-sm" + errorClassName="hidden" + />
- Facility -
+ Facility +
{isFacilityLoading ? ( - + ) : ( )} diff --git a/src/Components/Patient/SampleViewAdmin.tsx b/src/Components/Patient/SampleViewAdmin.tsx index b7105ef2fd5..2f1204a34c4 100644 --- a/src/Components/Patient/SampleViewAdmin.tsx +++ b/src/Components/Patient/SampleViewAdmin.tsx @@ -401,7 +401,7 @@ export default function SampleViewAdmin() { "Sample Test Type", "sample_type", SAMPLE_TYPE_CHOICES.find( - (type) => type.id.toString() === qParams.sample_type + (type) => type.id === qParams.sample_type )?.text || "" ), value("Facility", "facility", facilityName), From 293396f651cda1d2d4bfadecb5f1149c0b703136 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Mon, 12 Jun 2023 17:50:15 +0530 Subject: [PATCH 03/30] fixes #5004 (#5629) --- src/Components/Users/UserAdd.tsx | 558 +++++++++++++++---------------- 1 file changed, 276 insertions(+), 282 deletions(-) diff --git a/src/Components/Users/UserAdd.tsx b/src/Components/Users/UserAdd.tsx index fd22eddf470..5a2c580615c 100644 --- a/src/Components/Users/UserAdd.tsx +++ b/src/Components/Users/UserAdd.tsx @@ -1,4 +1,3 @@ -import { Card, CardContent, CircularProgress } from "@material-ui/core"; import loadable from "@loadable/component"; import { Link, navigate } from "raviger"; import { parsePhoneNumberFromString } from "libphonenumber-js/max"; @@ -39,9 +38,11 @@ import Checkbox from "../Common/components/CheckBox"; import DateFormField from "../Form/FormFields/DateFormField"; import { FieldLabel } from "../Form/FormFields/FormField"; import useAppHistory from "../../Common/hooks/useAppHistory"; +import Page from "../Common/components/Page"; +import Card from "../../CAREUI/display/Card"; +import CircularProgress from "../Common/components/CircularProgress"; const Loading = loadable(() => import("../Common/Loading")); -const PageTitle = loadable(() => import("../Common/PageTitle")); interface UserProps { userId?: number; @@ -632,322 +633,315 @@ export const UserAdd = (props: UserProps) => { }; return ( -
- -  Need Help? - - } - justifyContents="justify-between" - backUrl="/users" - /> - - - -
handleSubmit(e)}> -
-
- Facilities - -
- - o.role + ((o.readOnly && " (Read Only)") || "") - } - optionValue={(o) => o.id} - /> - - {state.form.user_type === "Doctor" && ( - <> - - - - - - - )} - - option.name} - optionValue={(option) => option.id} - onChange={handleFieldChange} + +  Need Help? + + } + backUrl="/users" + > + + handleSubmit(e)}> +
+
+ Facilities + - -
- + + o.role + ((o.readOnly && " (Read Only)") || "") + } + optionValue={(o) => o.id} + /> + + {state.form.user_type === "Doctor" && ( + <> + - -
+ + + )} + + option.name} + optionValue={(option) => option.id} + onChange={handleFieldChange} + /> + +
+ +
-
- { - handleFieldChange(e); - setUsernameInput(e.value); - }} - onFocus={() => setUsernameInputInFocus(true)} - onBlur={() => { - setUsernameInputInFocus(false); - }} - /> - {usernameInputInFocus && ( -
-
- {usernameExists !== userExistsEnums.idle && ( - <> - {usernameExists === userExistsEnums.checking ? ( - - checking... - - ) : ( - <> - {usernameExists === userExistsEnums.exists ? ( -
- {" "} - - Username is not available - -
- ) : ( -
- {" "} - - Username is available - -
- )} - - )} - - )} -
-
- {validateRule( - state.form.username?.length >= 2, - "Username should be atleast 2 characters long" - )} -
-
- {validateRule( - /[^.@+_-]/.test( - state.form.username[state.form.username?.length - 1] - ), - "Username can't end with ^ . @ + _ -" - )} -
-
- )} -
+ - + { + handleFieldChange(e); + setUsernameInput(e.value); + }} + onFocus={() => setUsernameInputInFocus(true)} + onBlur={() => { + setUsernameInputInFocus(false); + }} /> - -
- setPasswordInputInFocus(true)} - onBlur={() => setPasswordInputInFocus(false)} - /> - {passwordInputInFocus && ( -
- {validateRule( - state.form.password?.length >= 8, - "Password should be atleast 8 characters long" - )} - {validateRule( - state.form.password !== state.form.password.toUpperCase(), - "Password should contain at least 1 lowercase letter" + {usernameInputInFocus && ( +
+
+ {usernameExists !== userExistsEnums.idle && ( + <> + {usernameExists === userExistsEnums.checking ? ( + + checking... + + ) : ( + <> + {usernameExists === userExistsEnums.exists ? ( +
+ {" "} + + Username is not available + +
+ ) : ( +
+ {" "} + + Username is available + +
+ )} + + )} + )} +
+
{validateRule( - state.form.password !== state.form.password.toLowerCase(), - "Password should contain at least 1 uppercase letter" + state.form.username?.length >= 2, + "Username should be atleast 2 characters long" )} +
+
{validateRule( - /\d/.test(state.form.password), - "Password should contain at least 1 number" + /[^.@+_-]/.test( + state.form.username[state.form.username?.length - 1] + ), + "Username can't end with ^ . @ + _ -" )}
- )} -
-
- setConfirmPasswordInputInFocus(true)} - onBlur={() => setConfirmPasswordInputInFocus(false)} - /> - {confirmPasswordInputInFocus && - state.form.c_password.length > 0 && - validateRule( - state.form.c_password === state.form.password, - "Confirm password should match the entered password" - )} -
+
+ )} +
+ + + +
setPasswordInputInFocus(true)} + onBlur={() => setPasswordInputInFocus(false)} /> + {passwordInputInFocus && ( +
+ {validateRule( + state.form.password?.length >= 8, + "Password should be atleast 8 characters long" + )} + {validateRule( + state.form.password !== state.form.password.toUpperCase(), + "Password should contain at least 1 lowercase letter" + )} + {validateRule( + state.form.password !== state.form.password.toLowerCase(), + "Password should contain at least 1 uppercase letter" + )} + {validateRule( + /\d/.test(state.form.password), + "Password should contain at least 1 number" + )} +
+ )} +
+
setConfirmPasswordInputInFocus(true)} + onBlur={() => setConfirmPasswordInputInFocus(false)} /> - 0 && + validateRule( + state.form.c_password === state.form.password, + "Confirm password should match the entered password" + )} +
+ + + + o.text} + optionValue={(o) => o.text} + /> + + {isStateLoading ? ( + + ) : ( + o.name} + optionValue={(o) => o.id} + onChange={(e) => { + handleFieldChange(e); + if (e) fetchDistricts(e.value); + }} /> + )} + + {isDistrictLoading ? ( + + ) : ( o.text} - optionValue={(o) => o.text} + placeholder="Choose District" + options={districts} + optionLabel={(o) => o.name} + optionValue={(o) => o.id} + onChange={(e) => { + handleFieldChange(e); + if (e) fetchLocalBody(e.value); + }} /> + )} - {isStateLoading ? ( - - ) : ( - o.name} - optionValue={(o) => o.id} - onChange={(e) => { - handleFieldChange(e); - if (e) fetchDistricts(e.value); - }} - /> - )} - - {isDistrictLoading ? ( - + {showLocalbody && + (isLocalbodyLoading ? ( + ) : ( o.name} optionValue={(o) => o.id} - onChange={(e) => { - handleFieldChange(e); - if (e) fetchLocalBody(e.value); - }} /> - )} - - {showLocalbody && - (isLocalbodyLoading ? ( - - ) : ( - <> - o.name} - optionValue={(o) => o.id} - /> - - ))} -
-
- goBack()} /> - -
- - + ))} +
+
+ goBack()} /> + +
+
-
+ ); }; From a19d042773fcecde90b74c0ff2ad1ec1373302d3 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Mon, 12 Jun 2023 17:51:48 +0530 Subject: [PATCH 04/30] fixes #5003 (#5628) --- src/Components/Users/SkillsSlideOver.tsx | 4 +- src/Components/Users/UnlinkSkillDialog.tsx | 76 ++++++++-------------- 2 files changed, 30 insertions(+), 50 deletions(-) diff --git a/src/Components/Users/SkillsSlideOver.tsx b/src/Components/Users/SkillsSlideOver.tsx index 785a2513a18..2a1dfbcbfde 100644 --- a/src/Components/Users/SkillsSlideOver.tsx +++ b/src/Components/Users/SkillsSlideOver.tsx @@ -94,8 +94,8 @@ export default ({ show, setShow, username }: IProps) => { setDeleteSkill(null)} - handleOk={() => removeSkill(username, deleteSkill.id)} + onCancel={() => setDeleteSkill(null)} + onSubmit={() => removeSkill(username, deleteSkill.id)} /> )} void; - handleOk: () => void; + onCancel: () => void; + onSubmit: () => void; } -const UnlinkSkillDialog = (props: ConfirmDialogProps) => { - const { skillName, userName, handleCancel, handleOk } = props; - - const [disable, setDisable] = useState(false); +export default function UnlinkSkillDialog(props: Props) { + const [disabled, setDisabled] = useState(false); const handleSubmit = () => { - handleOk(); - setDisable(true); + props.onSubmit(); + setDisabled(true); }; + return ( - - -
- -
- Are you sure you want to unlink the skill{" "} - {skillName} from user {userName} - ? the user will not have the skill associated anymore. -
-
-
-
- - - - -
+ + Are you sure you want to unlink the skill{" "} + {props.skillName} from user{" "} + {props.userName}? the user will not have the skill + associated anymore. + + } + > ); -}; - -export default UnlinkSkillDialog; +} From 615c7a5bdf6b8a8975e51ee678d223561eac2078 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Mon, 12 Jun 2023 17:52:26 +0530 Subject: [PATCH 05/30] fixes #5625 (#5627) --- src/index.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index dfebfd4fdaf..4df33b7357d 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,4 +1,4 @@ -import ReactDOM from "react-dom"; +import { createRoot } from "react-dom/client"; import reducer from "../src/Redux/Reducer"; import { createTheme, ThemeProvider } from "@material-ui/core/styles"; import App from "./App"; @@ -30,11 +30,11 @@ const theme = createTheme({ }, }); -ReactDOM.render( +const root = createRoot(document.getElementById("root") as HTMLElement); +root.render( - , - document.getElementById("root") + ); From 3f4dc21b85a35c1e3d328ee399f8f59efe1c614a Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Mon, 12 Jun 2023 17:53:00 +0530 Subject: [PATCH 06/30] replaces circular progress bar import (#5619) --- src/Components/Facility/DischargeModal.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Components/Facility/DischargeModal.tsx b/src/Components/Facility/DischargeModal.tsx index 66535bc187f..d15d88a3353 100644 --- a/src/Components/Facility/DischargeModal.tsx +++ b/src/Components/Facility/DischargeModal.tsx @@ -4,7 +4,6 @@ import { Cancel, Submit } from "../Common/components/ButtonV2"; import { useCallback, useEffect, useState } from "react"; import CareIcon from "../../CAREUI/icons/CareIcon"; -import { CircularProgress } from "@material-ui/core"; import ClaimDetailCard from "../HCX/ClaimDetailCard"; import { ConsultationModel } from "./models"; import CreateClaimCard from "../HCX/CreateClaimCard"; @@ -24,6 +23,7 @@ import useConfig from "../../Common/hooks/useConfig"; import { useDispatch } from "react-redux"; import { useMessageListener } from "../../Common/hooks/useMessageListener"; import PrescriptionBuilder from "../Medicine/PrescriptionBuilder"; +import CircularProgress from "../Common/components/CircularProgress"; interface PreDischargeFormInterface { discharge_reason: string; @@ -332,7 +332,7 @@ const DischargeModal = ({
{isSendingDischargeApi ? ( - + ) : ( handlePatientDischarge(false)} From 4877b288f921f2f8ead0bf14f0f83d501fb7e9e5 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Mon, 12 Jun 2023 17:53:48 +0530 Subject: [PATCH 07/30] fixes #4975 (#5618) --- .../Patient/DailyRoundListDetails.tsx | 30 +++++++------------ 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/src/Components/Patient/DailyRoundListDetails.tsx b/src/Components/Patient/DailyRoundListDetails.tsx index c1f45a55780..81fbbd9a39f 100644 --- a/src/Components/Patient/DailyRoundListDetails.tsx +++ b/src/Components/Patient/DailyRoundListDetails.tsx @@ -1,5 +1,3 @@ -import { Button } from "@material-ui/core"; -import { navigate } from "raviger"; import loadable from "@loadable/component"; import moment from "moment"; import { useCallback, useEffect, useState } from "react"; @@ -10,8 +8,9 @@ import { getConsultationDailyRoundsDetails } from "../../Redux/actions"; import { DailyRoundsModel } from "./models"; import { getTemperaturePreference } from "../Common/utils/DevicePreference"; import { celsiusToFahrenheit, fahrenheitToCelsius } from "../../Utils/utils"; +import Page from "../Common/components/Page"; +import ButtonV2 from "../Common/components/ButtonV2"; const Loading = loadable(() => import("../Common/Loading")); -const PageTitle = loadable(() => import("../Common/PageTitle")); const symptomChoices = [...SYMPTOM_CHOICES]; const currentHealthChoices = [...CURRENT_HEALTH_CHANGE]; @@ -119,11 +118,10 @@ export const DailyRoundListDetails = (props: any) => { } return ( -
- +
@@ -137,19 +135,11 @@ export const DailyRoundListDetails = (props: any) => {
- +
@@ -252,6 +242,6 @@ export const DailyRoundListDetails = (props: any) => {
-
+ ); }; From 825fb65f8ee9914dd162a6766684ab3224b5be1b Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Mon, 12 Jun 2023 17:54:14 +0530 Subject: [PATCH 08/30] fixes #4974 (#5617) --- src/Components/Notifications/NotificationsList.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Components/Notifications/NotificationsList.tsx b/src/Components/Notifications/NotificationsList.tsx index 92d826ca97e..9f747ec4fb4 100644 --- a/src/Components/Notifications/NotificationsList.tsx +++ b/src/Components/Notifications/NotificationsList.tsx @@ -9,7 +9,6 @@ import { getPublicKey, } from "../../Redux/actions"; import { useSelector } from "react-redux"; -import { CircularProgress } from "@material-ui/core"; import Spinner from "../Common/Spinner"; import { NOTIFICATION_EVENTS } from "../../Common/constants"; import { Error } from "../../Utils/Notifications.js"; @@ -25,6 +24,7 @@ import SlideOver from "../../CAREUI/interactive/SlideOver"; import ButtonV2 from "../Common/components/ButtonV2"; import SelectMenuV2 from "../Form/SelectMenuV2"; import { useTranslation } from "react-i18next"; +import CircularProgress from "../Common/components/CircularProgress"; const RESULT_LIMIT = 14; @@ -348,7 +348,7 @@ export default function NotificationsList({ if (!offset && isLoading) { manageResults = (
- +
); } else if (data && data.length) { @@ -364,7 +364,7 @@ export default function NotificationsList({ ))} {isLoading && (
- +
)} {totalCount > RESULT_LIMIT && offset < totalCount - RESULT_LIMIT && ( From 572af4c18061134602f4b186a740d096a0124564 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Mon, 12 Jun 2023 18:12:49 +0530 Subject: [PATCH 09/30] fixes #4962 (#5616) Co-authored-by: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> --- src/Components/Facility/Consultations/Beds.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Facility/Consultations/Beds.tsx b/src/Components/Facility/Consultations/Beds.tsx index e7ab1418e4f..5f8e1b2ba12 100644 --- a/src/Components/Facility/Consultations/Beds.tsx +++ b/src/Components/Facility/Consultations/Beds.tsx @@ -9,13 +9,13 @@ import * as Notification from "../../../Utils/Notifications.js"; import Loading from "../../Common/Loading"; import { BedModel, CurrentBed } from "../models"; import { BedSelect } from "../../Common/BedSelect"; -import CircularProgress from "@material-ui/core/CircularProgress"; import { formatDate } from "../../../Utils/utils"; import { FieldLabel } from "../../Form/FormFields/FormField"; import ButtonV2 from "../../Common/components/ButtonV2"; import moment from "moment"; import CareIcon from "../../../CAREUI/icons/CareIcon"; import TextFormField from "../../Form/FormFields/TextFormField"; +import CircularProgress from "../../Common/components/CircularProgress"; const formatDateTime: () => string = () => { const current = new Date(); From 05991fdc4956b250a9432cfbf3f13ab21ea1fef0 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Mon, 12 Jun 2023 18:13:36 +0530 Subject: [PATCH 10/30] fixes #4954 (#5614) Co-authored-by: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> --- src/Components/Facility/FacilityUsers.tsx | 29 +++++++++++------------ 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/Components/Facility/FacilityUsers.tsx b/src/Components/Facility/FacilityUsers.tsx index c5f4100bcd1..5d3685e8566 100644 --- a/src/Components/Facility/FacilityUsers.tsx +++ b/src/Components/Facility/FacilityUsers.tsx @@ -14,8 +14,6 @@ import { import Pagination from "../Common/Pagination"; import { USER_TYPES, RESULTS_PER_PAGE_LIMIT } from "../../Common/constants"; import { FacilityModel } from "../Facility/models"; - -import { IconButton } from "@material-ui/core"; import LinkFacilityDialog from "../Users/LinkFacilityDialog"; import UserDeleteDialog from "../Users/UserDeleteDialog"; import * as Notification from "../../Utils/Notifications.js"; @@ -24,9 +22,10 @@ import UnlinkFacilityDialog from "../Users/UnlinkFacilityDialog"; import { classNames } from "../../Utils/utils"; import CountBlock from "../../CAREUI/display/Count"; import CareIcon from "../../CAREUI/icons/CareIcon"; +import ButtonV2 from "../Common/components/ButtonV2"; +import Page from "../Common/components/Page"; const Loading = loadable(() => import("../Common/Loading")); -const PageTitle = loadable(() => import("../Common/PageTitle")); export default function FacilityUsers(props: any) { const { facilityId } = props; @@ -235,9 +234,10 @@ export default function FacilityUsers(props: any) { >
{facility.name}
- setUnlinkFacilityData({ @@ -247,8 +247,8 @@ export default function FacilityUsers(props: any) { }) } > - - + +
))} @@ -452,7 +452,12 @@ export default function FacilityUsers(props: any) { } return ( -
+ {linkFacility.show && ( )} -
)} -
+
); } From 9e2ee510d5d43f6e7601dc9c193d83587d99d177 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Mon, 12 Jun 2023 18:14:09 +0530 Subject: [PATCH 11/30] fixes #4956 (#5613) --- src/Components/Facility/InventoryList.tsx | 70 ++++++++--------------- 1 file changed, 25 insertions(+), 45 deletions(-) diff --git a/src/Components/Facility/InventoryList.tsx b/src/Components/Facility/InventoryList.tsx index ba78564ed00..e635ecd7bec 100644 --- a/src/Components/Facility/InventoryList.tsx +++ b/src/Components/Facility/InventoryList.tsx @@ -1,14 +1,14 @@ -import React, { useState, useCallback, useEffect } from "react"; +import { useState, useCallback, useEffect } from "react"; import loadable from "@loadable/component"; -import { Button } from "@material-ui/core"; import { navigate } from "raviger"; import { useDispatch } from "react-redux"; import { statusType, useAbortableEffect } from "../../Common/utils"; import { getInventorySummary, getAnyFacility } from "../../Redux/actions"; import Pagination from "../Common/Pagination"; -import { RoleButton } from "../Common/RoleButton"; import { classNames } from "../../Utils/utils"; -const PageTitle = loadable(() => import("../Common/PageTitle")); +import Page from "../Common/components/Page"; +import ButtonV2 from "../Common/components/ButtonV2"; +import { NonReadOnlyUsers } from "../../Utils/AuthorizeFor"; const Loading = loadable(() => import("../Common/Loading")); export default function InventoryList(props: any) { @@ -152,52 +152,32 @@ export default function InventoryList(props: any) { } return ( -
- +
-
-
- - navigate(`/facility/${facilityId}/inventory/add`) - } - disableFor="readOnly" - buttonType="materialUI" - > - Manage Inventory - -
-
- -
+
+ + Manage Inventory + + + Minimum Quantity Required +
{inventoryItem}
-
+
); } From 5f7a1c3ba7a948b8f2b64ed0a7adcc6c7fe43ccf Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Tue, 13 Jun 2023 09:53:56 +0530 Subject: [PATCH 12/30] CareUI: Adds PhoneNumberFormField (#5579) * delete: `LegacyActionTextInputField` * delete: `LegacyPhoneNumberField` * finish making it * minor fixes * fix cypress * fix cypress * uninstall phone number form field and fix errors * minor fixes for support phone * fix cypress test: correct phone number format * landline numbers wont work * fix cypress: facility * fix cypress: patient crud * fix cypress: user crud * fix cypress :) im done with this * fix more cypress * yesssssss! it's over!!!!!!!!!!!!! * Fixed phone number cypress in patient crud * fix disabled logic --------- --- .../external_result.cy.ts | 4 +- cypress/e2e/facility_spec/facility.cy.ts | 6 +- cypress/e2e/patient_spec/patient_crud.cy.ts | 5 +- cypress/e2e/users_spec/user_crud.cy.ts | 14 +- package-lock.json | 79 +----- package.json | 3 +- src/Common/static/countryPhoneAndFlags.json | 1 + src/Components/Common/HelperInputFields.tsx | 236 +----------------- src/Components/ExternalResult/ResultList.tsx | 1 - src/Components/Facility/FacilityCreate.tsx | 2 +- .../Form/FormFields/PhoneNumberFormField.tsx | 114 +++++++-- src/Components/Patient/ManagePatients.tsx | 4 +- src/Components/Patient/PatientRegister.tsx | 6 +- src/Components/Patient/ShiftCreate.tsx | 2 +- src/Components/Resource/ResourceCreate.tsx | 2 +- src/Components/Users/UserAdd.tsx | 8 +- src/react-phone-input-2.d.ts | 70 ------ 17 files changed, 124 insertions(+), 433 deletions(-) create mode 100644 src/Common/static/countryPhoneAndFlags.json delete mode 100644 src/react-phone-input-2.d.ts diff --git a/cypress/e2e/external_results_spec/external_result.cy.ts b/cypress/e2e/external_results_spec/external_result.cy.ts index 830ad77d4aa..22d46060049 100644 --- a/cypress/e2e/external_results_spec/external_result.cy.ts +++ b/cypress/e2e/external_results_spec/external_result.cy.ts @@ -30,11 +30,11 @@ describe("Edit Profile Testing", () => { it("Search by phone number", () => { cy.intercept(/\/api\/v1\/external_result/).as("external_result"); - cy.get("[placeholder='Search by Phone Number']").type("4738743424"); + cy.get("[placeholder='Search by Phone Number']").type("7387434255"); cy.wait("@external_result").then((interception) => { expect(interception.response.statusCode).to.equal(200); }); - cy.url().should("include", "%2B914738743424"); + cy.url().should("include", "%2B91+73874+34255"); }); it("import", () => { diff --git a/cypress/e2e/facility_spec/facility.cy.ts b/cypress/e2e/facility_spec/facility.cy.ts index eead81442e6..14487e45be9 100644 --- a/cypress/e2e/facility_spec/facility.cy.ts +++ b/cypress/e2e/facility_spec/facility.cy.ts @@ -73,7 +73,7 @@ class facility { cy.get("input[id=pincode]").should("exist").clear().type(pincode); - cy.get("input[name=phone_number]").should("exist").type(phone); + cy.get("input[name=phone_number]").should("exist").clear().type(phone); cy.get("input[id=oxygen_capacity]").clear().type(oxygen_capacity); cy.get("input[id=expected_oxygen_requirement]") @@ -138,7 +138,7 @@ describe("Facility", () => { ward: "MANAKKAPADY", address: "some address", pincode: "884656", - phone: "9985784535", + phone: "+919985784535", oxygen_capacity: "20", oxygen_requirement: "30", type_b_cylinders: "20", @@ -185,7 +185,7 @@ describe("Facility", () => { ward: "PAZHAMTHOTTAM", address: " update", pincode: "584675", - phone: "9985784535", + phone: "+919985784535", oxygen_capacity: "30", oxygen_requirement: "40", type_b_cylinders: "23", diff --git a/cypress/e2e/patient_spec/patient_crud.cy.ts b/cypress/e2e/patient_spec/patient_crud.cy.ts index 55d2705490c..c9ce05ad1a7 100644 --- a/cypress/e2e/patient_spec/patient_crud.cy.ts +++ b/cypress/e2e/patient_spec/patient_crud.cy.ts @@ -36,7 +36,7 @@ describe("Patient Creation with consultation", () => { cy.get("#phone_number-div").type(phone_number); cy.get("#emergency_phone_number-div").type(emergency_phone_number); cy.get("[data-testid=date-of-birth] button").click(); - cy.get("div").contains("1").click(); + cy.get("#date-1").click(); cy.get("[data-testid=name] input").type("Test E2E User"); cy.get("[data-testid=Gender] button") .click() @@ -64,7 +64,8 @@ describe("Patient Creation with consultation", () => { .then(() => { cy.get("[role='option']").contains("O+").click(); }); - cy.get("button").get("[data-testid=submit-button]").click(); + cy.get("button[data-testid='submit-button']").click(); + cy.get("h2").should("contain", "Create Consultation"); cy.url().should("include", "/patient"); cy.url().then((url) => { diff --git a/cypress/e2e/users_spec/user_crud.cy.ts b/cypress/e2e/users_spec/user_crud.cy.ts index 405f5a07a41..a742d7277d7 100644 --- a/cypress/e2e/users_spec/user_crud.cy.ts +++ b/cypress/e2e/users_spec/user_crud.cy.ts @@ -11,7 +11,7 @@ const makeid = (length: number) => { }; const makePhoneNumber = () => - "9199" + Math.floor(Math.random() * 99999999).toString(); + "99" + Math.floor(Math.random() * 99999999).toString(); const username = makeid(25); const phone_number = makePhoneNumber(); @@ -44,9 +44,9 @@ describe("User management", () => { cy.wait(1000); cy.get("input[type='checkbox']").click(); cy.wait(1000); - cy.get("[placeholder='Phone Number']").type(phone_number); + cy.get("[name='phone_number']").type(phone_number); cy.wait(1000); - cy.get("[placeholder='WhatsApp Phone Number']").type(alt_phone_number, { + cy.get("[name='alt_phone_number']").type(alt_phone_number, { force: true, }); cy.intercept(/users/).as("check_availability"); @@ -184,7 +184,7 @@ describe("Edit Profile Testing", () => { }); it("Invalid Whatsapp Number of " + username, () => { - const whatsapp_num = "11111-11111"; + const whatsapp_num = "11 1111 111"; cy.get("[placeholder='WhatsApp Number']") .focus() .type(`${backspace}${whatsapp_num}`) @@ -201,7 +201,7 @@ describe("Edit Profile Testing", () => { }); it("Valid Whatsapp Number of " + username, () => { - const whatsapp_num = "91111-11111"; + const whatsapp_num = "91111 11111"; cy.get("[placeholder='WhatsApp Number']") .focus() .type(`${backspace}${whatsapp_num}`) @@ -218,7 +218,7 @@ describe("Edit Profile Testing", () => { }); it("Invalid Phone Number of " + username, () => { - const phone_num = "11111-11111"; + const phone_num = "11 1111 111"; cy.get("[placeholder='Phone Number']") .focus() .type(`${backspace}${phone_num}`) @@ -235,7 +235,7 @@ describe("Edit Profile Testing", () => { }); it("Valid Phone Number of " + username, () => { - const phone_num = "99999-99999"; + const phone_num = "99999 99999"; cy.get("[placeholder='Phone Number']") .focus() .type(`${backspace}${phone_num}`) diff --git a/package-lock.json b/package-lock.json index c5e43cd7cdc..523af4f7edf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -53,7 +53,6 @@ "react-dom": "18.2.0", "react-google-recaptcha": "^2.1.0", "react-i18next": "^11.18.6", - "react-phone-input-2": "^2.15.1", "react-player": "^2.11.0", "react-qr-reader": "^2.2.1", "react-redux": "^8.0.4", @@ -7517,12 +7516,6 @@ "dev": true, "license": "MIT" }, - "node_modules/classnames": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/classnames/-/classnames-2.3.1.tgz", - "integrity": "sha512-OlQdbZ7gLfGarSqxesMesDa5uz7KFbID8Kpq/SxIoNGDqY8lSYs0D+hhtBXhcdB3rcbXArFr7vlHheLk1voeNA==", - "license": "MIT" - }, "node_modules/clean-stack": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", @@ -12532,6 +12525,7 @@ "version": "4.0.8", "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==", + "dev": true, "license": "MIT" }, "node_modules/lodash.isplainobject": { @@ -12541,12 +12535,6 @@ "dev": true, "license": "MIT" }, - "node_modules/lodash.memoize": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", - "integrity": "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==", - "license": "MIT" - }, "node_modules/lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", @@ -12561,24 +12549,12 @@ "dev": true, "license": "MIT" }, - "node_modules/lodash.reduce": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/lodash.reduce/-/lodash.reduce-4.6.0.tgz", - "integrity": "sha512-6raRe2vxCYBhpBu+B+TtNGUzah+hQjVdu3E17wfusjyrXBka2nBS8OH/gjVZ5PvHOhWmIZTYri09Z6n/QfnNMw==", - "license": "MIT" - }, "node_modules/lodash.sortby": { "version": "4.7.0", "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", "integrity": "sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==", "dev": true }, - "node_modules/lodash.startswith": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/lodash.startswith/-/lodash.startswith-4.2.1.tgz", - "integrity": "sha512-XClYR1h4/fJ7H+mmCKppbiBmljN/nGs73iq2SjCT9SF4CBPoUHzLvWmH1GtZMhMBZSiRkHXfeA2RY1eIlJ75ww==", - "license": "MIT" - }, "node_modules/lodash.throttle": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/lodash.throttle/-/lodash.throttle-4.1.1.tgz", @@ -14625,23 +14601,6 @@ "react-dom": "^0.14 || >=15" } }, - "node_modules/react-phone-input-2": { - "version": "2.15.1", - "resolved": "https://registry.npmjs.org/react-phone-input-2/-/react-phone-input-2-2.15.1.tgz", - "integrity": "sha512-W03abwhXcwUoq+vUFvC6ch2+LJYMN8qSOiO889UH6S7SyMCQvox/LF3QWt+cZagZrRdi5z2ON3omnjoCUmlaYw==", - "dependencies": { - "classnames": "^2.2.6", - "lodash.debounce": "^4.0.8", - "lodash.memoize": "^4.1.2", - "lodash.reduce": "^4.6.0", - "lodash.startswith": "^4.2.1", - "prop-types": "^15.7.2" - }, - "peerDependencies": { - "react": "^16.12.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0", - "react-dom": "^16.12.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0" - } - }, "node_modules/react-player": { "version": "2.11.0", "resolved": "https://registry.npmjs.org/react-player/-/react-player-2.11.0.tgz", @@ -23095,11 +23054,6 @@ "integrity": "sha512-SXgeMX9VwDe7iFFaEWkA5AstuER9YKqy4EhHqr4DVqkwmD9rpVimkMKWHdjn30Ja45txyjhSn63lVX69eVCckg==", "dev": true }, - "classnames": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/classnames/-/classnames-2.3.1.tgz", - "integrity": "sha512-OlQdbZ7gLfGarSqxesMesDa5uz7KFbID8Kpq/SxIoNGDqY8lSYs0D+hhtBXhcdB3rcbXArFr7vlHheLk1voeNA==" - }, "clean-stack": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", @@ -26683,7 +26637,8 @@ "lodash.debounce": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", - "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==" + "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==", + "dev": true }, "lodash.isplainobject": { "version": "4.0.6", @@ -26691,11 +26646,6 @@ "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==", "dev": true }, - "lodash.memoize": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", - "integrity": "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==" - }, "lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", @@ -26708,22 +26658,12 @@ "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==", "dev": true }, - "lodash.reduce": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/lodash.reduce/-/lodash.reduce-4.6.0.tgz", - "integrity": "sha512-6raRe2vxCYBhpBu+B+TtNGUzah+hQjVdu3E17wfusjyrXBka2nBS8OH/gjVZ5PvHOhWmIZTYri09Z6n/QfnNMw==" - }, "lodash.sortby": { "version": "4.7.0", "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", "integrity": "sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==", "dev": true }, - "lodash.startswith": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/lodash.startswith/-/lodash.startswith-4.2.1.tgz", - "integrity": "sha512-XClYR1h4/fJ7H+mmCKppbiBmljN/nGs73iq2SjCT9SF4CBPoUHzLvWmH1GtZMhMBZSiRkHXfeA2RY1eIlJ75ww==" - }, "lodash.throttle": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/lodash.throttle/-/lodash.throttle-4.1.1.tgz", @@ -28138,19 +28078,6 @@ "prop-types": "^15.7.2" } }, - "react-phone-input-2": { - "version": "2.15.1", - "resolved": "https://registry.npmjs.org/react-phone-input-2/-/react-phone-input-2-2.15.1.tgz", - "integrity": "sha512-W03abwhXcwUoq+vUFvC6ch2+LJYMN8qSOiO889UH6S7SyMCQvox/LF3QWt+cZagZrRdi5z2ON3omnjoCUmlaYw==", - "requires": { - "classnames": "^2.2.6", - "lodash.debounce": "^4.0.8", - "lodash.memoize": "^4.1.2", - "lodash.reduce": "^4.6.0", - "lodash.startswith": "^4.2.1", - "prop-types": "^15.7.2" - } - }, "react-player": { "version": "2.11.0", "resolved": "https://registry.npmjs.org/react-player/-/react-player-2.11.0.tgz", diff --git a/package.json b/package.json index 816d6099809..ba94c4ed55c 100644 --- a/package.json +++ b/package.json @@ -94,7 +94,6 @@ "react-dom": "18.2.0", "react-google-recaptcha": "^2.1.0", "react-i18next": "^11.18.6", - "react-phone-input-2": "^2.15.1", "react-player": "^2.11.0", "react-qr-reader": "^2.2.1", "react-redux": "^8.0.4", @@ -210,4 +209,4 @@ "engines": { "node": "18.x" } -} \ No newline at end of file +} diff --git a/src/Common/static/countryPhoneAndFlags.json b/src/Common/static/countryPhoneAndFlags.json new file mode 100644 index 00000000000..687b08fdc25 --- /dev/null +++ b/src/Common/static/countryPhoneAndFlags.json @@ -0,0 +1 @@ +{"AD":{"flag":"🇦🇩","name":"Andorra","code":"376"},"AE":{"flag":"🇦🇪","name":"United Arab Emirates","code":"971"},"AF":{"flag":"🇦🇫","name":"Afghanistan","code":"93"},"AG":{"flag":"🇦🇬","name":"Antigua & Barbuda","code":"+1-268"},"AI":{"flag":"🇦🇮","name":"Anguilla","code":"+1-264"},"AL":{"flag":"🇦🇱","name":"Albania","code":"355"},"AM":{"flag":"🇦🇲","name":"Armenia","code":"374"},"AO":{"flag":"🇦🇴","name":"Angola","code":"244"},"AR":{"flag":"🇦🇷","name":"Argentina","code":"54"},"AS":{"flag":"🇦🇸","name":"American Samoa","code":"+1-684"},"AT":{"flag":"🇦🇹","name":"Austria","code":"43"},"AU":{"flag":"🇦🇺","name":"Australia","code":"61"},"AW":{"flag":"🇦🇼","name":"Aruba","code":"297"},"AX":{"flag":"🇦🇽","name":"Åland Islands","code":"+358-18"},"AZ":{"flag":"🇦🇿","name":"Azerbaijan","code":"994"},"BA":{"flag":"🇧🇦","name":"Bosnia & Herzegovina","code":"387"},"BB":{"flag":"🇧🇧","name":"Barbados","code":"+1-246"},"BD":{"flag":"🇧🇩","name":"Bangladesh","code":"880"},"BE":{"flag":"🇧🇪","name":"Belgium","code":"32"},"BF":{"flag":"🇧🇫","name":"Burkina Faso","code":"226"},"BG":{"flag":"🇧🇬","name":"Bulgaria","code":"359"},"BH":{"flag":"🇧🇭","name":"Bahrain","code":"973"},"BI":{"flag":"🇧🇮","name":"Burundi","code":"257"},"BJ":{"flag":"🇧🇯","name":"Benin","code":"229"},"BL":{"flag":"🇧🇱","name":"St. Barthélemy","code":"590"},"BM":{"flag":"🇧🇲","name":"Bermuda","code":"+1-441"},"BN":{"flag":"🇧🇳","name":"Brunei","code":"673"},"BO":{"flag":"🇧🇴","name":"Bolivia","code":"591"},"BQ":{"flag":"🇧🇶","name":"Caribbean Netherlands","code":"599"},"BR":{"flag":"🇧🇷","name":"Brazil","code":"55"},"BS":{"flag":"🇧🇸","name":"Bahamas","code":"+1-242"},"BT":{"flag":"🇧🇹","name":"Bhutan","code":"975"},"BW":{"flag":"🇧🇼","name":"Botswana","code":"267"},"BY":{"flag":"🇧🇾","name":"Belarus","code":"375"},"BZ":{"flag":"🇧🇿","name":"Belize","code":"501"},"CA":{"flag":"🇨🇦","name":"Canada","code":"1"},"CC":{"flag":"🇨🇨","name":"Cocos (Keeling) Islands","code":"61"},"CD":{"flag":"🇨🇩","name":"Congo - Kinshasa","code":"243"},"CF":{"flag":"🇨🇫","name":"Central African Republic","code":"236"},"CG":{"flag":"🇨🇬","name":"Congo - Brazzaville","code":"242"},"CH":{"flag":"🇨🇭","name":"Switzerland","code":"41"},"CI":{"flag":"🇨🇮","name":"Côte d’Ivoire","code":"225"},"CK":{"flag":"🇨🇰","name":"Cook Islands","code":"682"},"CL":{"flag":"🇨🇱","name":"Chile","code":"56"},"CM":{"flag":"🇨🇲","name":"Cameroon","code":"237"},"CN":{"flag":"🇨🇳","name":"China","code":"86"},"CO":{"flag":"🇨🇴","name":"Colombia","code":"57"},"CR":{"flag":"🇨🇷","name":"Costa Rica","code":"506"},"CU":{"flag":"🇨🇺","name":"Cuba","code":"53"},"CV":{"flag":"🇨🇻","name":"Cape Verde","code":"238"},"CW":{"flag":"🇨🇼","name":"Curaçao","code":"599"},"CX":{"flag":"🇨🇽","name":"Christmas Island","code":"61"},"CY":{"flag":"🇨🇾","name":"Cyprus","code":"357"},"CZ":{"flag":"🇨🇿","name":"Czechia","code":"420"},"DE":{"flag":"🇩🇪","name":"Germany","code":"49"},"DJ":{"flag":"🇩🇯","name":"Djibouti","code":"253"},"DK":{"flag":"🇩🇰","name":"Denmark","code":"45"},"DM":{"flag":"🇩🇲","name":"Dominica","code":"+1-767"},"DO":{"flag":"🇩🇴","name":"Dominican Republic","code":"+1-809 and 1-829"},"DZ":{"flag":"🇩🇿","name":"Algeria","code":"213"},"EC":{"flag":"🇪🇨","name":"Ecuador","code":"593"},"EE":{"flag":"🇪🇪","name":"Estonia","code":"372"},"EG":{"flag":"🇪🇬","name":"Egypt","code":"20"},"EH":{"flag":"🇪🇭","name":"Western Sahara","code":"212"},"ER":{"flag":"🇪🇷","name":"Eritrea","code":"291"},"ES":{"flag":"🇪🇸","name":"Spain","code":"34"},"ET":{"flag":"🇪🇹","name":"Ethiopia","code":"251"},"FI":{"flag":"🇫🇮","name":"Finland","code":"358"},"FJ":{"flag":"🇫🇯","name":"Fiji","code":"679"},"FK":{"flag":"🇫🇰","name":"Falkland Islands","code":"500"},"FM":{"flag":"🇫🇲","name":"Micronesia","code":"691"},"FO":{"flag":"🇫🇴","name":"Faroe Islands","code":"298"},"FR":{"flag":"🇫🇷","name":"France","code":"33"},"GA":{"flag":"🇬🇦","name":"Gabon","code":"241"},"GB":{"flag":"🇬🇧","name":"United Kingdom","code":"44"},"GD":{"flag":"🇬🇩","name":"Grenada","code":"+1-473"},"GE":{"flag":"🇬🇪","name":"Georgia","code":"995"},"GF":{"flag":"🇬🇫","name":"French Guiana","code":"594"},"GG":{"flag":"🇬🇬","name":"Guernsey","code":"+44-1481"},"GH":{"flag":"🇬🇭","name":"Ghana","code":"233"},"GI":{"flag":"🇬🇮","name":"Gibraltar","code":"350"},"GL":{"flag":"🇬🇱","name":"Greenland","code":"299"},"GM":{"flag":"🇬🇲","name":"Gambia","code":"220"},"GN":{"flag":"🇬🇳","name":"Guinea","code":"224"},"GP":{"flag":"🇬🇵","name":"Guadeloupe","code":"590"},"GQ":{"flag":"🇬🇶","name":"Equatorial Guinea","code":"240"},"GR":{"flag":"🇬🇷","name":"Greece","code":"30"},"GT":{"flag":"🇬🇹","name":"Guatemala","code":"502"},"GU":{"flag":"🇬🇺","name":"Guam","code":"+1-671"},"GW":{"flag":"🇬🇼","name":"Guinea-Bissau","code":"245"},"GY":{"flag":"🇬🇾","name":"Guyana","code":"592"},"HK":{"flag":"🇭🇰","name":"Hong Kong SAR China","code":"852"},"HM":{"flag":"🇭🇲","name":"Heard & McDonald Islands","code":" "},"HN":{"flag":"🇭🇳","name":"Honduras","code":"504"},"HR":{"flag":"🇭🇷","name":"Croatia","code":"385"},"HT":{"flag":"🇭🇹","name":"Haiti","code":"509"},"HU":{"flag":"🇭🇺","name":"Hungary","code":"36"},"ID":{"flag":"🇮🇩","name":"Indonesia","code":"62"},"IE":{"flag":"🇮🇪","name":"Ireland","code":"353"},"IL":{"flag":"🇮🇱","name":"Israel","code":"972"},"IM":{"flag":"🇮🇲","name":"Isle of Man","code":"+44-1624"},"IN":{"flag":"🇮🇳","name":"India","code":"91"},"IO":{"flag":"🇮🇴","name":"British Indian Ocean Territory","code":"246"},"IQ":{"flag":"🇮🇶","name":"Iraq","code":"964"},"IR":{"flag":"🇮🇷","name":"Iran","code":"98"},"IS":{"flag":"🇮🇸","name":"Iceland","code":"354"},"IT":{"flag":"🇮🇹","name":"Italy","code":"39"},"JE":{"flag":"🇯🇪","name":"Jersey","code":"+44-1534"},"JM":{"flag":"🇯🇲","name":"Jamaica","code":"+1-876"},"JO":{"flag":"🇯🇴","name":"Jordan","code":"962"},"JP":{"flag":"🇯🇵","name":"Japan","code":"81"},"KE":{"flag":"🇰🇪","name":"Kenya","code":"254"},"KG":{"flag":"🇰🇬","name":"Kyrgyzstan","code":"996"},"KH":{"flag":"🇰🇭","name":"Cambodia","code":"855"},"KI":{"flag":"🇰🇮","name":"Kiribati","code":"686"},"KM":{"flag":"🇰🇲","name":"Comoros","code":"269"},"KN":{"flag":"🇰🇳","name":"St. Kitts & Nevis","code":"+1-869"},"KP":{"flag":"🇰🇵","name":"North Korea","code":"850"},"KR":{"flag":"🇰🇷","name":"South Korea","code":"82"},"KW":{"flag":"🇰🇼","name":"Kuwait","code":"965"},"KY":{"flag":"🇰🇾","name":"Cayman Islands","code":"+1-345"},"KZ":{"flag":"🇰🇿","name":"Kazakhstan","code":"7"},"LA":{"flag":"🇱🇦","name":"Laos","code":"856"},"LB":{"flag":"🇱🇧","name":"Lebanon","code":"961"},"LC":{"flag":"🇱🇨","name":"St. Lucia","code":"+1-758"},"LI":{"flag":"🇱🇮","name":"Liechtenstein","code":"423"},"LK":{"flag":"🇱🇰","name":"Sri Lanka","code":"94"},"LR":{"flag":"🇱🇷","name":"Liberia","code":"231"},"LS":{"flag":"🇱🇸","name":"Lesotho","code":"266"},"LT":{"flag":"🇱🇹","name":"Lithuania","code":"370"},"LU":{"flag":"🇱🇺","name":"Luxembourg","code":"352"},"LV":{"flag":"🇱🇻","name":"Latvia","code":"371"},"LY":{"flag":"🇱🇾","name":"Libya","code":"218"},"MA":{"flag":"🇲🇦","name":"Morocco","code":"212"},"MC":{"flag":"🇲🇨","name":"Monaco","code":"377"},"MD":{"flag":"🇲🇩","name":"Moldova","code":"373"},"ME":{"flag":"🇲🇪","name":"Montenegro","code":"382"},"MF":{"flag":"🇲🇫","name":"St. Martin","code":"590"},"MG":{"flag":"🇲🇬","name":"Madagascar","code":"261"},"MH":{"flag":"🇲🇭","name":"Marshall Islands","code":"692"},"MK":{"flag":"🇲🇰","name":"North Macedonia","code":"389"},"ML":{"flag":"🇲🇱","name":"Mali","code":"223"},"MM":{"flag":"🇲🇲","name":"Myanmar (Burma)","code":"95"},"MN":{"flag":"🇲🇳","name":"Mongolia","code":"976"},"MO":{"flag":"🇲🇴","name":"Macao SAR China","code":"853"},"MP":{"flag":"🇲🇵","name":"Northern Mariana Islands","code":"+1-670"},"MQ":{"flag":"🇲🇶","name":"Martinique","code":"596"},"MR":{"flag":"🇲🇷","name":"Mauritania","code":"222"},"MS":{"flag":"🇲🇸","name":"Montserrat","code":"+1-664"},"MT":{"flag":"🇲🇹","name":"Malta","code":"356"},"MU":{"flag":"🇲🇺","name":"Mauritius","code":"230"},"MV":{"flag":"🇲🇻","name":"Maldives","code":"960"},"MW":{"flag":"🇲🇼","name":"Malawi","code":"265"},"MX":{"flag":"🇲🇽","name":"Mexico","code":"52"},"MY":{"flag":"🇲🇾","name":"Malaysia","code":"60"},"MZ":{"flag":"🇲🇿","name":"Mozambique","code":"258"},"NA":{"flag":"🇳🇦","name":"Namibia","code":"264"},"NC":{"flag":"🇳🇨","name":"New Caledonia","code":"687"},"NE":{"flag":"🇳🇪","name":"Niger","code":"227"},"NF":{"flag":"🇳🇫","name":"Norfolk Island","code":"672"},"NG":{"flag":"🇳🇬","name":"Nigeria","code":"234"},"NI":{"flag":"🇳🇮","name":"Nicaragua","code":"505"},"NL":{"flag":"🇳🇱","name":"Netherlands","code":"31"},"NO":{"flag":"🇳🇴","name":"Norway","code":"47"},"NP":{"flag":"🇳🇵","name":"Nepal","code":"977"},"NR":{"flag":"🇳🇷","name":"Nauru","code":"674"},"NU":{"flag":"🇳🇺","name":"Niue","code":"683"},"NZ":{"flag":"🇳🇿","name":"New Zealand","code":"64"},"OM":{"flag":"🇴🇲","name":"Oman","code":"968"},"PA":{"flag":"🇵🇦","name":"Panama","code":"507"},"PE":{"flag":"🇵🇪","name":"Peru","code":"51"},"PF":{"flag":"🇵🇫","name":"French Polynesia","code":"689"},"PG":{"flag":"🇵🇬","name":"Papua New Guinea","code":"675"},"PH":{"flag":"🇵🇭","name":"Philippines","code":"63"},"PK":{"flag":"🇵🇰","name":"Pakistan","code":"92"},"PL":{"flag":"🇵🇱","name":"Poland","code":"48"},"PM":{"flag":"🇵🇲","name":"St. Pierre & Miquelon","code":"508"},"PN":{"flag":"🇵🇳","name":"Pitcairn Islands","code":"870"},"PR":{"flag":"🇵🇷","name":"Puerto Rico","code":"+1-787 and 1-939"},"PS":{"flag":"🇵🇸","name":"Palestinian Territories","code":"970"},"PT":{"flag":"🇵🇹","name":"Portugal","code":"351"},"PW":{"flag":"🇵🇼","name":"Palau","code":"680"},"PY":{"flag":"🇵🇾","name":"Paraguay","code":"595"},"QA":{"flag":"🇶🇦","name":"Qatar","code":"974"},"RE":{"flag":"🇷🇪","name":"Réunion","code":"262"},"RO":{"flag":"🇷🇴","name":"Romania","code":"40"},"RS":{"flag":"🇷🇸","name":"Serbia","code":"381"},"RU":{"flag":"🇷🇺","name":"Russia","code":"7"},"RW":{"flag":"🇷🇼","name":"Rwanda","code":"250"},"SA":{"flag":"🇸🇦","name":"Saudi Arabia","code":"966"},"SB":{"flag":"🇸🇧","name":"Solomon Islands","code":"677"},"SC":{"flag":"🇸🇨","name":"Seychelles","code":"248"},"SD":{"flag":"🇸🇩","name":"Sudan","code":"249"},"SE":{"flag":"🇸🇪","name":"Sweden","code":"46"},"SG":{"flag":"🇸🇬","name":"Singapore","code":"65"},"SH":{"flag":"🇸🇭","name":"St. Helena","code":"290"},"SI":{"flag":"🇸🇮","name":"Slovenia","code":"386"},"SJ":{"flag":"🇸🇯","name":"Svalbard & Jan Mayen","code":"47"},"SK":{"flag":"🇸🇰","name":"Slovakia","code":"421"},"SL":{"flag":"🇸🇱","name":"Sierra Leone","code":"232"},"SM":{"flag":"🇸🇲","name":"San Marino","code":"378"},"SN":{"flag":"🇸🇳","name":"Senegal","code":"221"},"SO":{"flag":"🇸🇴","name":"Somalia","code":"252"},"SR":{"flag":"🇸🇷","name":"Suriname","code":"597"},"SS":{"flag":"🇸🇸","name":"South Sudan","code":"211"},"ST":{"flag":"🇸🇹","name":"São Tomé & Príncipe","code":"239"},"SV":{"flag":"🇸🇻","name":"El Salvador","code":"503"},"SX":{"flag":"🇸🇽","name":"Sint Maarten","code":"599"},"SY":{"flag":"🇸🇾","name":"Syria","code":"963"},"SZ":{"flag":"🇸🇿","name":"Eswatini","code":"268"},"TC":{"flag":"🇹🇨","name":"Turks & Caicos Islands","code":"+1-649"},"TD":{"flag":"🇹🇩","name":"Chad","code":"235"},"TG":{"flag":"🇹🇬","name":"Togo","code":"228"},"TH":{"flag":"🇹🇭","name":"Thailand","code":"66"},"TJ":{"flag":"🇹🇯","name":"Tajikistan","code":"992"},"TK":{"flag":"🇹🇰","name":"Tokelau","code":"690"},"TL":{"flag":"🇹🇱","name":"Timor-Leste","code":"670"},"TM":{"flag":"🇹🇲","name":"Turkmenistan","code":"993"},"TN":{"flag":"🇹🇳","name":"Tunisia","code":"216"},"TO":{"flag":"🇹🇴","name":"Tonga","code":"676"},"TR":{"flag":"🇹🇷","name":"Turkey","code":"90"},"TT":{"flag":"🇹🇹","name":"Trinidad & Tobago","code":"+1-868"},"TV":{"flag":"🇹🇻","name":"Tuvalu","code":"688"},"TW":{"flag":"🇹🇼","name":"Taiwan","code":"886"},"TZ":{"flag":"🇹🇿","name":"Tanzania","code":"255"},"UA":{"flag":"🇺🇦","name":"Ukraine","code":"380"},"UG":{"flag":"🇺🇬","name":"Uganda","code":"256"},"UM":{"flag":"🇺🇲","name":"U.S. Outlying Islands","code":"1"},"US":{"flag":"🇺🇸","name":"United States","code":"1"},"UY":{"flag":"🇺🇾","name":"Uruguay","code":"598"},"UZ":{"flag":"🇺🇿","name":"Uzbekistan","code":"998"},"VA":{"flag":"🇻🇦","name":"Vatican City","code":"379"},"VC":{"flag":"🇻🇨","name":"St. Vincent & Grenadines","code":"+1-784"},"VE":{"flag":"🇻🇪","name":"Venezuela","code":"58"},"VG":{"flag":"🇻🇬","name":"British Virgin Islands","code":"+1-284"},"VI":{"flag":"🇻🇮","name":"U.S. Virgin Islands","code":"+1-340"},"VN":{"flag":"🇻🇳","name":"Vietnam","code":"84"},"VU":{"flag":"🇻🇺","name":"Vanuatu","code":"678"},"WF":{"flag":"🇼🇫","name":"Wallis & Futuna","code":"681"},"WS":{"flag":"🇼🇸","name":"Samoa","code":"685"},"YE":{"flag":"🇾🇪","name":"Yemen","code":"967"},"YT":{"flag":"🇾🇹","name":"Mayotte","code":"262"},"ZA":{"flag":"🇿🇦","name":"South Africa","code":"27"},"ZM":{"flag":"🇿🇲","name":"Zambia","code":"260"},"ZW":{"flag":"🇿🇼","name":"Zimbabwe","code":"263"}} \ No newline at end of file diff --git a/src/Components/Common/HelperInputFields.tsx b/src/Components/Common/HelperInputFields.tsx index a98172c015b..8d1de0b3b74 100644 --- a/src/Components/Common/HelperInputFields.tsx +++ b/src/Components/Common/HelperInputFields.tsx @@ -1,5 +1,3 @@ -import "react-phone-input-2/lib/high-res.css"; - import { Checkbox, Chip, @@ -21,13 +19,10 @@ import { KeyboardDateTimePicker, MuiPickersUtilsProvider, } from "@material-ui/pickers"; -import PhoneInput, { ICountryData } from "react-phone-input-2"; -import React, { ChangeEvent, useEffect, useState } from "react"; +import React from "react"; import Autocomplete from "@material-ui/lab/Autocomplete"; import Box from "@material-ui/core/Box"; -import ButtonV2 from "./components/ButtonV2"; -import CareIcon from "../../CAREUI/icons/CareIcon"; import DateFnsUtils from "@date-io/date-fns"; import FormControl from "@material-ui/core/FormControl"; import { MaterialUiPickersDate } from "@material-ui/pickers/typings/date"; @@ -74,10 +69,6 @@ export interface DefaultNativeSelectInputProps extends NativeSelectInputProps { // Type Declarations type TextFieldPropsExtended = TextFieldProps & { errors: string }; -type ActionTextFieldProps = TextFieldPropsExtended & { - actionIcon?: React.ReactElement; - action?: () => void; -}; interface DateInputFieldProps extends DatePickerProps { value: string; @@ -136,54 +127,6 @@ export const LegacyTextInputField = (props: TextFieldPropsExtended) => { ); }; -/** - * Deprecated. Use `TextFormField` instead. - */ -export const LegacyActionTextInputField = (props: ActionTextFieldProps) => { - const { onChange, type, errors, onKeyDown } = props; - const inputType = type === "number" || type === "float" ? "text" : type; - const handleChange = (event: React.ChangeEvent) => { - if (typeof onChange !== "function") { - return; - } - if (type === "number" && event.target.value) { - event.target.value = event.target.value.replace(/\D/, ""); - } - if (type === "float" && event.target.value) { - event.target.value = event.target.value.replace(/(?!\.)\D/, ""); - } - onChange(event); - }; - const handleKeyDown = (event: React.KeyboardEvent) => { - if (typeof onKeyDown !== "function") { - return; - } - onKeyDown(event); - }; - return ( -
-
- - {props.actionIcon && ( -
- {props.actionIcon} -
- )} -
- -
- ); -}; - /** * Deprecated. Use `TextAreaFormField` instead. */ @@ -564,180 +507,3 @@ export const LegacyAutoCompleteAsyncField = ( ); }; - -/** - * Deprecated. Use `PhoneNumberFormField` instead. - */ -export const LegacyPhoneNumberField = (props: any) => { - const { - label, - placeholder, - errors, - onChange, - onlyIndia, - value, - turnOffAutoFormat, - disabled, - countryCodeEditable = false, - className, - id, - name, - requiredError = false, - } = props; - const [maxLength, setMaxLength] = useState(15); - const [enableTollFree, setEnableTollFree] = useState( - value.startsWith("1800") - ); - const countryRestriction = onlyIndia ? { onlyCountries: ["in"] } : {}; - const [randId, setRandId] = useState(""); - - useEffect(() => { - if (value.startsWith("1800")) { - setEnableTollFree(true); - } else { - setEnableTollFree(false); - } - }, [value]); - - useEffect(() => { - setRandId( - Math.random() - .toString(36) - .replace(/[^a-z]+/g, "a") - ); - }, []); - - const setFocus = () => { - setTimeout(() => { - const input = document.querySelector(`div#${randId} > div.visible input`); - if (input instanceof HTMLElement) { - input.focus(); - } - }, 10); - }; - - useEffect(() => { - if (enableTollFree) { - if (value.startsWith("1800")) { - setMaxLength(11); - } else { - setMaxLength(15); - } - } else { - setMaxLength(15); - } - }, [value]); - - const handleChange = ( - value: string, - data: Partial, - event: ChangeEvent, - formattedValue: string - ) => { - let phone = value; - if (phone.startsWith("91")) { - phone = phone.replace("91", ""); - } - if (phone.startsWith("1800")) { - setEnableTollFree(true); - setFocus(); - onChange(phone); - } else { - if (!value.startsWith("91") && !value.startsWith("1800")) { - onChange(`91${formattedValue}`); - } else { - onChange(formattedValue); - } - if (!value.startsWith("1800")) { - setEnableTollFree(false); - setFocus(); - } - } - setFocus(); - }; - - return ( - <> - {label && {label}} -
-
-
- -
- - { - onChange("+91"); - setEnableTollFree(false); - setFocus(); - }} - > - {" "} - - -
-
- - { - onChange("+91"); - setEnableTollFree(false); - setFocus(); - }} - > - - -
-
- {errors && } - - ); -}; diff --git a/src/Components/ExternalResult/ResultList.tsx b/src/Components/ExternalResult/ResultList.tsx index 78332376d3b..c39f22d4df4 100644 --- a/src/Components/ExternalResult/ResultList.tsx +++ b/src/Components/ExternalResult/ResultList.tsx @@ -281,7 +281,6 @@ export default function ResultList() { value={qParams.mobile_number || "+91"} onChange={(event) => updateQuery({ [event.name]: event.value })} placeholder="Search by Phone Number" - noAutoFormat />
diff --git a/src/Components/Facility/FacilityCreate.tsx b/src/Components/Facility/FacilityCreate.tsx index 6b4fe5e8769..d30015ddd8b 100644 --- a/src/Components/Facility/FacilityCreate.tsx +++ b/src/Components/Facility/FacilityCreate.tsx @@ -869,7 +869,7 @@ export const FacilityCreate = (props: FacilityProps) => { {...field("phone_number")} label={t("emergency_contact_number")} required - onlyIndia + disableCountry />
= phoneCodesJson; -type Props = FormFieldBaseProps & { +interface Props extends FormFieldBaseProps { placeholder?: string; autoComplete?: string; - noAutoFormat?: boolean; - onlyIndia?: boolean; - countryCodeEditable?: boolean; -}; + disableCountry?: boolean; +} -const PhoneNumberFormField = (props: Props) => { +export default function PhoneNumberFormField(props: Props) { const field = useFormFieldPropsResolver(props as any); + + const asYouType = useMemo(() => { + const asYouType = new AsYouType(); + + asYouType.reset(); + + if (field.value) { + asYouType.input(field.value); + } else { + asYouType.input("+91"); + field.handleChange(asYouType.getNumberValue()); + } + + return asYouType; + }, []); + + const setValue = (value: string) => { + asYouType.reset(); + field.handleChange(asYouType.input(value)); + }; + return ( - +
+ setValue(e.target.value)} + disabled={field.disabled} + /> + {!props.disableCountry && ( +
+ + +
+ )} +
); -}; +} -export default PhoneNumberFormField; +const conditionPhoneCode = (code: string) => { + code = code.split(" ")[0]; + return code.startsWith("+") ? code : "+" + code; +}; diff --git a/src/Components/Patient/ManagePatients.tsx b/src/Components/Patient/ManagePatients.tsx index aa52650c266..192633b3ce0 100644 --- a/src/Components/Patient/ManagePatients.tsx +++ b/src/Components/Patient/ManagePatients.tsx @@ -111,7 +111,7 @@ export const PatientManager = () => { const setPhoneNum = (phone_number: string) => { setPhoneNumber(phone_number); - if (phone_number.length === 15) { + if (phone_number.length >= 13) { setPhoneNumberError(""); updateQuery({ phone_number }); return; @@ -128,7 +128,7 @@ export const PatientManager = () => { const setEmergencyPhoneNum = (emergency_phone_number: string) => { setEmergencyPhoneNumber(emergency_phone_number); - if (emergency_phone_number.length === 15) { + if (emergency_phone_number.length >= 13) { setEmergencyPhoneNumberError(""); updateQuery({ emergency_phone_number }); return; diff --git a/src/Components/Patient/PatientRegister.tsx b/src/Components/Patient/PatientRegister.tsx index 919a27ef2d6..780064c83d0 100644 --- a/src/Components/Patient/PatientRegister.tsx +++ b/src/Components/Patient/PatientRegister.tsx @@ -105,8 +105,8 @@ const initForm: any = { name: "", age: "", gender: "", - phone_number: "", - emergency_phone_number: "", + phone_number: "+91", + emergency_phone_number: null, blood_group: "", disease_status: diseaseStatus[2], is_declared_positive: "false", @@ -362,7 +362,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { fetchDistricts(res.data.district_object.state), fetchLocalBody(res.data.district), fetchWards(res.data.local_body), - duplicateCheck("+91" + res.data.mobile_number), + duplicateCheck(res.data.mobile_number), ]); setShowImport(false); diff --git a/src/Components/Patient/ShiftCreate.tsx b/src/Components/Patient/ShiftCreate.tsx index e863ae3fd84..c4bb347cfcb 100644 --- a/src/Components/Patient/ShiftCreate.tsx +++ b/src/Components/Patient/ShiftCreate.tsx @@ -314,7 +314,7 @@ export const ShiftCreate = (props: patientShiftProps) => { label="Contact person phone" name="refering_facility_contact_number" required - onlyIndia + disableCountry value={state.form.refering_facility_contact_number} onChange={handleFormFieldChange} error={state.errors.refering_facility_contact_number} diff --git a/src/Components/Resource/ResourceCreate.tsx b/src/Components/Resource/ResourceCreate.tsx index 14b0a593599..2f1203bdc91 100644 --- a/src/Components/Resource/ResourceCreate.tsx +++ b/src/Components/Resource/ResourceCreate.tsx @@ -244,7 +244,7 @@ export default function ResourceCreate(props: resourceProps) { label={t("contact_phone")} name="refering_facility_contact_number" required - onlyIndia + disableCountry value={state.form.refering_facility_contact_number} onChange={handleFormFieldChange} error={state.errors.refering_facility_contact_number} diff --git a/src/Components/Users/UserAdd.tsx b/src/Components/Users/UserAdd.tsx index 5a2c580615c..3bad31a865d 100644 --- a/src/Components/Users/UserAdd.tsx +++ b/src/Components/Users/UserAdd.tsx @@ -87,8 +87,8 @@ const initForm: UserForm = { first_name: "", last_name: "", email: "", - phone_number: "", - alt_phone_number: "", + phone_number: "+91", + alt_phone_number: "+91", age: 0, date_of_birth: null, state: 0, @@ -713,7 +713,7 @@ export const UserAdd = (props: UserProps) => { placeholder="Phone Number" label="Phone Number" required - onlyIndia + disableCountry /> { placeholder="WhatsApp Phone Number" label="Whatsapp Number" disabled={phoneIsWhatsApp} - onlyIndia + disableCountry />
diff --git a/src/react-phone-input-2.d.ts b/src/react-phone-input-2.d.ts deleted file mode 100644 index 0b2ad81da0f..00000000000 --- a/src/react-phone-input-2.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -declare module "react-phone-input-2" { - import React from "react"; - - export interface ICountryData { - name: string; - dialCode: string; - countryCode: string; - format: string; - } - - interface IStyle { - containerClass?: string; - inputClass?: string; - buttonClass?: string; - dropdownClass?: string; - searchClass?: string; - - containerStyle?: React.CSSProperties; - inputStyle?: React.CSSProperties; - buttonStyle?: React.CSSProperties; - dropdownStyle?: React.CSSProperties; - searchStyle?: React.CSSProperties; - } - - interface IPhoneInputEventsProps { - onChange?( - value: string, - data: ICountryData | {}, - event: ChangeEvent, - formattedValue: string - ): void; - onFocus?( - event: React.FocusEvent, - data: ICountryData | {} - ): void; - onBlur?( - event: React.FocusEvent, - data: ICountryData | {} - ): void; - onClick?( - event: React.MouseEvent, - data: ICountryData | {} - ): void; - onKeyDown?(event: React.KeyboardEvent): void; - } - - export interface IPhoneInputProps extends IPhoneInputEventsProps, IStyle { - country?: string; - value?: string; - onlyCountries?: string[]; - preferredCountries?: string[]; - excludeCountries?: string[]; - placeholder?: string; - searchPlaceholder?: string; - inputProps?: object; - - autoFormat?: boolean; - disabled?: boolean; - disableDropdown?: boolean; - disableCountryCode?: boolean; - enableAreaCodes?: boolean; - enableTerritories?: boolean; - enableLongNumbers?: boolean; - countryCodeEditable?: boolean; - enableSearch?: boolean; - disableSearchIcon?: boolean; - } - const PhoneInput: React.FC; - export default PhoneInput; -} From 8aa29c3b551c064ca87e2e210edaba443d75f9ba Mon Sep 17 00:00:00 2001 From: Khavin Shankar Date: Tue, 13 Jun 2023 13:26:24 +0530 Subject: [PATCH 13/30] Added `cypress passed` label --- .github/workflows/cypress.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 3a67eee5614..8a67bd22ccd 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -58,6 +58,20 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NODE_OPTIONS: --max_old_space_size=4096 + - name: Remove cypress passed label on failure 🏷️ + uses: actions-ecosystem/action-remove-labels@v1 + if: failure() + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + labels: cypress passed + + - name: Add cypress passed label on success 🏷️ + uses: actions-ecosystem/action-add-labels@v1 + if: success() + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + labels: cypress passed + - name: Remove cypress failed label on success 🏷️ uses: actions-ecosystem/action-remove-labels@v1 if: success() From 614ad7eaae6572f9638e705d8159308051191572 Mon Sep 17 00:00:00 2001 From: Khavin Shankar Date: Tue, 13 Jun 2023 13:38:01 +0530 Subject: [PATCH 14/30] Added write permissions to add labels --- .github/workflows/cypress.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index 8a67bd22ccd..7c160ce029b 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -11,6 +11,7 @@ on: jobs: cypress-run: + permissions: write-all if: github.repository == 'coronasafe/care_fe' runs-on: ubuntu-latest steps: From 93b0045d3367334f56d47a090555ae2df161bd62 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Tue, 13 Jun 2023 14:48:24 +0530 Subject: [PATCH 15/30] Fix the user number --- cypress/e2e/users_spec/user_crud.cy.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/cypress/e2e/users_spec/user_crud.cy.ts b/cypress/e2e/users_spec/user_crud.cy.ts index a742d7277d7..af5153bad12 100644 --- a/cypress/e2e/users_spec/user_crud.cy.ts +++ b/cypress/e2e/users_spec/user_crud.cy.ts @@ -11,7 +11,7 @@ const makeid = (length: number) => { }; const makePhoneNumber = () => - "99" + Math.floor(Math.random() * 99999999).toString(); + "99" + Math.floor(Math.random() * 9000000000 + 1000000000).toString(); const username = makeid(25); const phone_number = makePhoneNumber(); @@ -46,15 +46,13 @@ describe("User management", () => { cy.wait(1000); cy.get("[name='phone_number']").type(phone_number); cy.wait(1000); - cy.get("[name='alt_phone_number']").type(alt_phone_number, { - force: true, - }); + cy.get("[name='alt_phone_number']").type(alt_phone_number); cy.intercept(/users/).as("check_availability"); cy.get("[id='date_of_birth']").click(); cy.get("div").contains("20").click(); cy.get("[id='year-0']").click(); cy.get("[id='date-1']").click(); - cy.get("[name='username']").type(username, { force: true }); + cy.get("[name='username']").type(username); cy.wait("@check_availability").its("response.statusCode").should("eq", 200); cy.get("[name='password']").type("#@Cypress_test123"); cy.get("[name='c_password']").type("#@Cypress_test123"); @@ -63,9 +61,7 @@ describe("User management", () => { cy.get("[name='email']").type("cypress@tester.com"); cy.get("[id='gender'] > div > button").click(); cy.get("div").contains("Male").click(); - cy.get("button[id='submit']").contains("Save User").click({ - force: true, - }); + cy.get("button[id='submit']").contains("Save User").click(); cy.verifyNotification("User added successfully"); }); From cc8017a638ff8ada0f582db3e73758deb3323227 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Tue, 13 Jun 2023 15:35:18 +0530 Subject: [PATCH 16/30] CareUI: Adds `UserAutocompleteFormField` and used it in "Assigned To" filter field of Shifting (#5626) * CareUI: Adds `UserAutocompleteFormField` and used it in Assigned To field of Shifting Filter * delete unused `UserSelect2` * fix cypress * fix cypress * fix cypress * fix cypress * oops uncomment it * Update src/Components/Shifting/ListFilter.tsx --------- --- cypress/e2e/shifting_spec/filter.cy.ts | 7 +- src/Common/hooks/useAsyncOptions.ts | 6 +- .../Common/UserAutocompleteFormField.tsx | 46 ++++++++ src/Components/Common/UserSelect2.tsx | 109 ------------------ src/Components/Shifting/ListFilter.tsx | 31 ++--- src/Components/Users/models.tsx | 4 +- 6 files changed, 68 insertions(+), 135 deletions(-) create mode 100644 src/Components/Common/UserAutocompleteFormField.tsx delete mode 100644 src/Components/Common/UserSelect2.tsx diff --git a/cypress/e2e/shifting_spec/filter.cy.ts b/cypress/e2e/shifting_spec/filter.cy.ts index 2429648946c..3e755db5c66 100644 --- a/cypress/e2e/shifting_spec/filter.cy.ts +++ b/cypress/e2e/shifting_spec/filter.cy.ts @@ -32,8 +32,11 @@ describe("Shifting section filter", () => { it("filter by assigned to user", () => { cy.intercept(/\/api\/v1\/users/).as("users_filter"); - cy.get("[name='assigned_to']").type("cypress").wait("@users_filter"); - cy.get("[name='assigned_to']").type("{downarrow}{enter}"); + cy.get("[id='assigned_to']") + .wait(100) + .type("cypress") + .wait("@users_filter"); + cy.get("[id='assigned_to']").wait(100).type("{downarrow}{enter}"); cy.contains("Apply").click(); }); diff --git a/src/Common/hooks/useAsyncOptions.ts b/src/Common/hooks/useAsyncOptions.ts index 7ed5121e2a1..f0a1c895430 100644 --- a/src/Common/hooks/useAsyncOptions.ts +++ b/src/Common/hooks/useAsyncOptions.ts @@ -4,6 +4,7 @@ import { useDispatch } from "react-redux"; interface IUseAsyncOptionsArgs { debounceInterval?: number; + queryResponseExtractor?: (data: any) => any; } /** @@ -40,7 +41,10 @@ export function useAsyncOptions>( debounce(async (action: any) => { setIsLoading(true); const res = await dispatch(action); - if (res?.data) setQueryOptions(res.data as T[]); + if (res?.data) + setQueryOptions( + args?.queryResponseExtractor?.(res.data) ?? (res.data as T[]) + ); setIsLoading(false); }, args?.debounceInterval ?? 300), [dispatch, args?.debounceInterval] diff --git a/src/Components/Common/UserAutocompleteFormField.tsx b/src/Components/Common/UserAutocompleteFormField.tsx new file mode 100644 index 00000000000..ba2e2cd19e6 --- /dev/null +++ b/src/Components/Common/UserAutocompleteFormField.tsx @@ -0,0 +1,46 @@ +import { useAsyncOptions } from "../../Common/hooks/useAsyncOptions"; +import { getUserList } from "../../Redux/actions"; +import { Autocomplete } from "../Form/FormFields/Autocomplete"; +import FormField from "../Form/FormFields/FormField"; +import { + FormFieldBaseProps, + useFormFieldPropsResolver, +} from "../Form/FormFields/Utils"; +import { UserModel } from "../Users/models"; + +type Props = FormFieldBaseProps & { + placeholder?: string; +}; + +export default function UserAutocompleteFormField(props: Props) { + const field = useFormFieldPropsResolver(props as any); + const { fetchOptions, isLoading, options } = useAsyncOptions( + "id", + { queryResponseExtractor: (data) => data.results } + ); + + return ( + + `${option.user_type}`} + optionValue={(option) => option} + onQuery={(query) => + fetchOptions(getUserList({ limit: 5, offset: 0, search_text: query })) + } + isLoading={isLoading} + /> + + ); +} + +const getUserFullName = (user: UserModel) => { + const personName = user.first_name + " " + user.last_name; + return personName.trim().length > 0 ? personName : user.username || ""; +}; diff --git a/src/Components/Common/UserSelect2.tsx b/src/Components/Common/UserSelect2.tsx deleted file mode 100644 index 612c02871c7..00000000000 --- a/src/Components/Common/UserSelect2.tsx +++ /dev/null @@ -1,109 +0,0 @@ -import React, { useCallback, useState } from "react"; -import { useDispatch } from "react-redux"; -import { getUserList } from "../../Redux/actions"; -import { LegacyAutoCompleteAsyncField } from "../Common/HelperInputFields"; -import { UserModel } from "../Users/models"; -import { debounce } from "lodash"; -interface UserSelectProps { - name?: string | ""; - margin?: string; - errors: string; - className?: string; - multiple?: boolean; - selected: UserModel | UserModel[] | null; - setSelected: (selected: UserModel | UserModel[] | null) => void; -} - -export const UserSelect = (props: UserSelectProps) => { - const { - name, - multiple, - selected, - setSelected, - margin, - errors, - className = "", - } = props; - const dispatchAction: any = useDispatch(); - const [userLoading, isUserLoading] = useState(false); - const [hasSearchText, setHasSearchText] = useState(false); - const [UserList, setUserList] = useState>([]); - - const getPersonName = (user: any) => { - const personName = user.first_name + " " + user.last_name; - - return personName.trim().length > 0 ? personName : user.username; - }; - - const handleValueChange = (current: UserModel | UserModel[] | null) => { - if (!current) { - setUserList([]); - isUserLoading(false); - setHasSearchText(false); - } - setSelected(current); - }; - - const handelSearch = (e: any) => { - isUserLoading(true); - setHasSearchText(!!e.target.value); - onUserSearch(e.target.value); - }; - - const onUserSearch = useCallback( - debounce(async (text: string) => { - if (text) { - const params = { - limit: 50, - offset: 0, - search_text: text, - }; - - const res = await dispatchAction(getUserList(params)); - - if (res && res.data) { - setUserList(res.data.results); - } - isUserLoading(false); - } else { - setUserList([]); - isUserLoading(false); - } - }, 300), - [] - ); - - return ( - handleValueChange(selected)} - loading={userLoading} - placeholder="Search by name or username" - noOptionsText={ - hasSearchText - ? "No user found, please try again" - : "Start typing to begin search" - } - renderOption={(option: any) => ( -
- - {getPersonName(option)} - ({option.user_type}) - -
- )} - getOptionSelected={(option: any, value: any) => option.id === value.id} - getOptionLabel={(option: any) => - `${getPersonName(option)} - (${option.user_type})` - } - filterOptions={(options: UserModel[]) => options} - errors={errors} - className={className} - /> - ); -}; diff --git a/src/Components/Shifting/ListFilter.tsx b/src/Components/Shifting/ListFilter.tsx index 099926f78e4..ed6baa7d32d 100644 --- a/src/Components/Shifting/ListFilter.tsx +++ b/src/Components/Shifting/ListFilter.tsx @@ -18,7 +18,6 @@ import { FieldLabel } from "../Form/FormFields/FormField"; import FiltersSlideover from "../../CAREUI/interactive/FiltersSlideover"; import { LegacySelectField } from "../Common/HelperInputFields"; import PhoneNumberFormField from "../Form/FormFields/PhoneNumberFormField"; -import { UserSelect } from "../Common/UserSelect2"; import moment from "moment"; import { navigate } from "raviger"; import parsePhoneNumberFromString from "libphonenumber-js"; @@ -26,6 +25,7 @@ import useConfig from "../../Common/hooks/useConfig"; import { useDispatch } from "react-redux"; import useMergeState from "../../Common/hooks/useMergeState"; import { useTranslation } from "react-i18next"; +import UserAutocompleteFormField from "../Common/UserAutocompleteFormField"; const clearFilterState = { orgin_facility: "", @@ -57,7 +57,6 @@ export default function ListFilter(props: any) { const [isOriginLoading, setOriginLoading] = useState(false); const [isShiftingLoading, setShiftingLoading] = useState(false); const [isAssignedLoading, setAssignedLoading] = useState(false); - const [isAssignedUserLoading, setAssignedUserLoading] = useState(false); const { t } = useTranslation(); const shiftStatusOptions = ( @@ -143,16 +142,13 @@ export default function ListFilter(props: any) { useEffect(() => { async function fetchData() { if (filter.assigned_to) { - setAssignedUserLoading(true); const res = await dispatch(getUserList({ id: filter.assigned_to })); - if (res && res.data && res.data.count) { setFilterState({ ...filterState, assigned_user_ref: res.data.results[0], }); } - setAssignedUserLoading(false); } } fetchData(); @@ -345,23 +341,16 @@ export default function ListFilter(props: any) {
-
- {t("assigned_to")} - {isAssignedUserLoading ? ( - - ) : ( - setAssignedUser(obj)} - className="shifting-page-filter-dropdown" - errors={""} - /> - )} -
+ setAssignedUser(value)} + errorClassName="hidden" + /> -
+
{t("ordering")} Date: Tue, 13 Jun 2023 15:35:44 +0530 Subject: [PATCH 17/30] Tailwinds `CoverImageEditModal.tsx` (#5615) * fixes #4951 * fix hint breaks --------- --- .../Facility/CoverImageEditModal.tsx | 39 +++++++++---------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/src/Components/Facility/CoverImageEditModal.tsx b/src/Components/Facility/CoverImageEditModal.tsx index 0ea44f9e479..cb28aa8c3ab 100644 --- a/src/Components/Facility/CoverImageEditModal.tsx +++ b/src/Components/Facility/CoverImageEditModal.tsx @@ -1,4 +1,3 @@ -import { Modal } from "@material-ui/core"; import axios from "axios"; import { ChangeEventHandler, @@ -20,6 +19,7 @@ import CareIcon from "../../CAREUI/icons/CareIcon"; import * as Notification from "../../Utils/Notifications.js"; import { useTranslation } from "react-i18next"; import { LocalStorageKeys } from "../../Common/constants"; +import DialogModal from "../Common/Dialog"; interface Props { open: boolean; onClose: (() => void) | undefined; @@ -173,26 +173,24 @@ const CoverImageEditModal = ({ {t("max_size_for_image_uploaded_should_be")} 1mb.
{t("allowed_formats_are")} jpg,png,jpeg. -
{t("recommended_aspect_ratio_for")} facility cover photo is 1:1 ); return ( - -
+ +
{!isCameraOpen ? ( -
-
- - {t("edit_cover_photo")} - - {facility.name} -
- + {hasImage ? ( <> -
+
{facility.name}

- {t("no_cover_photo_uploaded_for_this_facility")}.
- {commonHint} + {t("no_cover_photo_uploaded_for_this_facility")}. {commonHint}

)} -
+
) : ( -
-
+
+
{t("capture_cover_photo")} {facility.name}
-
+
{!previewImage ? ( <> )}
- + ); }; From b0a070726c55a47c187979a7034d00feea374c16 Mon Sep 17 00:00:00 2001 From: Rohan Malik Date: Tue, 13 Jun 2023 15:36:20 +0530 Subject: [PATCH 18/30] All the buttons are not in full width during responsive view, fixed (#5608) * adding responsiveness to record button * fixed all the button * fixed responsiveness bug in record, upload and open camera button --- src/Components/Patient/FileUpload.tsx | 50 ++++++++++++++------------- src/Utils/VoiceRecorder.tsx | 1 + 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/Components/Patient/FileUpload.tsx b/src/Components/Patient/FileUpload.tsx index 00deb0e734d..6f1d7c78195 100644 --- a/src/Components/Patient/FileUpload.tsx +++ b/src/Components/Patient/FileUpload.tsx @@ -1525,7 +1525,7 @@ export const FileUpload = (props: FileUploadProps) => { InputLabelProps={{ shrink: !!audioName }} value={audioName} disabled={uploadStarted} - onChange={(e: any) => { + onChange={(e: React.ChangeEvent) => { setAudioName(e.target.value); }} errors={audioFileError} @@ -1534,7 +1534,7 @@ export const FileUpload = (props: FileUploadProps) => { Please allow browser permission before you start speaking
{audiouploadStarted ? ( - + ) : (
{audioBlobExists && ( @@ -1542,9 +1542,7 @@ export const FileUpload = (props: FileUploadProps) => { { - deleteAudioBlob(); - }} + onClick={deleteAudioBlob} > Delete @@ -1558,12 +1556,7 @@ export const FileUpload = (props: FileUploadProps) => { /> {audioBlobExists && (
- { - handleAudioUpload(); - }} - className="w-full" - > + Save @@ -1598,7 +1591,7 @@ export const FileUpload = (props: FileUploadProps) => { {uploadStarted ? ( ) : ( -
+
{({ isAuthorized }) => isAuthorized ? ( @@ -1617,18 +1610,27 @@ export const FileUpload = (props: FileUploadProps) => { ) } - setModalOpenForCamera(true)}> - - Open Camera - - handleUpload({ status })} - > - - {t("upload")} - +
+ setModalOpenForCamera(true)} + > + + Open Camera + +
+ +
+ handleUpload({ status })} + > + + {t("upload")} + +
)} {file && ( diff --git a/src/Utils/VoiceRecorder.tsx b/src/Utils/VoiceRecorder.tsx index fdf45e819d0..60f03dba5a2 100644 --- a/src/Utils/VoiceRecorder.tsx +++ b/src/Utils/VoiceRecorder.tsx @@ -67,6 +67,7 @@ export const VoiceRecorder = (props: any) => { {t("record")} From 23c90a87f0cccbb13cd982a679da8efd98f48d79 Mon Sep 17 00:00:00 2001 From: Yogesh Bhutkar Date: Tue, 13 Jun 2023 15:37:16 +0530 Subject: [PATCH 19/30] Updated the FontAwesomeIcons with CareIcons, replaced PageTitle with Page component and migrated tooltip. (#5642) * Added tooltip custom care component * Migrated PageTitle to Page * Added CareIcons and fixed implementation of tooltip * Changed button with ButtonV2 * Fixed color coding the text inside a button --------- --- package-lock.json | 2 +- src/Components/Facility/InventoryLog.tsx | 110 ++++++++++++----------- 2 files changed, 58 insertions(+), 54 deletions(-) diff --git a/package-lock.json b/package-lock.json index 523af4f7edf..3c736b57355 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30554,4 +30554,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/Components/Facility/InventoryLog.tsx b/src/Components/Facility/InventoryLog.tsx index 64b631200b7..cebb7d95326 100644 --- a/src/Components/Facility/InventoryLog.tsx +++ b/src/Components/Facility/InventoryLog.tsx @@ -10,9 +10,10 @@ import { } from "../../Redux/actions"; import { statusType, useAbortableEffect } from "../../Common/utils"; import Pagination from "../Common/Pagination"; -import { Tooltip } from "@material-ui/core"; import { formatDate } from "../../Utils/utils"; -const PageTitle = loadable(() => import("../Common/PageTitle")); +import Page from "../Common/components/Page.js"; +import CareIcon from "../../CAREUI/icons/CareIcon.js"; +import ButtonV2 from "../Common/components/ButtonV2.js"; const Loading = loadable(() => import("../Common/Loading")); export default function InventoryLog(props: any) { @@ -146,43 +147,49 @@ export default function InventoryLog(props: any) {

- +
+ {inventoryItem.probable_accident ? (
Unmarks this transaction as accident
This action will not affect the total stock.
) : ( -
+
Marks this transaction as accident
This action will not affect the total stock. To delete the transaction, create another transaction that undos the effect of this, or click Delete Last Entry.
- ) - } - arrow={true} - > -
+ + {inventoryItem.probable_accident ? ( + flagFacility(inventoryItem.external_id)} + disabled={saving} + variant="primary" + > + + + UnMark - ) : ( - - + + ) : ( + flagFacility(inventoryItem.external_id)} + disabled={saving} + variant="danger" + > + + Mark as Accident - )} - - + + )} +
)); @@ -245,7 +252,7 @@ export default function InventoryLog(props: any) { return (
- -
-
-
-

Item: {itemName}

- {current_stock > 0 && ( - + > +
+
+
+

Item: {itemName}

+ {current_stock > 0 && ( +
+
Deletes the last transaction by creating an equivalent undo transaction and marks both the transactions as accident.
- } - arrow={true} - > - - - )} + + removeLastInventoryLog(inventory[0].item_object.id) + } + disabled={saving} + > + + + Delete Last Entry + + +
+ )} +
+ {inventoryItem}
- {inventoryItem}
-
+
); } From 5f0db99cee30507100a6696ee02ef484d147a135 Mon Sep 17 00:00:00 2001 From: Gokulram A Date: Tue, 13 Jun 2023 15:37:55 +0530 Subject: [PATCH 20/30] Changed UI for Live/Discharged Tabs in Patients Page (#5543) * changed live/discharged tab change UI * made the advanced filter button ui consistent across all pages * replaced fontawesome icons with care icons in few places * fixed advanced filters button length * fixed cypress tests * removed commented code --------- Co-authored-by: Khavin Shankar --- cypress/e2e/resource_spec/resources.cy.ts | 8 +-- cypress/e2e/shifting_spec/shifting.cy.ts | 8 +-- src/CAREUI/interactive/FiltersSlideover.tsx | 4 +- src/Components/Assets/AssetsList.tsx | 2 +- .../Common/components/SwitchTabs.tsx | 37 +++++++++++ src/Components/ExternalResult/ResultList.tsx | 14 ++--- src/Components/Patient/ManagePatients.tsx | 52 ++++++++------- src/Components/Resource/ListView.tsx | 34 ++++------ src/Components/Resource/ResourceBoardView.tsx | 63 +++++++------------ src/Components/Shifting/BoardView.tsx | 59 +++++++---------- src/Components/Shifting/ListView.tsx | 40 +++++------- 11 files changed, 156 insertions(+), 165 deletions(-) create mode 100644 src/Components/Common/components/SwitchTabs.tsx diff --git a/cypress/e2e/resource_spec/resources.cy.ts b/cypress/e2e/resource_spec/resources.cy.ts index 5a9287964b1..099e782277a 100644 --- a/cypress/e2e/resource_spec/resources.cy.ts +++ b/cypress/e2e/resource_spec/resources.cy.ts @@ -27,15 +27,15 @@ describe("Resource Page", () => { cy.wait("@resource").then((interception) => { expect(interception.response.statusCode).to.equal(200); }); - cy.contains("Active").should("have.class", "bg-gray-200"); - cy.contains("Completed").should("have.class", "bg-white"); + cy.contains("Active").should("have.class", "text-primary-500"); + cy.contains("Completed").should("have.class", "text-white"); cy.intercept(/\/api\/v1\/resource/).as("resource"); cy.contains("Active").click(); cy.wait("@resource").then((interception) => { expect(interception.response.statusCode).to.equal(200); }); - cy.contains("Active").should("have.class", "bg-white"); - cy.contains("Completed").should("have.class", "bg-gray-200"); + cy.contains("Active").should("have.class", "text-white"); + cy.contains("Completed").should("have.class", "text-primary-500"); }); it("switch between list view and board view", () => { diff --git a/cypress/e2e/shifting_spec/shifting.cy.ts b/cypress/e2e/shifting_spec/shifting.cy.ts index e32b701bee8..bc78e55f175 100644 --- a/cypress/e2e/shifting_spec/shifting.cy.ts +++ b/cypress/e2e/shifting_spec/shifting.cy.ts @@ -32,12 +32,12 @@ describe("Shifting Page", () => { it("switch between active/archived", () => { cy.intercept(/\/api\/v1\/shift/).as("shifting"); cy.contains("Archived").click().wait("@shifting"); - cy.contains("Active").should("have.class", "bg-gray-200"); - cy.contains("Archived").should("have.class", "bg-white"); + cy.contains("Active").should("have.class", "text-primary-500"); + cy.contains("Archived").should("have.class", "text-white"); cy.intercept(/\/api\/v1\/shift/).as("shifting"); cy.contains("Active").click().wait("@shifting"); - cy.contains("Active").should("have.class", "bg-white"); - cy.contains("Archived").should("have.class", "bg-gray-200"); + cy.contains("Active").should("have.class", "text-white"); + cy.contains("Archived").should("have.class", "text-primary-500"); }); afterEach(() => { diff --git a/src/CAREUI/interactive/FiltersSlideover.tsx b/src/CAREUI/interactive/FiltersSlideover.tsx index 4e2d68cd6c5..581dcd25cd0 100644 --- a/src/CAREUI/interactive/FiltersSlideover.tsx +++ b/src/CAREUI/interactive/FiltersSlideover.tsx @@ -55,8 +55,8 @@ export const AdvancedFilterButton = ({ onClick }: { onClick: () => void }) => { className="bg-white w-full sm:w-auto" onClick={onClick} > - - {t("advanced_filters")} + + {t("advanced_filters")} ); }; diff --git a/src/Components/Assets/AssetsList.tsx b/src/Components/Assets/AssetsList.tsx index a9755ff79d5..2db93ecb7c5 100644 --- a/src/Components/Assets/AssetsList.tsx +++ b/src/Components/Assets/AssetsList.tsx @@ -360,7 +360,7 @@ const AssetsList = () => { />
setIsScannerActive(true)} > Scan Asset QR diff --git a/src/Components/Common/components/SwitchTabs.tsx b/src/Components/Common/components/SwitchTabs.tsx new file mode 100644 index 00000000000..5fee897d97e --- /dev/null +++ b/src/Components/Common/components/SwitchTabs.tsx @@ -0,0 +1,37 @@ +export default function SwitchTabs(props: { + activeTab: boolean; + onClickTab1: () => void; + onClickTab2: () => void; + Tab1: string; + Tab2: string; +}) { + return ( +
+
+
+ {props.Tab1} +
+
+ {props.Tab2} +
+
+ ); +} diff --git a/src/Components/ExternalResult/ResultList.tsx b/src/Components/ExternalResult/ResultList.tsx index c39f22d4df4..a22fa4ae1dd 100644 --- a/src/Components/ExternalResult/ResultList.tsx +++ b/src/Components/ExternalResult/ResultList.tsx @@ -14,6 +14,7 @@ import CareIcon from "../../CAREUI/icons/CareIcon"; import ExportMenu from "../Common/Export"; import PhoneNumberFormField from "../Form/FormFields/PhoneNumberFormField"; import CountBlock from "../../CAREUI/display/Count"; +import { AdvancedFilterButton } from "../../CAREUI/interactive/FiltersSlideover"; import Page from "../Common/components/Page"; const Loading = loadable(() => import("../Common/Loading")); @@ -285,17 +286,12 @@ export default function ResultList() {
-
- -
+ advancedFilter.setShow(true)} + />
+ [ badge("Name", "name"), diff --git a/src/Components/Patient/ManagePatients.tsx b/src/Components/Patient/ManagePatients.tsx index 192633b3ce0..fe00c0f1c75 100644 --- a/src/Components/Patient/ManagePatients.tsx +++ b/src/Components/Patient/ManagePatients.tsx @@ -29,12 +29,12 @@ import { ExportMenu } from "../Common/Export"; import FacilitiesSelectDialogue from "../ExternalResult/FacilitiesSelectDialogue"; import { FieldChangeEvent } from "../Form/FormFields/Utils"; import FilterBadge from "../../CAREUI/display/FilterBadge"; -import NavTabs from "../Common/NavTabs"; import PatientFilter from "./PatientFilter"; import PhoneNumberFormField from "../Form/FormFields/PhoneNumberFormField"; import RecordMeta from "../../CAREUI/display/RecordMeta"; import SearchInput from "../Form/SearchInput"; import SortDropdownMenu from "../Common/SortDropdown"; +import SwitchTabs from "../Common/components/SwitchTabs"; import SwipeableViews from "react-swipeable-views"; import { Tooltip } from "@material-ui/core"; import loadable from "@loadable/component"; @@ -729,30 +729,46 @@ export const PatientManager = () => { }} />
- -
- {showDoctorConnect && ( - { - setShowDoctors(true); - }} - > - -

Doctor Connect

-
- )} +
+ { qParams.facility ? navigate(`/facility/${qParams.facility}/patient`) : setShowDialog(true); }} + className="w-full lg:w-fit" >

Add Patient Details

+
+
+ updateQuery({ is_active: "True" })} + onClickTab2={() => updateQuery({ is_active: "False" })} + activeTab={tabValue ? true : false} + /> + {showDoctorConnect && ( + { + setShowDoctors(true); + }} + > + +

Doctor Connect

+
+ )} + advancedFilter.setShow(true)} /> { count={totalCount} loading={isLoading} icon={"user-injured"} - containerClass="pb-8" + containerClass="pb-10" />
{/*
@@ -941,14 +957,6 @@ export const PatientManager = () => {
- updateQuery({ is_active: tab ? "False" : "True" })} - options={[ - { value: 0, label: "Live" }, - { value: 1, label: "Discharged" }, - ]} - active={tabValue} - />
{managePatients}
diff --git a/src/Components/Resource/ListView.tsx b/src/Components/Resource/ListView.tsx index 222bce4f3a0..15c5bd4baba 100644 --- a/src/Components/Resource/ListView.tsx +++ b/src/Components/Resource/ListView.tsx @@ -13,6 +13,10 @@ import BadgesList from "./BadgesList"; import { formatDate } from "../../Utils/utils"; import useFilters from "../../Common/hooks/useFilters"; import { ExportButton } from "../Common/Export"; +import ButtonV2 from "../Common/components/ButtonV2"; +import { useTranslation } from "react-i18next"; +import { AdvancedFilterButton } from "../../CAREUI/interactive/FiltersSlideover"; +import CareIcon from "../../CAREUI/icons/CareIcon"; const Loading = loadable(() => import("../Common/Loading")); const PageTitle = loadable(() => import("../Common/PageTitle")); @@ -24,6 +28,7 @@ export default function ListView() { const [data, setData] = useState([]); const [totalCount, setTotalCount] = useState(0); const [isLoading, setIsLoading] = useState(false); + const { t } = useTranslation(); const onBoardViewBtnClick = () => navigate("/resource/board-view", { query: qParams }); @@ -199,28 +204,13 @@ export default function ListView() { />
-
-
- -
-
- -
+
+ + + {t("board_view")} + + + advancedFilter.setShow(true)} />
diff --git a/src/Components/Resource/ResourceBoardView.tsx b/src/Components/Resource/ResourceBoardView.tsx index 616c23b38fb..e3f147f41b6 100644 --- a/src/Components/Resource/ResourceBoardView.tsx +++ b/src/Components/Resource/ResourceBoardView.tsx @@ -10,6 +10,11 @@ import BadgesList from "./BadgesList"; import { formatFilter } from "./Commons"; import useFilters from "../../Common/hooks/useFilters"; import { ExportButton } from "../Common/Export"; +import SwitchTabs from "../Common/components/SwitchTabs"; +import ButtonV2 from "../Common/components/ButtonV2"; +import { useTranslation } from "react-i18next"; +import { AdvancedFilterButton } from "../../CAREUI/interactive/FiltersSlideover"; +import CareIcon from "../../CAREUI/icons/CareIcon"; const Loading = loadable(() => import("../Common/Loading")); const PageTitle = loadable(() => import("../Common/PageTitle")); @@ -25,6 +30,7 @@ export default function BoardView() { // eslint-disable-next-line const [isLoading, setIsLoading] = useState(false); const appliedFilters = formatFilter(qParams); + const { t } = useTranslation(); const onListViewBtnClick = () => { navigate("/resource/list-view", { query: qParams }); @@ -33,7 +39,7 @@ export default function BoardView() { return (
-
+
-
-
- - -
-
- - + />
diff --git a/src/Components/Shifting/BoardView.tsx b/src/Components/Shifting/BoardView.tsx index 79c85fb7572..d4d95d93e70 100644 --- a/src/Components/Shifting/BoardView.tsx +++ b/src/Components/Shifting/BoardView.tsx @@ -17,6 +17,10 @@ import useFilters from "../../Common/hooks/useFilters"; import { useState } from "react"; import { useTranslation } from "react-i18next"; import withScrolling from "react-dnd-scrolling"; +import ButtonV2 from "../Common/components/ButtonV2"; +import SwitchTabs from "../Common/components/SwitchTabs"; +import { AdvancedFilterButton } from "../../CAREUI/interactive/FiltersSlideover"; +import CareIcon from "../../CAREUI/icons/CareIcon"; const Loading = loadable(() => import("../Common/Loading")); const PageTitle = loadable(() => import("../Common/PageTitle")); @@ -55,7 +59,7 @@ export default function BoardView() { return (
-
+
-
+
updateQuery({ [e.name]: e.value })} placeholder={t("search_patient")} /> -
- - -
-
- - + />
diff --git a/src/Components/Shifting/ListView.tsx b/src/Components/Shifting/ListView.tsx index 6a8739df848..a90f66b41c4 100644 --- a/src/Components/Shifting/ListView.tsx +++ b/src/Components/Shifting/ListView.tsx @@ -21,6 +21,8 @@ import useConfig from "../../Common/hooks/useConfig"; import { useDispatch, useSelector } from "react-redux"; import useFilters from "../../Common/hooks/useFilters"; import { useTranslation } from "react-i18next"; +import { AdvancedFilterButton } from "../../CAREUI/interactive/FiltersSlideover"; +import CareIcon from "../../CAREUI/icons/CareIcon"; const Loading = loadable(() => import("../Common/Loading")); @@ -302,30 +304,20 @@ export default function ListView() {
{/* dummy div to align space as per board view */}
-
-
- -
-
- -
+
+ + navigate("/shifting/board-view", { query: qParams }) + } + > + + {t("board_view")} + + + advancedFilter.setShow(true)} + />
} From 5ee4f150e21ea8226f8dcf0c54b590b5326f9bb4 Mon Sep 17 00:00:00 2001 From: Shivam Jha <86483059+ShivamJhaa@users.noreply.github.com> Date: Tue, 13 Jun 2023 15:38:19 +0530 Subject: [PATCH 21/30] Added cypress test for asset creation (#5632) * Added test for patient creation * Fixed patient creation suite * Fixed edit and update test cases and removed unwanted changes * Tried a fix * Added tests for asset creation * Nits * Update Facility name * Update facility name * Trying a fix for the failure * FIxed failing test * Reverted unwanted changes --------- --- cypress/e2e/assets_spec/assets.cy.ts | 62 ++++++++++++++++++++- cypress/e2e/patient_spec/patient_crud.cy.ts | 1 + src/Components/Assets/AssetsList.tsx | 5 +- src/Components/Facility/AssetCreate.tsx | 56 ++++++++++++++++--- vite.config.ts | 1 + 5 files changed, 114 insertions(+), 11 deletions(-) diff --git a/cypress/e2e/assets_spec/assets.cy.ts b/cypress/e2e/assets_spec/assets.cy.ts index 3dbedeb2098..87bbbafa6c3 100644 --- a/cypress/e2e/assets_spec/assets.cy.ts +++ b/cypress/e2e/assets_spec/assets.cy.ts @@ -1,8 +1,12 @@ /// import { cy, describe, before, beforeEach, it } from "local-cypress"; +import { v4 as uuidv4 } from "uuid"; -describe("Assets List", () => { +const phone_number = "9" + parseInt((Math.random() * 10 ** 9).toString()); +const serial_no = parseInt((Math.random() * 10 ** 10).toString()); + +describe("Asset", () => { before(() => { cy.loginByApi("devdistrictadmin", "Coronasafe@123"); cy.saveLocalStorage(); @@ -13,6 +17,62 @@ describe("Assets List", () => { cy.awaitUrl("/assets"); }); + it("Create an Asset", () => { + cy.get("button").should("contain", "Create Asset"); + cy.get("[data-testid=create-asset-buttom] button").click(); + cy.get("input[name='facilities']") + .type("Dummy Facility 1") + .then(() => { + cy.get("[role='option']").contains("Dummy Facility 1").click(); + }); + cy.get("button").should("contain", "Select"); + cy.get("button").get("#submit").click(); + cy.get("[data-testid=asset-name-input] input").type("New Test Asset"); + cy.get("[data-testid=asset-location-input] input").type( + "Camera Location{enter}" + ); + cy.get("[data-testid=asset-type-input] button") + .click() + .then(() => { + cy.get("li").contains("Internal").click(); + }); + cy.get("[data-testid=asset-class-input] button") + .click() + .then(() => { + cy.get("li").contains("ONVIF Camera").click(); + }); + cy.get("[data-testid=asset-description-input] textarea").type( + "Test Description" + ); + cy.get("[data-testid=asset-working-status-input] li") + .contains("Working") + .click(); + const qr_id = uuidv4(); + cy.get("[data-testid=asset-qr-id-input] input").type(qr_id); + cy.get("[data-testid=asset-manufacturer-input] input").type( + "Manufacturer's Name" + ); + cy.get("[data-testid=asset-warranty-input] input").type("2025-12-25"); + cy.get("[data-testid=asset-support-name-input] input").type( + "Customer Support's Name" + ); + cy.get("#customer-support-phone-div").type(phone_number); + cy.get("[data-testid=asset-support-email-input] input").type( + "email@support.com" + ); + cy.get("[data-testid=asset-vendor-name-input] input").type("Vendor's Name"); + cy.get("[data-testid=asset-serial-number-input] input").type(serial_no); + cy.get("[data-testid=asset-last-serviced-on-input] input").type( + "2021-12-25" + ); + cy.get("[data-testid=asset-notes-input] textarea").type( + "Test note for asset creation!" + ); + cy.wait(500); + cy.get("#submit").contains("Create Asset").click(); + cy.verifyNotification("Asset created successfully"); + }); + it("Search Asset Name", () => { const initialUrl = cy.url(); cy.get("[name='search']").type("dummy camera 30"); diff --git a/cypress/e2e/patient_spec/patient_crud.cy.ts b/cypress/e2e/patient_spec/patient_crud.cy.ts index c9ce05ad1a7..2f4522be1bd 100644 --- a/cypress/e2e/patient_spec/patient_crud.cy.ts +++ b/cypress/e2e/patient_spec/patient_crud.cy.ts @@ -157,6 +157,7 @@ describe("Patient Creation with consultation", () => { cy.get("button#submit").should("be.visible").click(); cy.get("[data-testid='return-to-patient-dashboard']").click(); }); + afterEach(() => { cy.saveLocalStorage(); }); diff --git a/src/Components/Assets/AssetsList.tsx b/src/Components/Assets/AssetsList.tsx index 2db93ecb7c5..a04286420f6 100644 --- a/src/Components/Assets/AssetsList.tsx +++ b/src/Components/Assets/AssetsList.tsx @@ -366,7 +366,10 @@ const AssetsList = () => { Scan Asset QR
-
+
{ {/* General Details Section */} {sectionTitle("General Details")} {/* Asset Name */} -
+
{ Asset Location -
+
@@ -540,7 +548,11 @@ const AssetCreate = (props: AssetProps) => {
{/* Asset Type */}
-
+
{
{/* Asset Class */} -
+
{
{/* Description */} -
+
{ />
{/* Divider */} -
+

{ />
{/* Working Status */} -
+
{
{/* Asset QR ID */}
-
+
{
{
{
{
{
{
{
{
{
{/* Notes */} -
+
Date: Wed, 14 Jun 2023 13:47:32 +0530 Subject: [PATCH 22/30] fix user filter phone number intiail state (#5672) --- src/Components/Users/UserFilter.tsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Components/Users/UserFilter.tsx b/src/Components/Users/UserFilter.tsx index 57fe365935f..1fee0624b99 100644 --- a/src/Components/Users/UserFilter.tsx +++ b/src/Components/Users/UserFilter.tsx @@ -23,8 +23,8 @@ export default function UserFilter(props: any) { const [filterState, setFilterState] = useMergeState({ first_name: filter.first_name || "", last_name: filter.last_name || "", - phone_number: filter.phone_number || "", - alt_phone_number: filter.alt_phone_number || "", + phone_number: filter.phone_number || "+91", + alt_phone_number: filter.alt_phone_number || "+91", user_type: filter.user_type || "", district_id: filter.district_id || "", district_ref: null, @@ -33,8 +33,8 @@ export default function UserFilter(props: any) { const clearFilterState = { first_name: "", last_name: "", - phone_number: "", - alt_phone_number: "", + phone_number: "+91", + alt_phone_number: "+91", user_type: "", district_id: "", district_ref: null, @@ -59,8 +59,9 @@ export default function UserFilter(props: any) { const data = { first_name: first_name || "", last_name: last_name || "", - phone_number: parsePhoneNumberForFilterParam(phone_number), - alt_phone_number: parsePhoneNumberForFilterParam(alt_phone_number), + phone_number: parsePhoneNumberForFilterParam(phone_number) || "+91", + alt_phone_number: + parsePhoneNumberForFilterParam(alt_phone_number) || "+91", user_type: user_type || "", district_id: district_id || "", }; From 7833d042073f3f22765c50a235f08d48ea160491 Mon Sep 17 00:00:00 2001 From: Sahil Singh <96344003+SahilSingh177@users.noreply.github.com> Date: Wed, 14 Jun 2023 14:47:01 +0530 Subject: [PATCH 23/30] Added Cypress test for updating an existing patient. (#5602) Added test that validates whether the patient has been successfully updated by changing/adding details, and then updating their profile. This is followed by checking the dashboard to confirm if the patient has been updated successfully. Fixes #4234 --- cypress/e2e/patient_spec/patient_crud.cy.ts | 50 ++++++++++++++++++++- src/Components/Patient/PatientHome.tsx | 5 ++- src/Components/Patient/PatientRegister.tsx | 1 + 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/cypress/e2e/patient_spec/patient_crud.cy.ts b/cypress/e2e/patient_spec/patient_crud.cy.ts index 2f4522be1bd..c2ce7497154 100644 --- a/cypress/e2e/patient_spec/patient_crud.cy.ts +++ b/cypress/e2e/patient_spec/patient_crud.cy.ts @@ -95,7 +95,27 @@ describe("Patient Creation with consultation", () => { it("Edit the patient details", () => { cy.awaitUrl(patient_url + "/update"); - cy.get("[data-testid=name] input").clear().type("Test E2E User Editted"); + cy.get("[data-testid=name] input").clear().type("Test E2E User Edited"); + cy.get("#emergency_phone_number-div") + .clear() + .then(() => { + cy.get("#emergency_phone_number__country").select("IN"); + }); + cy.get("#emergency_phone_number-div").type("9120330220"); + cy.get("#address").clear().type("Test Patient Address Edited"); + cy.get("#present_health").type("Severe Cough"); + cy.get("#ongoing_medication").type("Paracetamol"); + cy.get("#allergies").type("Dust"); + cy.get("[name=medical_history_check_1]").uncheck(); + cy.get("[name=medical_history_check_2]").check(); + cy.get("#medical_history_2").type("2 months ago"); + cy.get("[name=medical_history_check_3]").check(); + cy.get("#medical_history_3").type("1 month ago"); + cy.get("button").get("[data-testid=add-insurance-button]").click(); + cy.get("#subscriber_id").type("SUB123"); + cy.get("#policy_id").type("P123"); + cy.get("#insurer_id").type("GICOFINDIA"); + cy.get("#insurer_name").type("GICOFINDIA"); cy.get("button").get("[data-testid=submit-button]").click(); cy.url().should("include", "/patient"); cy.url().then((url) => { @@ -105,6 +125,34 @@ describe("Patient Creation with consultation", () => { }); }); + it("Patient Detail verification post edit", () => { + cy.log(patient_url); + cy.awaitUrl(patient_url); + cy.url().should("include", "/facility/"); + cy.get("[data-testid=patient-dashboard]").should( + "contain", + "Test E2E User Edited" + ); + cy.get("[data-testid=patient-dashboard]").should( + "contain", + "+919120330220" + ); + const patientDetails_values: string[] = [ + "Test Patient Address Edited", + "Severe Cough", + "Paracetamol", + "Dust", + "Diabetes", + "2 months ago", + "Heart Disease", + "1 month ago", + ]; + + patientDetails_values.forEach((value) => { + cy.get("[data-testid=patient-details]").should("contain", value); + }); + }); + it("Create a New consultation to existing patient", () => { cy.visit(patient_url + "/consultation"); cy.get("#consultation_status") diff --git a/src/Components/Patient/PatientHome.tsx b/src/Components/Patient/PatientHome.tsx index f48a1a95b7f..c3bc1009a40 100644 --- a/src/Components/Patient/PatientHome.tsx +++ b/src/Components/Patient/PatientHome.tsx @@ -1022,7 +1022,10 @@ export const PatientHome = (props: any) => {
-
+
diff --git a/src/Components/Patient/PatientRegister.tsx b/src/Components/Patient/PatientRegister.tsx index 780064c83d0..da32db60872 100644 --- a/src/Components/Patient/PatientRegister.tsx +++ b/src/Components/Patient/PatientRegister.tsx @@ -2120,6 +2120,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { }, ]) } + data-testid="add-insurance-button" > Add Insurance Details From 19b1d331e0caa3c390aa135d929f637a0f9aece4 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Wed, 14 Jun 2023 14:47:59 +0530 Subject: [PATCH 24/30] Removed all cypress force:true in userpage (#5673) * removed all cypress force code in userpage * minor fix in facility page --- cypress/e2e/facility_spec/facility.cy.ts | 2 +- cypress/e2e/users_spec/user_crud.cy.ts | 211 +++++++++-------------- src/Components/Common/Pagination.tsx | 9 + 3 files changed, 87 insertions(+), 135 deletions(-) diff --git a/cypress/e2e/facility_spec/facility.cy.ts b/cypress/e2e/facility_spec/facility.cy.ts index 14487e45be9..b03c17245b4 100644 --- a/cypress/e2e/facility_spec/facility.cy.ts +++ b/cypress/e2e/facility_spec/facility.cy.ts @@ -13,7 +13,7 @@ class facility { } static update(facility) { - cy.get("[id=manage-facility-dropdown]").should("exist").click(); + cy.get("[id=manage-facility-dropdown]").click(); cy.get("[id=update-facility]").click(); cy.url().should("include", "update"); this.fillForm({ diff --git a/cypress/e2e/users_spec/user_crud.cy.ts b/cypress/e2e/users_spec/user_crud.cy.ts index af5153bad12..e950e98e1c8 100644 --- a/cypress/e2e/users_spec/user_crud.cy.ts +++ b/cypress/e2e/users_spec/user_crud.cy.ts @@ -10,12 +10,9 @@ const makeid = (length: number) => { return result; }; -const makePhoneNumber = () => - "99" + Math.floor(Math.random() * 9000000000 + 1000000000).toString(); - const username = makeid(25); -const phone_number = makePhoneNumber(); -const alt_phone_number = makePhoneNumber(); +const phone_number = 9999999999; +const alt_phone_number = 9999999999; describe("User management", () => { before(() => { @@ -39,13 +36,13 @@ describe("User management", () => { cy.get("[id='local_body'] > div > button").click(); cy.get("div").contains("Aikaranad").click(); cy.intercept(/\/api\/v1\/facility/).as("facility"); - cy.get("[name='facilities']").type("cypress facility").wait("@facility"); - cy.get("[name='facilities']").type("{enter}"); - cy.wait(1000); + cy.get("[name='facilities']") + .click() + .type("cypress facility") + .wait("@facility"); + cy.get("li[role='option']").contains("cypress facility").click(); cy.get("input[type='checkbox']").click(); - cy.wait(1000); cy.get("[name='phone_number']").type(phone_number); - cy.wait(1000); cy.get("[name='alt_phone_number']").type(alt_phone_number); cy.intercept(/users/).as("check_availability"); cy.get("[id='date_of_birth']").click(); @@ -69,20 +66,21 @@ describe("User management", () => { cy.contains("Advanced Filters").click(); cy.get("[name='first_name']").type("Cypress Test"); cy.get("[name='last_name']").type("Tester"); - cy.get("[id='role'] > div > button").click(); - cy.get("div") - .contains(/^Ward Admin$/) + cy.get("#role button").click(); + cy.contains("#role li", "Ward Admin").click(); + cy.get("input[name='district']").click(); + cy.get("input[name='district']").type("Ernakulam"); + cy.get("li[id^='headlessui-combobox-option']") + .contains("Ernakulam") .click(); - cy.get("input[name='district']").type("Ernakulam").wait(1000); - cy.get("input[name='district']").type("{downarrow}{enter}"); + cy.get("[placeholder='Phone Number']").click(); cy.get("[placeholder='Phone Number']").type(phone_number); cy.get("[placeholder='WhatsApp Phone Number']").type(alt_phone_number); cy.contains("Apply").click(); cy.intercept(/\/api\/v1\/users/).as("getUsers"); cy.wait(1000); - cy.get("[name='username']").type(username, { force: true }); + cy.get("[name='username']").type(username); cy.wait("@getUsers"); - cy.wait(1000); cy.get("dd[id='count']").contains(/^1$/).click(); cy.get("div[id='usr_0']").within(() => { cy.intercept(`/api/v1/users/${username}/get_facilities/`).as( @@ -102,12 +100,15 @@ describe("User management", () => { }); it("link facility for user", () => { - cy.contains("Linked Facilities").click({ force: true }); + cy.contains("Linked Facilities").click(); cy.intercept(/\/api\/v1\/facility/).as("getFacilities"); - cy.get("[name='facility']").type("cypress facility").wait("@getFacilities"); - cy.get("[name='facility']").type("{downarrow}{enter}"); + cy.get("[name='facility']") + .click() + .type("cypress facility") + .wait("@getFacilities"); + cy.get("li[role='option']").contains("cypress facility").click(); cy.intercept(/\/api\/v1\/users\/\w+\/add_facility\//).as("addFacility"); - cy.get("button > span").contains("Add").click({ force: true }); + cy.get("button > span").contains("Add").click(); cy.wait("@addFacility") // .its("response.statusCode") // .should("eq", 201) @@ -117,14 +118,10 @@ describe("User management", () => { it("Next/Previous Page", () => { // only works for desktop mode - cy.get("button") - .should("contain", "Next") - .contains("Next") - .click({ force: true }); - cy.get("button") - .should("contain", "Previous") - .contains("Previous") - .click({ force: true }); + cy.get("button#next-pages").click(); + cy.url().should("include", "page=2"); + cy.get("button#prev-pages").click(); + cy.url().should("include", "page=1"); }); afterEach(() => { @@ -132,10 +129,7 @@ describe("User management", () => { }); }); -const backspace = - "{backspace}{backspace}{backspace}{backspace}{backspace}{backspace}{backspace}{backspace}{backspace}{backspace}"; - -describe("Edit Profile Testing", () => { +describe("Edit User Profile & Error Validation", () => { before(() => { cy.loginByApi(username, "#@Cypress_test123"); cy.saveLocalStorage(); @@ -144,107 +138,56 @@ describe("Edit Profile Testing", () => { beforeEach(() => { cy.restoreLocalStorage(); cy.awaitUrl("/user/profile"); - cy.contains("Edit User Profile").click({ force: true }); + cy.contains("button", "Edit User Profile").click(); }); - it("Empty First-Name field of " + username, () => { - cy.get("input[name=firstName]").clear().trigger("change", { force: true }); - cy.get("form").get("button[type='submit']").contains("Update").click(); - cy.get(".error-text").contains("Field is required"); + it("First name Field Updation " + username, () => { + cy.get("input[name=firstName]").clear(); + cy.contains("button[type='submit']", "Update").click(); + cy.get("span.error-text").should("contain", "Field is required"); + cy.get("input[name=firstName]").type("firstName updated"); + cy.contains("button[type='submit']", "Update").click(); }); - it("Valid First-Name field of " + username, () => { - cy.get("input[name=firstName]") - .clear() - .type("User 1") - .trigger("change", { force: true }); - cy.get("form").get("button[type='submit']").contains("Update").click(); - cy.wait(1000); - cy.get("dt").contains("First Name").siblings().first().contains("User 1"); + it("Last name Field Updation " + username, () => { + cy.get("input[name=lastName]").clear(); + cy.contains("button[type='submit']", "Update").click(); + cy.get("span.error-text").should("contain", "Field is required"); + cy.get("input[name=lastName]").type("lastName updated"); + cy.contains("button[type='submit']", "Update").click(); }); - it("Empty Last-Name field of " + username, () => { - cy.get("input[name=lastName]").clear().trigger("change", { force: true }); - cy.get("form").get("button[type='submit']").contains("Update").click(); - cy.get(".error-text").contains("Field is required"); + it("Age Field Updation " + username, () => { + cy.get("input[name=age]").clear(); + cy.contains("button[type='submit']", "Update").click(); + cy.get("span.error-text").should("contain", "This field is required"); + cy.get("input[name=age]").type("11"); + cy.contains("button[type='submit']", "Update").click(); }); - it("Valid Last-Name field of " + username, () => { - cy.get("input[name=lastName]") - .clear() - .type("User 1") - .trigger("change", { force: true }); - cy.get("form").get("button[type='submit']").contains("Update").click(); - cy.wait(1000); - cy.get("dt").contains("Last Name").siblings().first().contains("User 1"); + it("Phone number Field Updation " + username, () => { + cy.get("input[name=phoneNumber]").clear(); + cy.contains("button[type='submit']", "Update").click(); + cy.get("span.error-text").should( + "contain", + "Please enter valid phone number" + ); + cy.get("input[name=phoneNumber]").type("+919999999999"); + cy.contains("button[type='submit']", "Update").click(); }); - it("Invalid Whatsapp Number of " + username, () => { - const whatsapp_num = "11 1111 111"; - cy.get("[placeholder='WhatsApp Number']") - .focus() - .type(`${backspace}${whatsapp_num}`) - .trigger("change", { force: true }) - .should("have.attr", "value", `+91 ${whatsapp_num}`); - cy.wait(1000); - cy.get("form") - .get("button[type='submit']") - .contains("Update") - .click() - .then(() => { - cy.get(".error-text").contains("Please enter valid mobile number"); - }); + it("Whatsapp number Field Updation " + username, () => { + cy.get("input[name=altPhoneNumber]").clear(); + cy.get("input[name=altPhoneNumber]").type("+919999999999"); + cy.contains("button[type='submit']", "Update").click(); }); - it("Valid Whatsapp Number of " + username, () => { - const whatsapp_num = "91111 11111"; - cy.get("[placeholder='WhatsApp Number']") - .focus() - .type(`${backspace}${whatsapp_num}`) - .trigger("change", { force: true }) - .should("have.attr", "value", `+91 ${whatsapp_num}`); - cy.wait(1000); - cy.get("form").get("button[type='submit']").contains("Update").click(); - cy.wait(1000); - cy.get("dt") - .contains("Whatsapp No") - .siblings() - .first() - .contains(`+91 ${whatsapp_num}`.replace(/[ -]/g, "")); - }); - - it("Invalid Phone Number of " + username, () => { - const phone_num = "11 1111 111"; - cy.get("[placeholder='Phone Number']") - .focus() - .type(`${backspace}${phone_num}`) - .trigger("change", { force: true }) - .should("have.attr", "value", `+91 ${phone_num}`); - cy.wait(1000); - cy.get("form") - .get("button[type='submit']") - .contains("Update") - .click() - .then(() => { - cy.get(".error-text").contains("Please enter valid phone number"); - }); - }); - - it("Valid Phone Number of " + username, () => { - const phone_num = "99999 99999"; - cy.get("[placeholder='Phone Number']") - .focus() - .type(`${backspace}${phone_num}`) - .trigger("change", { force: true }) - .should("have.attr", "value", `+91 ${phone_num}`); - cy.wait(1000); - cy.get("form").get("button[type='submit']").contains("Update").click(); - cy.wait(1000); - cy.get("dt") - .contains("Contact No") - .siblings() - .first() - .contains(`+91 ${phone_num}`.replace(/[ -]/g, "")); + it("Email Field Updation " + username, () => { + cy.get("input[name=email]").clear(); + cy.contains("button[type='submit']", "Update").click(); + cy.get("span.error-text").should("contain", "This field is required"); + cy.get("input[name=email]").type("test@test.com"); + cy.contains("button[type='submit']", "Update").click(); }); afterEach(() => { @@ -252,15 +195,15 @@ describe("Edit Profile Testing", () => { }); }); -describe("Delete User", () => { - it("deletes user", () => { - cy.loginByApi("devdistrictadmin", "Coronasafe@123"); - cy.awaitUrl("/user"); - cy.get("[name='username']").type(username, { force: true }); - cy.get("button") - .should("contain", "Delete") - .contains("Delete") - .click({ force: true }); - cy.get("button.font-medium.btn.btn-danger").click(); - }); -}); +// describe("Delete User", () => { district admin wont be able to delete user +// it("deletes user", () => { +// cy.loginByApi("devdistrictadmin", "Coronasafe@123"); +// cy.awaitUrl("/user"); +// cy.get("[name='username']").type(username); +// cy.get("button") +// .should("contain", "Delete") +// .contains("Delete") +// .click(); +// cy.get("button.font-medium.btn.btn-danger").click(); +// }); +// }); diff --git a/src/Components/Common/Pagination.tsx b/src/Components/Common/Pagination.tsx index bf5a4354e49..e173e1d9b35 100644 --- a/src/Components/Common/Pagination.tsx +++ b/src/Components/Common/Pagination.tsx @@ -90,12 +90,14 @@ const Pagination = ({ {/* Mobile view */}
goToPage(currentPage - 1)} disabled={currentPage - 1 <= 0} children={} /> } onClick={() => goToPage(currentPage + 1)} @@ -106,12 +108,14 @@ const Pagination = ({ {/* Desktop view */}
); } From a1368660e785b5c869029f916f14bdd040cb1d9f Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Fri, 16 Jun 2023 19:34:18 +0530 Subject: [PATCH 27/30] Revert "feat: Temperature preference stored in local storage (#5589)" (#5707) This reverts commit 556875be4c29eb1e4f713215eaf5fa3bc86048a4. --- src/Components/Common/TemperatureSelector.tsx | 48 ------------ .../Common/utils/DevicePreference.tsx | 7 -- .../VirtualNursingAssistantLogUpdateCard.tsx | 2 - .../Consultations/DailyRoundsList.tsx | 12 --- .../Patient/DailyRoundListDetails.tsx | 49 +----------- src/Components/Patient/DailyRounds.tsx | 55 ++++++-------- .../Patient/LegacyPatientVitalsCard.tsx | 74 +------------------ src/Components/Patient/models.tsx | 1 - src/Components/Users/UserProfile.tsx | 16 ---- src/Utils/utils.ts | 12 --- 10 files changed, 26 insertions(+), 250 deletions(-) delete mode 100644 src/Components/Common/TemperatureSelector.tsx delete mode 100644 src/Components/Common/utils/DevicePreference.tsx diff --git a/src/Components/Common/TemperatureSelector.tsx b/src/Components/Common/TemperatureSelector.tsx deleted file mode 100644 index 30dac61baa0..00000000000 --- a/src/Components/Common/TemperatureSelector.tsx +++ /dev/null @@ -1,48 +0,0 @@ -import { useEffect, useState } from "react"; -import { classNames } from "../../Utils/utils"; -import { SelectFormField } from "../Form/FormFields/SelectFormField"; -import { getTemperaturePreference } from "../Common/utils/DevicePreference"; - -export const TemperatureSelector = (props: any) => { - const [temperature, setTemperature] = useState( - getTemperaturePreference() === "F" ? "Fahrenheit (°F)" : "Celsius (°C)" - ); - const handleTemperature = (value: string) => { - setTemperature(value); - if (window && window.localStorage) { - localStorage.setItem("temperature", value?.charAt(0)); - } - }; - - function handleLocalTemperatureChange(e: any) { - if (e.key === "temperature") { - setTemperature( - getTemperaturePreference() === "F" ? "Fahrenheit (°F)" : "Celsius (°C)" - ); - } - } - useEffect(() => { - window.addEventListener("storage", handleLocalTemperatureChange); - return () => { - window.removeEventListener("storage", handleLocalTemperatureChange); - }; - }, []); - - useEffect(() => { - handleTemperature(temperature); - }, [temperature]); - - return ( - handleTemperature(value)} - options={["Celsius (°C)", "Fahrenheit (°F)"]} - optionLabel={(o) => o} - optionValue={(o) => o} - /> - ); -}; diff --git a/src/Components/Common/utils/DevicePreference.tsx b/src/Components/Common/utils/DevicePreference.tsx deleted file mode 100644 index 3b45516716a..00000000000 --- a/src/Components/Common/utils/DevicePreference.tsx +++ /dev/null @@ -1,7 +0,0 @@ -export function getTemperaturePreference(): "C" | "F" { - if (window && window.localStorage) { - const temp = localStorage.getItem("temperature"); - if (temp === "F" || temp === "C") return temp; - } - return "C"; -} diff --git a/src/Components/Facility/Consultations/DailyRounds/VirtualNursingAssistantLogUpdateCard.tsx b/src/Components/Facility/Consultations/DailyRounds/VirtualNursingAssistantLogUpdateCard.tsx index a8a416bd3f8..d2c9889af6a 100644 --- a/src/Components/Facility/Consultations/DailyRounds/VirtualNursingAssistantLogUpdateCard.tsx +++ b/src/Components/Facility/Consultations/DailyRounds/VirtualNursingAssistantLogUpdateCard.tsx @@ -37,7 +37,6 @@ const extractVirtualNursingAssistantFields = (round?: DailyRoundsModel) => { if (!round) return; const { temperature, - tempratureUnit, temperature_measured_at, bp, resp, @@ -48,7 +47,6 @@ const extractVirtualNursingAssistantFields = (round?: DailyRoundsModel) => { return { temperature, - tempratureUnit, temperature_measured_at, bp, resp, diff --git a/src/Components/Facility/Consultations/DailyRoundsList.tsx b/src/Components/Facility/Consultations/DailyRoundsList.tsx index 84fb8ccbaea..acc717ad3d1 100644 --- a/src/Components/Facility/Consultations/DailyRoundsList.tsx +++ b/src/Components/Facility/Consultations/DailyRoundsList.tsx @@ -9,8 +9,6 @@ import VirtualNursingAssistantLogUpdateCard from "./DailyRounds/VirtualNursingAs import DefaultLogUpdateCard from "./DailyRounds/DefaultLogUpdateCard"; import { useTranslation } from "react-i18next"; import LoadingLogUpdateCard from "./DailyRounds/LoadingCard"; -import { getTemperaturePreference } from "../../Common/utils/DevicePreference"; -import { fahrenheitToCelsius } from "../../../Utils/utils"; export const DailyRoundsList = (props: any) => { const { t } = useTranslation(); @@ -46,16 +44,7 @@ export const DailyRoundsList = (props: any) => { ); if (!status.aborted) { if (res && res.data) { - res.data.results.forEach((round: DailyRoundsModel) => { - round.temperatureUnit = getTemperaturePreference(); - round.temperature = - round.temperatureUnit === "F" - ? round.temperature - : fahrenheitToCelsius(round.temperature); - return round; - }); setDailyRoundsListData(res.data.results); - console.log(res.data.results); setTotalCount(res.data.count); } setIsDailyRoundLoading(false); @@ -106,7 +95,6 @@ export const DailyRoundsList = (props: any) => { return ( { diff --git a/src/Components/Patient/DailyRoundListDetails.tsx b/src/Components/Patient/DailyRoundListDetails.tsx index 81fbbd9a39f..8e355f7b313 100644 --- a/src/Components/Patient/DailyRoundListDetails.tsx +++ b/src/Components/Patient/DailyRoundListDetails.tsx @@ -1,13 +1,11 @@ import loadable from "@loadable/component"; import moment from "moment"; -import { useCallback, useEffect, useState } from "react"; +import React, { useCallback, useState } from "react"; import { useDispatch } from "react-redux"; import { CURRENT_HEALTH_CHANGE, SYMPTOM_CHOICES } from "../../Common/constants"; import { statusType, useAbortableEffect } from "../../Common/utils"; import { getConsultationDailyRoundsDetails } from "../../Redux/actions"; import { DailyRoundsModel } from "./models"; -import { getTemperaturePreference } from "../Common/utils/DevicePreference"; -import { celsiusToFahrenheit, fahrenheitToCelsius } from "../../Utils/utils"; import Page from "../Common/components/Page"; import ButtonV2 from "../Common/components/ButtonV2"; const Loading = loadable(() => import("../Common/Loading")); @@ -36,11 +34,8 @@ export const DailyRoundListDetails = (props: any) => { const data: DailyRoundsModel = { ...res.data, temperature: Number(res.data.temperature) - ? getTemperaturePreference() === "F" - ? res.data.temperature - : fahrenheitToCelsius(Number(res.data.temperature)) + ? res.data.temperature : "", - temperatureUnit: getTemperaturePreference(), additional_symptoms_text: "", medication_given: Object.keys(res.data.medication_given).length === 0 @@ -76,43 +71,6 @@ export const DailyRoundListDetails = (props: any) => { [dispatch, fetchpatient] ); - const toggleTemperatureOnLocalChange = () => { - const isCelcius = - dailyRoundListDetailsData.temperatureUnit === "C" ? true : false; - const temp = dailyRoundListDetailsData.temperature; - - const data = { ...dailyRoundListDetailsData }; - data.temperature = isCelcius - ? celsiusToFahrenheit(temp) - : fahrenheitToCelsius(temp); - data.temperatureUnit = isCelcius ? "F" : "C"; - setDailyRoundListDetails(data); - }; - - const handleLocalTemperatureChange = (e: any) => { - if (e.key === "temperature") { - if ( - dailyRoundListDetailsData.temperatureUnit === "C" && - e.newValue === "F" - ) { - toggleTemperatureOnLocalChange(); - } - if ( - dailyRoundListDetailsData.temperatureUnit === "F" && - e.newValue === "C" - ) { - toggleTemperatureOnLocalChange(); - } - } - }; - - useEffect(() => { - window.addEventListener("storage", handleLocalTemperatureChange); - return () => { - window.removeEventListener("storage", handleLocalTemperatureChange); - }; - }, [dailyRoundListDetailsData.temperature]); - if (isLoading) { return ; } @@ -147,8 +105,7 @@ export const DailyRoundListDetails = (props: any) => {
Temperature: - {`${dailyRoundListDetailsData.temperature} °${dailyRoundListDetailsData.temperatureUnit}` || - "-"} + {dailyRoundListDetailsData.temperature || "-"}
Taken at: diff --git a/src/Components/Patient/DailyRounds.tsx b/src/Components/Patient/DailyRounds.tsx index 1fad194e1b8..0ba60f4cf5c 100644 --- a/src/Components/Patient/DailyRounds.tsx +++ b/src/Components/Patient/DailyRounds.tsx @@ -40,8 +40,6 @@ import { FieldLabel } from "../Form/FormFields/FormField"; import TextAreaFormField from "../Form/FormFields/TextAreaFormField"; import { Cancel, Submit } from "../Common/components/ButtonV2"; import useAppHistory from "../../Common/hooks/useAppHistory"; -import { celsiusToFahrenheit, fahrenheitToCelsius } from "../../Utils/utils"; -import { getTemperaturePreference } from "../Common/utils/DevicePreference"; const Loading = loadable(() => import("../Common/Loading")); const PageTitle = loadable(() => import("../Common/PageTitle")); @@ -64,7 +62,7 @@ const initForm: any = { diastolic: null, pulse: null, resp: null, - tempInCelsius: false, + tempInCelcius: false, temperature: null, rhythm: "0", rhythm_detail: "", @@ -155,11 +153,6 @@ export const DailyRounds = (props: any) => { (i) => i.text === res.data.patient_category )?.id || "Comfort" : "Comfort", - tempInCelsius: getTemperaturePreference() === "C" ? true : false, - temperature: - getTemperaturePreference() === "C" - ? fahrenheitToCelsius(res.data.temperature) - : res.data.temperature, admitted_to: res.data.admitted_to ? res.data.admitted_to : "Select", }; dispatch({ type: "set_form", form: data }); @@ -236,6 +229,16 @@ export const DailyRounds = (props: any) => { return !invalidForm; }; + const fahrenheitToCelcius = (x: any) => { + const t = (Number(x) - 32.0) * (5.0 / 9.0); + return String(t.toFixed(1)); + }; + + const celciusToFahrenheit = (x: any) => { + const t = (Number(x) * 9.0) / 5.0 + 32.0; + return String(t.toFixed(1)); + }; + const calculateMAP = (systolic: any, diastolic: any) => { let map = 0; if (systolic && diastolic) { @@ -296,8 +299,8 @@ export const DailyRounds = (props: any) => { : undefined, pulse: state.form.pulse, resp: Number(state.form.resp), - temperature: state.form.tempInCelsius - ? celsiusToFahrenheit(state.form.temperature) + temperature: state.form.tempInCelcius + ? celciusToFahrenheit(state.form.temperature) : state.form.temperature, rhythm: Number(state.form.rhythm) || 0, rhythm_detail: state.form.rhythm_detail, @@ -478,33 +481,17 @@ export const DailyRounds = (props: any) => { }; const toggleTemperature = () => { - const isCelsius = state.form.tempInCelsius; + const isCelcius = state.form.tempInCelcius; const temp = state.form.temperature; const form = { ...state.form }; - form.temperature = isCelsius - ? celsiusToFahrenheit(temp) - : fahrenheitToCelsius(temp); - form.tempInCelsius = !isCelsius; + form.temperature = isCelcius + ? celciusToFahrenheit(temp) + : fahrenheitToCelcius(temp); + form.tempInCelcius = !isCelcius; dispatch({ type: "set_form", form }); }; - function handleLocalTemperatureChange(e: any) { - if (e.key === "temperature") { - if (e.newValue === "F" && state.form.tempInCelsius) { - toggleTemperature(); - } else if (e.newValue === "C" && !state.form.tempInCelsius) { - toggleTemperature(); - } - } - } - useEffect(() => { - window.addEventListener("storage", handleLocalTemperatureChange); - return () => { - window.removeEventListener("storage", handleLocalTemperatureChange); - }; - }, [state.form.temperature]); - if (isLoading) { return ; } @@ -811,7 +798,7 @@ export const DailyRounds = (props: any) => {
Temperature{" "} - {state.form.tempInCelsius + {state.form.tempInCelcius ? getStatus( 36.4, "Low", @@ -835,7 +822,7 @@ export const DailyRounds = (props: any) => { variant="standard" value={state.form.temperature} options={ - state.form.tempInCelsius + state.form.tempInCelcius ? generateOptions(35, 41, 0.1, 1) : generateOptions(95, 106, 0.1, 1) } @@ -863,7 +850,7 @@ export const DailyRounds = (props: any) => { > {" "} - {state.form.tempInCelsius ? "C" : "F"}{" "} + {state.form.tempInCelcius ? "C" : "F"}{" "}
diff --git a/src/Components/Patient/LegacyPatientVitalsCard.tsx b/src/Components/Patient/LegacyPatientVitalsCard.tsx index 5673870a837..867d1ebfe9a 100644 --- a/src/Components/Patient/LegacyPatientVitalsCard.tsx +++ b/src/Components/Patient/LegacyPatientVitalsCard.tsx @@ -1,17 +1,11 @@ import React, { ReactNode, useEffect, useRef, useState } from "react"; import { useDispatch } from "react-redux"; import { listAssetBeds, getPermittedFacility } from "../../Redux/actions"; -import { - celsiusToFahrenheit, - classNames, - fahrenheitToCelsius, -} from "../../Utils/utils"; +import { classNames } from "../../Utils/utils"; import { AssetData } from "../Assets/AssetTypes"; import ToolTip from "../Common/utils/Tooltip"; import { PatientModel } from "./models"; import Waveform, { WaveformType } from "./Waveform"; -import { getTemperaturePreference } from "../Common/utils/DevicePreference"; -import { fahrenheitToCelcius } from "../CriticalCareRecording/HemodynamicParameters/CriticalCare__HemodynamicParametersEditor.bs"; export interface IPatientVitalsCardProps { facilityId?: string; @@ -54,68 +48,6 @@ export default function LegacyPatientVitalsCard({ const [wsUrl, setWsUrl] = useState(""); const [patientObservations, setPatientObservations] = React.useState(); const [stats, setStats] = React.useState(false); - const [temperatureUnit, setTemperatureUnit] = useState( - getTemperaturePreference() - ); - - const initialTemperature = () => { - if (patient?.last_consultation?.last_daily_round?.temperature) { - patient = { - ...patient, - last_consultation: { - ...patient?.last_consultation, - last_daily_round: { - ...patient?.last_consultation?.last_daily_round, - temperature: - temperatureUnit === "F" - ? patient?.last_consultation?.last_daily_round?.temperature - : fahrenheitToCelcius( - patient?.last_consultation?.last_daily_round?.temperature - ), - }, - }, - }; - } - }; - initialTemperature(); - - const handleTemperatureChange = (change: "C->F" | "F->C") => { - if (patient?.last_consultation?.last_daily_round?.temperature) { - patient = { - ...patient, - last_consultation: { - ...patient?.last_consultation, - last_daily_round: { - ...patient?.last_consultation?.last_daily_round, - temperature: - change === "C->F" - ? celsiusToFahrenheit( - patient?.last_consultation?.last_daily_round?.temperature - ) - : fahrenheitToCelsius( - patient?.last_consultation?.last_daily_round?.temperature - ), - }, - }, - }; - } - }; - - useEffect(() => { - function handleLocalTemperatureChange(e: any) { - if (e.key === "temperature") { - if (temperatureUnit === "C" && e.newValue === "F") - handleTemperatureChange("C->F"); - else if (temperatureUnit === "F" && e.newValue === "C") - handleTemperatureChange("F->C"); - setTemperatureUnit(e.newValue); - } - } - window.addEventListener("storage", handleLocalTemperatureChange); - return () => { - window.removeEventListener("storage", handleLocalTemperatureChange); - }; - }, []); useEffect(() => { const fetchFacility = async () => { @@ -247,9 +179,7 @@ export default function LegacyPatientVitalsCard({ //waveformDefaultSpace: true }, { - label: shrinked - ? `Temp. (°${temperatureUnit})` - : `Temperature (°${temperatureUnit})`, + label: shrinked ? "Temp. (°F)" : "Temperature (°F)", liveKey: "body-temperature1", vitalKey: "temperature", }, diff --git a/src/Components/Patient/models.tsx b/src/Components/Patient/models.tsx index 9ed633feed0..3da59b9ba4a 100644 --- a/src/Components/Patient/models.tsx +++ b/src/Components/Patient/models.tsx @@ -260,7 +260,6 @@ export interface DailyRoundsModel { pulse?: number; resp?: number; temperature?: string; - temperatureUnit?: "C" | "F"; temperature_measured_at?: string; physical_examination_info?: string; other_details?: string; diff --git a/src/Components/Users/UserProfile.tsx b/src/Components/Users/UserProfile.tsx index 79ed0b5de1f..e647c9dbfb4 100644 --- a/src/Components/Users/UserProfile.tsx +++ b/src/Components/Users/UserProfile.tsx @@ -23,7 +23,6 @@ import { SelectFormField } from "../Form/FormFields/SelectFormField"; import moment from "moment"; import { SkillModel, SkillObjectModel } from "../Users/models"; import UpdatableApp, { checkForUpdate } from "../Common/UpdatableApp"; -import { TemperatureSelector } from "../Common/TemperatureSelector"; const Loading = loadable(() => import("../Common/Loading")); @@ -708,21 +707,6 @@ export default function UserProfile() {
-
-
-
-

- Temperature Unit -

-

- Set your temperature unit preference -

-
-
-
- -
-
diff --git a/src/Utils/utils.ts b/src/Utils/utils.ts index f97837e2232..35ad46408b1 100644 --- a/src/Utils/utils.ts +++ b/src/Utils/utils.ts @@ -224,15 +224,3 @@ export const formatCurrency = (price: number) => style: "currency", currency: "INR", }); - -export const fahrenheitToCelsius = (x: any) => { - if (x === null || x === undefined) return x; - const t = (Number(x) - 32.0) * (5.0 / 9.0); - return String(t.toFixed(1)); -}; - -export const celsiusToFahrenheit = (x: any) => { - if (x === null || x === undefined) return x; - const t = (Number(x) * 9.0) / 5.0 + 32.0; - return String(t.toFixed(1)); -}; From 0cb22649448894bf614b6e268f4c69775210c0a1 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Fri, 16 Jun 2023 20:27:22 +0530 Subject: [PATCH 28/30] patch cns middleware address resolving (#5706) Co-authored-by: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> --- src/Components/Facility/CentralNursingStation.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Facility/CentralNursingStation.tsx b/src/Components/Facility/CentralNursingStation.tsx index 13f4704ff49..56a17a0d9b2 100644 --- a/src/Components/Facility/CentralNursingStation.tsx +++ b/src/Components/Facility/CentralNursingStation.tsx @@ -97,7 +97,7 @@ export default function CentralNursingStation({ facilityId }: Props) { setData( entries.map(({ patient, asset, bed }) => { const middleware = - asset.meta?.middleware_hostname ?? facilityObj?.middleware_address; + asset.meta?.middleware_hostname || facilityObj?.middleware_address; const local_ip_address = asset.meta?.local_ip_address; return { From 444749e6bab315082f727268cec788044bb64755 Mon Sep 17 00:00:00 2001 From: Ashesh <3626859+Ashesh3@users.noreply.github.com> Date: Fri, 16 Jun 2023 20:29:37 +0530 Subject: [PATCH 29/30] Fix is_telemedicine checkbox (#5705) --- src/Components/Facility/ConsultationForm.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Components/Facility/ConsultationForm.tsx b/src/Components/Facility/ConsultationForm.tsx index c311cda0327..6abb9cc4a3f 100644 --- a/src/Components/Facility/ConsultationForm.tsx +++ b/src/Components/Facility/ConsultationForm.tsx @@ -321,6 +321,7 @@ export const ConsultationForm = (props: any) => { is_telemedicine: `${res.data.is_telemedicine}`, is_kasp: `${res.data.is_kasp}`, assigned_to: res.data.assigned_to || "", + assigned_to_object: res.data.assigned_to_object, ett_tt: res.data.ett_tt ? Number(res.data.ett_tt) : 3, special_instruction: res.data.special_instruction || "", weight: res.data.weight ? res.data.weight : "", @@ -622,7 +623,9 @@ export const ConsultationForm = (props: any) => { action: state.form.action, review_interval: state.form.review_interval, assigned_to: - state.form.is_telemedicine === "true" ? state.form.assigned_to : "", + state.form.is_telemedicine.toString() === "true" + ? state.form.assigned_to + : "", special_instruction: state.form.special_instruction, weight: Number(state.form.weight), height: Number(state.form.height), @@ -1218,8 +1221,8 @@ export const ConsultationForm = (props: any) => { {JSON.parse(state.form.is_telemedicine) && ( From 326c3e46863cf64fbc67b08da52bb62bf1ed7707 Mon Sep 17 00:00:00 2001 From: Ashesh <3626859+Ashesh3@users.noreply.github.com> Date: Fri, 16 Jun 2023 20:36:24 +0530 Subject: [PATCH 30/30] Fix rescript dropdown not visible (#5709) --- .../CriticalCareRecording/IOBalance/IOBalance__UnitPicker.res | 2 +- .../CriticalCareRecording/components/CriticalCare__Dropdown.res | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Components/CriticalCareRecording/IOBalance/IOBalance__UnitPicker.res b/src/Components/CriticalCareRecording/IOBalance/IOBalance__UnitPicker.res index aec60a0dba6..780e5abd751 100644 --- a/src/Components/CriticalCareRecording/IOBalance/IOBalance__UnitPicker.res +++ b/src/Components/CriticalCareRecording/IOBalance/IOBalance__UnitPicker.res @@ -76,7 +76,7 @@ let make = (~id, ~value, ~updateCB, ~placeholder, ~selectables) => { id value autoComplete="off" - onClick={_ => setShowDropdown(_ => !showDropdown)} + onClick={e => {ReactEvent.Mouse.stopPropagation(e);setShowDropdown(_ => !showDropdown)}} onChange={e => updateCB(ReactEvent.Form.target(e)["value"])} className="appearance-none h-10 mt-1 block w-full border border-gray-400 rounded py-2 px-4 text-sm bg-gray-100 hover:bg-gray-200 focus:outline-none focus:bg-white focus:ring-primary-500" placeholder diff --git a/src/Components/CriticalCareRecording/components/CriticalCare__Dropdown.res b/src/Components/CriticalCareRecording/components/CriticalCare__Dropdown.res index bc695002eab..a0196a9baa9 100644 --- a/src/Components/CriticalCareRecording/components/CriticalCare__Dropdown.res +++ b/src/Components/CriticalCareRecording/components/CriticalCare__Dropdown.res @@ -77,7 +77,7 @@ let make = (~id, ~value, ~updateCB, ~placeholder, ~selectables, ~label="", ~disa id value autoComplete="off" - onClick={_ => setShowDropdown(_ => !showDropdown)} + onClick={e => {ReactEvent.Mouse.stopPropagation(e); setShowDropdown(_ => !showDropdown)}} onChange={e => updateCB(ReactEvent.Form.target(e)["value"])} className="cui-input-base appearance-none h-10 mt-1 block py-2 px-4" disabled