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 1 commit
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
36 changes: 35 additions & 1 deletion src/Components/Users/ManageUsers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,15 @@ function UserFacilities(props: { user: any }) {
body: { home_facility: facility.id.toString() },
});
if (res && res.status === 200) user.home_facility_object = facility;
if (res?.status !== 200) {
Notification.Error({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (res && res.status === 200) user.home_facility_object = facility;
if (res?.status !== 200) {
Notification.Error({
if (!res?.ok) {
user.home_facility_object = facility;
Notification.Error({

Copy link
Contributor Author

@soumya-maheshwari soumya-maheshwari Mar 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @rithviknishad,

I just wanted to confirm the proposed changes. It seems like user.home_facility_object = facility; should be moved to the else statement. If this adjustment aligns with our intentions, I can proceed with pushing the code.

Let me know if there are any concerns.

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yes, you are right. my bad

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yes, you are right. my bad

I've made some updates to the pull request:
Please review the changes and let me know if there are any further adjustments needed. Looking forward to your feedback!

msg: "Error while updating Home facility",
});
} else {
Notification.Success({
msg: "Home Facility updated successfully",
});
}
await refetchUserFacilities();
setIsLoading(false);
};
Expand All @@ -650,11 +659,29 @@ function UserFacilities(props: { user: any }) {
pathParams: { username },
});
if (res && res.status === 204) user.home_facility_object = null;
if (res?.status !== 204) {
Notification.Error({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (res && res.status === 204) user.home_facility_object = null;
if (res?.status !== 204) {
Notification.Error({
if (!res?.ok) {
user.home_facility_object = null;
Notification.Error({

msg: "Error while clearing home facility",
});
} else {
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?.status !== 204) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (res?.status !== 204) {
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 +694,17 @@ function UserFacilities(props: { user: any }) {
pathParams: { username },
body: { facility: facility.id.toString() },
});

console.log(res);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.log(res);

if (res?.status !== 201) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
7 changes: 7 additions & 0 deletions src/Components/Users/SkillsSlideOver.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export default ({ show, setShow, username }: IProps) => {
pathParams: { username },
body: { skill: skill.id },
});

console.log(res);

soumya-maheshwari marked this conversation as resolved.
Show resolved Hide resolved
if (!res?.ok) {
Notification.Error({
msg: "Error while adding skill",
Expand All @@ -70,6 +73,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