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

added toast messages on facility and skills dialog #7448

Merged
merged 3 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading