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
24 changes: 12 additions & 12 deletions src/components/Assets/AssetsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@
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 @@
</div>
</>
)}
{typeof facility === "undefined" && (
{facility == null && (
<FacilitiesSelectDialogue
show={importAssetModalOpen}
setSelected={(e) => setFacility(e)}
selectedFacility={
facility ?? {
name: "",
}
}
selectedFacility={selectedFacility}

Check failure on line 465 in src/components/Assets/AssetsList.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (1)

Type 'FacilityModel | undefined' is not assignable to type 'FacilityModel | null'.

Check failure on line 465 in src/components/Assets/AssetsList.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (2)

Type 'FacilityModel | undefined' is not assignable to type 'FacilityModel | null'.

Check failure on line 465 in src/components/Assets/AssetsList.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (3)

Type 'FacilityModel | undefined' is not assignable to type 'FacilityModel | null'.

Check failure on line 465 in src/components/Assets/AssetsList.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (4)

Type 'FacilityModel | undefined' is not assignable to type 'FacilityModel | null'.
handleOk={() => {
return undefined;
}}
Expand All @@ -482,9 +476,9 @@
open={importAssetModalOpen}
onClose={() => {
setImportAssetModalOpen(false);
setFacility((f) => {

Check failure on line 479 in src/components/Assets/AssetsList.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (1)

Argument of type '(f: FacilityModel | undefined) => FacilityModel | null | undefined' is not assignable to parameter of type 'SetStateAction<FacilityModel | undefined>'.

Check failure on line 479 in src/components/Assets/AssetsList.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (2)

Argument of type '(f: FacilityModel | undefined) => FacilityModel | null | undefined' is not assignable to parameter of type 'SetStateAction<FacilityModel | undefined>'.

Check failure on line 479 in src/components/Assets/AssetsList.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (3)

Argument of type '(f: FacilityModel | undefined) => FacilityModel | null | undefined' is not assignable to parameter of type 'SetStateAction<FacilityModel | undefined>'.

Check failure on line 479 in src/components/Assets/AssetsList.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (4)

Argument of type '(f: FacilityModel | undefined) => FacilityModel | null | undefined' is not assignable to parameter of type 'SetStateAction<FacilityModel | undefined>'.
if (!qParams.facility) {
return undefined;
return null;
}
return f;
});
Expand All @@ -496,11 +490,17 @@
<FacilitiesSelectDialogue
show={showFacilityDialog}
setSelected={(e) => setSelectedFacility(e)}
selectedFacility={selectedFacility}

Check failure on line 493 in src/components/Assets/AssetsList.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (1)

Type 'FacilityModel | undefined' is not assignable to type 'FacilityModel | null'.

Check failure on line 493 in src/components/Assets/AssetsList.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (2)

Type 'FacilityModel | undefined' is not assignable to type 'FacilityModel | null'.

Check failure on line 493 in src/components/Assets/AssetsList.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (3)

Type 'FacilityModel | undefined' is not assignable to type 'FacilityModel | null'.

Check failure on line 493 in src/components/Assets/AssetsList.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (4)

Type 'FacilityModel | undefined' is not assignable to type 'FacilityModel | null'.
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(null);

Check failure on line 503 in src/components/Assets/AssetsList.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (1)

Argument of type 'null' is not assignable to parameter of type 'SetStateAction<FacilityModel | undefined>'.

Check failure on line 503 in src/components/Assets/AssetsList.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (2)

Argument of type 'null' is not assignable to parameter of type 'SetStateAction<FacilityModel | undefined>'.

Check failure on line 503 in src/components/Assets/AssetsList.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (3)

Argument of type 'null' is not assignable to parameter of type 'SetStateAction<FacilityModel | undefined>'.

Check failure on line 503 in src/components/Assets/AssetsList.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (4)

Argument of type 'null' is not assignable to parameter of type 'SetStateAction<FacilityModel | 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;
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 @@
"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 @@ -974,20 +972,24 @@
<FacilitiesSelectDialogue
show={!!showDialog}
setSelected={(e) => setSelectedFacility(e)}
selectedFacility={selectedFacility}

Check failure on line 975 in src/components/Patient/ManagePatients.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (1)

Type 'FacilityModel | undefined' is not assignable to type 'FacilityModel | null'.

Check failure on line 975 in src/components/Patient/ManagePatients.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (2)

Type 'FacilityModel | undefined' is not assignable to type 'FacilityModel | null'.

Check failure on line 975 in src/components/Patient/ManagePatients.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (3)

Type 'FacilityModel | undefined' is not assignable to type 'FacilityModel | null'.

Check failure on line 975 in src/components/Patient/ManagePatients.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (4)

Type 'FacilityModel | undefined' is not assignable to type 'FacilityModel | null'.
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(null);

Check failure on line 992 in src/components/Patient/ManagePatients.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (1)

Argument of type 'null' is not assignable to parameter of type 'SetStateAction<FacilityModel | undefined>'.

Check failure on line 992 in src/components/Patient/ManagePatients.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (2)

Argument of type 'null' is not assignable to parameter of type 'SetStateAction<FacilityModel | undefined>'.

Check failure on line 992 in src/components/Patient/ManagePatients.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (3)

Argument of type 'null' is not assignable to parameter of type 'SetStateAction<FacilityModel | undefined>'.

Check failure on line 992 in src/components/Patient/ManagePatients.tsx

View workflow job for this annotation

GitHub Actions / cypress-run (4)

Argument of type 'null' is not assignable to parameter of type 'SetStateAction<FacilityModel | undefined>'.
}}
/>

Expand Down
Loading