From 36bc82975730b1675ad3176adc58a9ea276ba2e7 Mon Sep 17 00:00:00 2001 From: Jean Paul Elisa NIYOKWIZERWA <140616733+Ndevu12@users.noreply.github.com> Date: Thu, 3 Oct 2024 11:15:34 +0200 Subject: [PATCH] fixing fetching invitation for specific organization (#515) --- src/pages/invitation.tsx | 15 ++++++++++++--- src/queries/invitation.queries.tsx | 4 ++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/pages/invitation.tsx b/src/pages/invitation.tsx index d836090d0..d360c5343 100644 --- a/src/pages/invitation.tsx +++ b/src/pages/invitation.tsx @@ -213,9 +213,15 @@ function Invitation() { useEffect(() => { if (filterVariables.role || filterVariables.status) { - filterInvitations(); + filterInvitations({ + variables: { + role: filterVariables.role || null, + status: typeof filterVariables.status === 'string' ? filterVariables.status : null, + orgToken: organizationToken, + }, + }); } - }, [filterVariables, filterInvitations]); + }, [filterVariables, filterInvitations,organizationToken]); // Consolidated effect to handle query and search data useEffect(() => { @@ -278,7 +284,10 @@ function Invitation() { setError(null); setLoading(false); - setFilterVariables({ role: selectedRole, status: selectedStatus }); + setFilterVariables({ + role: selectedRole, + status: typeof selectedStatus === 'string' ? selectedStatus : '', + }); }; const toggleOptions = (row: string) => { diff --git a/src/queries/invitation.queries.tsx b/src/queries/invitation.queries.tsx index 573f46916..b1b97200a 100644 --- a/src/queries/invitation.queries.tsx +++ b/src/queries/invitation.queries.tsx @@ -33,8 +33,8 @@ export const GET_INVITATIONS = gql` `; export const GET_ROLES_AND_STATUSES = gql` - query filterInvitations($limit: Int, $offset: Int, $role: String, $status: String) { - filterInvitations(limit: $limit, offset: $offset, role: $role, status: $status) { + query filterInvitations($limit: Int, $offset: Int, $role: String, $status: String, $orgToken: String!) { + filterInvitations(limit: $limit, offset: $offset, role: $role, status: $status, orgToken: $orgToken) { invitations { invitees { email