Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(console): refresh invitation list after inviting members #5593

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function Invitations() {
const { canInviteMember, canRemoveMember } = useCurrentTenantScopes();

const { data, error, isLoading, mutate } = useSWR<TenantInvitationResponse[], RequestError>(
`api/tenant/${currentTenantId}/invitations`,
'api/tenants/:tenantId/invitations',
async () =>
cloudApi.get('/api/tenants/:tenantId/invitations', { params: { tenantId: currentTenantId } })
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ function Members() {
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console.tenant_members' });
const cloudApi = useAuthedCloudApi();
const { currentTenantId } = useContext(TenantsContext);
const { canInviteMember, canRemoveMember, canUpdateMemberRole } = useCurrentTenantScopes();
const { canRemoveMember, canUpdateMemberRole } = useCurrentTenantScopes();

const { data, error, isLoading, mutate } = useSWR<TenantMemberResponse[], RequestError>(
`api/tenant/${currentTenantId}/members`,
`api/tenants/:tenantId/members`,
async () =>
cloudApi.get('/api/tenants/:tenantId/members', { params: { tenantId: currentTenantId } })
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import classNames from 'classnames';
import { useState } from 'react';
import { useContext, useState } from 'react';
import { Route, Routes } from 'react-router-dom';
import useSWRMutation from 'swr/mutation';

import InvitationIcon from '@/assets/icons/invitation.svg';
import MembersIcon from '@/assets/icons/members.svg';
import PlusIcon from '@/assets/icons/plus.svg';
import { useAuthedCloudApi } from '@/cloud/hooks/use-cloud-api';
import { TenantSettingsTabs } from '@/consts';
import { TenantsContext } from '@/contexts/TenantsProvider';
import Button from '@/ds-components/Button';
import Spacer from '@/ds-components/Spacer';
import useCurrentTenantScopes from '@/hooks/use-current-tenant-scopes';
Expand All @@ -28,6 +31,14 @@ function TenantMembers() {
`/tenant-settings/${TenantSettingsTabs.Members}/${invitationsRoute}`
);

const { currentTenantId } = useContext(TenantsContext);
const cloudApi = useAuthedCloudApi();
const { trigger: mutateInvitations } = useSWRMutation(
'api/tenants/:tenantId/invitations',
async () =>
cloudApi.get('/api/tenants/:tenantId/invitations', { params: { tenantId: currentTenantId } })
);

return (
<div className={styles.container}>
<div className={styles.tabButtons}>
Expand Down Expand Up @@ -73,7 +84,11 @@ function TenantMembers() {
onClose={(isSuccessful) => {
setShowInviteModal(false);
if (isSuccessful) {
navigate('invitations');
if (isInvitationTab) {
void mutateInvitations();
} else {
navigate('invitations');
}
}
}}
/>
Expand Down