Skip to content

Commit

Permalink
Merge branch 'ohcnetwork:develop' into issue/ohcnetwork#9339/notice-card
Browse files Browse the repository at this point in the history
  • Loading branch information
AnveshNalimela authored Dec 11, 2024
2 parents 237a4a5 + 113dddd commit 60e640d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 23 deletions.
22 changes: 11 additions & 11 deletions src/components/Assets/AssetsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ const AssetsList = () => {
const [importAssetModalOpen, setImportAssetModalOpen] = useState(false);
const assetsExist = assets.length > 0 && Object.keys(assets[0]).length > 0;
const [showFacilityDialog, setShowFacilityDialog] = useState(false);
const [selectedFacility, setSelectedFacility] = useState<FacilityModel>({
name: "",
});
const [selectedFacility, setSelectedFacility] = useState<FacilityModel>();
const params = {
limit: resultsPerPage,
page: qParams.page,
Expand Down Expand Up @@ -460,15 +458,11 @@ const AssetsList = () => {
</div>
</>
)}
{typeof facility === "undefined" && (
{facility == null && (
<FacilitiesSelectDialogue
show={importAssetModalOpen}
setSelected={(e) => setFacility(e)}
selectedFacility={
facility ?? {
name: "",
}
}
selectedFacility={selectedFacility}
handleOk={() => {
return undefined;
}}
Expand Down Expand Up @@ -497,10 +491,16 @@ const AssetsList = () => {
show={showFacilityDialog}
setSelected={(e) => setSelectedFacility(e)}
selectedFacility={selectedFacility}
handleOk={() => navigate(`facility/${selectedFacility.id}/assets/new`)}
handleOk={() => {
if (selectedFacility) {
navigate(`facility/${selectedFacility.id}/assets/new`);
} else {
Notification.Warn({ msg: "No facility selected" });
}
}}
handleCancel={() => {
setShowFacilityDialog(false);
setSelectedFacility({ name: "" });
setSelectedFacility(undefined);
}}
/>
</Page>
Expand Down
2 changes: 1 addition & 1 deletion src/components/ExternalResult/FacilitiesSelectDialogue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface Props {
show: boolean;
handleOk: () => void;
handleCancel: () => void;
selectedFacility: FacilityModel;
selectedFacility: FacilityModel | null | undefined;
setSelected: (e: any) => void;
}

Expand Down
24 changes: 13 additions & 11 deletions src/components/Patient/ManagePatients.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ export const PatientManager = () => {
"emergency_phone_number",
],
});
const [selectedFacility, setSelectedFacility] = useState<FacilityModel>({
name: "",
});
const [selectedFacility, setSelectedFacility] = useState<FacilityModel>();
const authUser = useAuthUser();
const [diagnoses, setDiagnoses] = useState<ICD11DiagnosisModel[]>([]);
const [showDialog, setShowDialog] = useState<"create" | "list-discharged">();
Expand Down Expand Up @@ -976,18 +974,22 @@ export const PatientManager = () => {
setSelected={(e) => setSelectedFacility(e)}
selectedFacility={selectedFacility}
handleOk={() => {
switch (showDialog) {
case "create":
navigate(`facility/${selectedFacility.id}/patient`);
break;
case "list-discharged":
navigate(`facility/${selectedFacility.id}/discharged-patients`);
break;
if (selectedFacility) {
switch (showDialog) {
case "create":
navigate(`facility/${selectedFacility.id}/patient`);
break;
case "list-discharged":
navigate(`facility/${selectedFacility.id}/discharged-patients`);
break;
}
} else {
Notification.Error({ msg: "No facility selected" });
}
}}
handleCancel={() => {
setShowDialog(undefined);
setSelectedFacility({ name: "" });
setSelectedFacility(undefined);
}}
/>

Expand Down

0 comments on commit 60e640d

Please sign in to comment.