mirror of
https://github.com/logto-io/logto.git
synced 2025-03-10 22:22:45 -05:00
fix(console): refresh invitation list after inviting members (#5593)
This commit is contained in:
parent
ceeeeb07a3
commit
0438a2e890
3 changed files with 20 additions and 5 deletions
|
@ -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 } })
|
||||
);
|
||||
|
|
|
@ -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 } })
|
||||
);
|
||||
|
|
|
@ -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';
|
||||
|
@ -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}>
|
||||
|
@ -73,7 +84,11 @@ function TenantMembers() {
|
|||
onClose={(isSuccessful) => {
|
||||
setShowInviteModal(false);
|
||||
if (isSuccessful) {
|
||||
navigate('invitations');
|
||||
if (isInvitationTab) {
|
||||
void mutateInvitations();
|
||||
} else {
|
||||
navigate('invitations');
|
||||
}
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
|
Loading…
Add table
Reference in a new issue