From e86ffa3a80aa9429fb0be4d16efc6845cf99a24b Mon Sep 17 00:00:00 2001 From: Xiao Yijun Date: Mon, 15 Apr 2024 21:12:21 +0800 Subject: [PATCH] fix(console): mutate org roles once a org role is deleted (#5716) --- .../pages/OrganizationRoleDetails/index.tsx | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/console/src/pages/OrganizationRoleDetails/index.tsx b/packages/console/src/pages/OrganizationRoleDetails/index.tsx index b64fbf8ce..e4f9f2e76 100644 --- a/packages/console/src/pages/OrganizationRoleDetails/index.tsx +++ b/packages/console/src/pages/OrganizationRoleDetails/index.tsx @@ -23,7 +23,11 @@ import useTenantPathname from '@/hooks/use-tenant-pathname'; import * as styles from './index.module.scss'; import { type OrganizationRoleDetailsOutletContext } from './types'; -const orgRolesPath = `/organization-template/${OrganizationTemplateTabs.OrganizationRoles}`; +// Console path for organization roles +const organizationRolesPath = `/organization-template/${OrganizationTemplateTabs.OrganizationRoles}`; + +// API endpoint for organization roles +const organizationRolesEndpoint = 'api/organization-roles'; function OrganizationRoleDetails() { const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' }); @@ -34,7 +38,7 @@ function OrganizationRoleDetails() { const isPageHasTable = pathname.endsWith(OrganizationRoleDetailsTabs.Permissions); const { data, error, mutate, isLoading } = useSWR( - id && `api/organization-roles/${id}` + id && `${organizationRolesEndpoint}/${id}` ); const api = useApi(); const { mutate: mutateGlobal } = useSWRConfig(); @@ -54,10 +58,10 @@ function OrganizationRoleDetails() { setIsDeleting(true); try { - await api.delete(`api/organization-roles/${data.id}`); + await api.delete(`${organizationRolesEndpoint}/${data.id}`); toast.success(t('organization_role_details.deleted', { name: data.name })); - await mutateGlobal('api/roles'); - navigate(orgRolesPath, { replace: true }); + await mutateGlobal(organizationRolesEndpoint); + navigate(organizationRolesPath, { replace: true }); } finally { setIsDeleting(false); } @@ -65,7 +69,7 @@ function OrganizationRoleDetails() { return ( - +