mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
Leave project mutation
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
export {
|
||||
useAddGroupToWorkspace,
|
||||
useDeleteGroupFromWorkspace,
|
||||
useLeaveProject,
|
||||
useUpdateGroupWorkspaceRole
|
||||
} from "./mutations";
|
||||
export {
|
||||
@@ -30,4 +31,5 @@ export {
|
||||
useUpdateIdentityWorkspaceRole,
|
||||
useUpdateUserWorkspaceRole,
|
||||
useUpdateWsEnvironment,
|
||||
useUpgradeProject} from "./queries";
|
||||
useUpgradeProject
|
||||
} from "./queries";
|
||||
|
||||
@@ -62,3 +62,15 @@ export const useDeleteGroupFromWorkspace = () => {
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useLeaveProject = () => {
|
||||
return useMutation<{}, {}, { workspaceId: string; organizationId: string }>({
|
||||
mutationFn: ({ workspaceId }) => {
|
||||
return apiRequest.delete(`/api/v1/workspace/${workspaceId}/leave`);
|
||||
},
|
||||
onSuccess: (_, { organizationId }) => {
|
||||
// Invalidating the query here will cause a permission error, so we won't invalidate any queries here. Instead after leaving the workspace, we will redirect the user to the organization overview page.
|
||||
window.location.href = `/org/${organizationId}/overview`;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user