Skip to content

Commit

Permalink
Refetching of orgs added after leaving org
Browse files Browse the repository at this point in the history
  • Loading branch information
raggettii committed Dec 10, 2024
1 parent ef9bef6 commit 1228beb
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/screens/UserPortal/LeaveOrganization/LeaveOrganization.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import React, { useState } from 'react';
import { useQuery, useMutation } from '@apollo/client';
import { ORGANIZATIONS_LIST } from 'GraphQl/Queries/Queries';
import {
ORGANIZATIONS_LIST,
USER_ORGANIZATION_CONNECTION,
} from 'GraphQl/Queries/Queries';
import { REMOVE_MEMBER_MUTATION } from 'GraphQl/Mutations/mutations';
import { Button, Modal, Form, Spinner, Alert } from 'react-bootstrap';
import { useParams, useNavigate } from 'react-router-dom';
Expand Down Expand Up @@ -28,11 +31,16 @@ const LeaveOrganization = (): JSX.Element => {
});

const [removeMember] = useMutation(REMOVE_MEMBER_MUTATION, {
refetchQueries: [
{
query: USER_ORGANIZATION_CONNECTION,
variables: { id: organizationId },
},
],
onCompleted: () => {
alert('You have successfully left the organization!');
setShowModal(false);
navigate(`/user/organizations`);
window.location.reload();
},
onError: (err) => {
setError(err.message);
Expand Down

0 comments on commit 1228beb

Please sign in to comment.