Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix: [Clear Button is active when no input is selected in Dropdown] #9264

Merged
merged 14 commits into from
Dec 11, 2024
Merged
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
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
Loading