Skip to content

Commit

Permalink
coderabbit suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaJ2305 committed Feb 1, 2025
1 parent a23757d commit c953fd3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
1 change: 1 addition & 0 deletions public/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,7 @@
"delete_facility": "Delete Facility",
"delete_item": "Delete {{name}}",
"delete_record": "Delete Record",
"deleted_failed": "{{name}} deleted failed",
"deleted_successfully": "{{name}} deleted successfully",
"deleting": "Deleting...",
"demography": "Demography",
Expand Down
16 changes: 10 additions & 6 deletions src/components/Facility/FacilityHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,16 @@ export const FacilityHome = ({ facilityId }: Props) => {
};

const handleDeleteSubmit = async () => {
const res = await callApi(routes.deleteFacility, {
pathParams: { id: facilityId },
});
if (res) {
toast.success(t("deleted_successfully", { name: facilityData?.name }));
navigate("/facility");
try {
const res = await callApi(routes.deleteFacility, {
pathParams: { id: facilityId },
});
if (res) {
toast.success(t("deleted_successfully", { name: facilityData?.name }));
navigate("/facility");
}
} catch (_error) {
toast.error(t("delete_failed", { name: facilityData?.name }));
}
};

Expand Down
19 changes: 11 additions & 8 deletions src/components/Users/UserAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,17 @@ export default function UserAvatar({ username }: { username: string }) {
};

const handleAvatarDelete = async (onError: () => void) => {
const response = await callApi(routes.deleteProfilePicture, {
pathParams: { username },
});
if (response) {
queryClient.invalidateQueries({ queryKey: ["currentUser"] });
toast.success(t("profile_picture_deleted"));
setEditAvatar(false);
} else {
try {
const response = await callApi(routes.deleteProfilePicture, {
pathParams: { username },
});

if (response) {
queryClient.invalidateQueries({ queryKey: ["currentUser"] });
toast.success(t("profile_picture_deleted"));
setEditAvatar(false);
}
} catch (_error) {
onError();
}
};
Expand Down

0 comments on commit c953fd3

Please sign in to comment.