Skip to content

Commit

Permalink
added toast messages on facility and skills dialog (#7448)
Browse files Browse the repository at this point in the history
* added toast messages on facility and skills dialog

* Requested changes done
  • Loading branch information
soumya-maheshwari authored Mar 27, 2024
1 parent 2134458 commit 83333fc
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
41 changes: 37 additions & 4 deletions src/Components/Users/ManageUsers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,16 @@ function UserFacilities(props: { user: any }) {
pathParams: { username },
body: { home_facility: facility.id.toString() },
});
if (res && res.status === 200) user.home_facility_object = facility;
if (!res?.ok) {
Notification.Error({
msg: "Error while updating Home facility",
});
} else {
user.home_facility_object = facility;
Notification.Success({
msg: "Home Facility updated successfully",
});
}
await refetchUserFacilities();
setIsLoading(false);
};
Expand All @@ -649,12 +658,31 @@ function UserFacilities(props: { user: any }) {
const { res } = await request(routes.clearHomeFacility, {
pathParams: { username },
});
if (res && res.status === 204) user.home_facility_object = null;

if (!res?.ok) {
Notification.Error({
msg: "Error while clearing home facility",
});
} else {
user.home_facility_object = null;
Notification.Success({
msg: "Home Facility cleared successfully",
});
}
} else {
await request(routes.deleteUserFacility, {
const { res } = await request(routes.deleteUserFacility, {
pathParams: { username },
body: { facility: unlinkFacilityData?.facility?.id?.toString() },
});
if (!res?.ok) {
Notification.Error({
msg: "Error while unlinking home facility",
});
} else {
Notification.Success({
msg: "Facility unlinked successfully",
});
}
}
await refetchUserFacilities();
hideUnlinkFacilityModal();
Expand All @@ -667,10 +695,15 @@ function UserFacilities(props: { user: any }) {
pathParams: { username },
body: { facility: facility.id.toString() },
});
if (res?.status !== 201) {

if (!res?.ok) {
Notification.Error({
msg: "Error while linking facility",
});
} else {
Notification.Success({
msg: "Facility linked successfully",
});
}
await refetchUserFacilities();
setIsLoading(false);
Expand Down
5 changes: 5 additions & 0 deletions src/Components/Users/SkillsSlideOver.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default ({ show, setShow, username }: IProps) => {
pathParams: { username },
body: { skill: skill.id },
});

if (!res?.ok) {
Notification.Error({
msg: "Error while adding skill",
Expand All @@ -70,6 +71,10 @@ export default ({ show, setShow, username }: IProps) => {
Notification.Error({
msg: "Error while unlinking skill",
});
} else {
Notification.Success({
msg: "Skill unlinked successfully",
});
}
setDeleteSkill(null);
await refetchUserSkills();
Expand Down

0 comments on commit 83333fc

Please sign in to comment.