mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-21 09:28:14 +00:00
refactor: enhance notification handling and streamline async logic across various components
This commit is contained in:
+9
-17
@@ -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 (
|
||||
|
||||
-12
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user