Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Pranshu1902 committed Jan 12, 2024
1 parent 85e088a commit 7046c61
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
13 changes: 6 additions & 7 deletions src/Components/Facility/LocationManagement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface Props {
}

interface LocationProps extends LocationModel {
setShowDeletePopup: any;
setShowDeletePopup: (e: { open: boolean; name: string; id: string }) => void;
}

export default function LocationManagement({ facilityId }: Props) {
Expand All @@ -29,19 +29,16 @@ export default function LocationManagement({ facilityId }: Props) {
});

const deleteAssetLocation = async () => {
const res: any = await request(routes.deleteFacilityAssetLocation, {
const { res } = await request(routes.deleteFacilityAssetLocation, {
pathParams: {
facility_external_id: facilityId,
external_id: showDeletePopup.id,
},
});
if (res?.res?.status === 204) {
if (res?.ok) {
Notification.Success({
msg: `Location ${showDeletePopup.name} deleted successully`,
});
PaginatedList.Refresh;
} else {
Notification.Error({ msg: "Something went wrong!" });
}
setShowDeletePopup({ ...showDeletePopup, open: false });
};
Expand Down Expand Up @@ -193,7 +190,9 @@ const Location = ({
variant="secondary"
border
className="w-full"
onClick={() => setShowDeletePopup({ open: true, name: name, id: id })}
onClick={() =>
setShowDeletePopup({ open: true, name: name ?? "", id: id ?? "" })
}
authorizeFor={NonReadOnlyUsers}
>
<CareIcon className="care-l-trash text-lg" />
Expand Down
4 changes: 1 addition & 3 deletions src/Redux/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,7 @@ const routes = {
deleteFacilityAssetLocation: {
path: "/api/v1/facility/{facility_external_id}/asset_location/{external_id}/",
method: "DELETE",
TRes: Type<null | {
detail?: string;
}>(),
TRes: Type<Record<string, never>>(),
},

// Asset bed
Expand Down

0 comments on commit 7046c61

Please sign in to comment.