refactor: enhance notification handling and streamline async logic across various components

This commit is contained in:
Victor Santos
2025-11-03 11:58:44 -03:00
parent 1ed59a7304
commit 3aeee8d552
38 changed files with 653 additions and 1064 deletions
@@ -10,24 +10,16 @@ export const DeleteProjectProtection = () => {
const { mutateAsync } = useUpdateProject();
const handleToggleDeleteProjectProtection = async (state: boolean) => {
try {
await mutateAsync({
projectId,
hasDeleteProtection: state
});
await mutateAsync({
projectId,
hasDeleteProtection: state
});
const text = `Successfully ${state ? "enabled" : "disabled"} delete protection`;
createNotification({
text,
type: "success"
});
} catch (err) {
console.error(err);
createNotification({
text: "Failed to update delete protection",
type: "error"
});
}
const text = `Successfully ${state ? "enabled" : "disabled"} delete protection`;
createNotification({
text,
type: "success"
});
};
return (
@@ -68,12 +68,6 @@ export const DeleteProjectSection = () => {
to: "/organization/projects"
});
handlePopUpClose("deleteWorkspace");
} catch (err) {
console.error(err);
createNotification({
text: "Failed to delete project",
type: "error"
});
} finally {
setIsDeleting.off();
}
@@ -118,12 +112,6 @@ export const DeleteProjectSection = () => {
navigate({
to: "/organization/projects"
});
} catch (err) {
console.error(err);
createNotification({
text: "Failed to leave project",
type: "error"
});
} finally {
setIsLeaving.off();
}