Skip to content

Commit

Permalink
Delete membership by email
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielHougaard committed Feb 13, 2024
1 parent ca7d2e9 commit 1edaa58
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
12 changes: 4 additions & 8 deletions frontend/src/hooks/api/workspace/queries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -337,16 +337,12 @@ export const useDeleteUserFromWorkspace = () => {
const queryClient = useQueryClient();

return useMutation({
mutationFn: async ({
membershipId,
workspaceId
}: {
workspaceId: string;
membershipId: string;
}) => {
mutationFn: async ({ emails, workspaceId }: { workspaceId: string; emails: string[] }) => {
const {
data: { deletedMembership }
} = await apiRequest.delete(`/api/v1/workspace/${workspaceId}/memberships/${membershipId}`);
} = await apiRequest.delete(`/api/v2/workspace/${workspaceId}/memberships`, {
data: { emails }
});
return deletedMembership;
},
onSuccess: (_, { workspaceId }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ export const MemberListTab = () => {
};

const handleRemoveUser = async () => {
const membershipId = (popUp?.removeMember?.data as { id: string })?.id;
const email = (popUp?.removeMember?.data as { email: string })?.email;
if (!currentOrg?.id) return;

try {
await removeUserFromWorkspace({ workspaceId, membershipId });
await removeUserFromWorkspace({ workspaceId, emails: [email] });
createNotification({
text: "Successfully removed user from project",
type: "success"
Expand Down Expand Up @@ -372,7 +372,7 @@ export const MemberListTab = () => {
className="ml-4"
isDisabled={userId === u?.id || !isAllowed}
onClick={() =>
handlePopUpOpen("removeMember", { id: membershipId })
handlePopUpOpen("removeMember", { email: u.email })
}
>
<FontAwesomeIcon icon={faXmark} />
Expand Down Expand Up @@ -456,7 +456,7 @@ export const MemberListTab = () => {
<DeleteActionModal
isOpen={popUp.removeMember.isOpen}
deleteKey="remove"
title="Do you want to remove this user from the org?"
title="Do you want to remove this user from the project?"
onChange={(isOpen) => handlePopUpToggle("removeMember", isOpen)}
onDeleteApproved={handleRemoveUser}
/>
Expand Down

0 comments on commit 1edaa58

Please sign in to comment.