mirror of
https://github.com/Unleash/unleash.git
synced 2025-04-19 01:17:18 +02:00
fix: fetch uiConfig when the user logs in (#3107)
This PR will force a refetch of the uiConfig after the user has logged into the system.
This commit is contained in:
parent
6c84ebc8ed
commit
a2499b7213
@ -1,4 +1,4 @@
|
|||||||
import { Suspense } from 'react';
|
import { Suspense, useEffect } from 'react';
|
||||||
import { Route, Routes } from 'react-router-dom';
|
import { Route, Routes } from 'react-router-dom';
|
||||||
import { ErrorBoundary } from 'react-error-boundary';
|
import { ErrorBoundary } from 'react-error-boundary';
|
||||||
import { Error } from 'component/layout/Error/Error';
|
import { Error } from 'component/layout/Error/Error';
|
||||||
@ -29,6 +29,8 @@ const StyledContainer = styled('div')(() => ({
|
|||||||
|
|
||||||
export const App = () => {
|
export const App = () => {
|
||||||
const { authDetails } = useAuthDetails();
|
const { authDetails } = useAuthDetails();
|
||||||
|
const { refetch: refetchUiConfig } = useUiConfig();
|
||||||
|
|
||||||
const { user } = useAuthUser();
|
const { user } = useAuthUser();
|
||||||
const hasFetchedAuth = Boolean(authDetails || user);
|
const hasFetchedAuth = Boolean(authDetails || user);
|
||||||
|
|
||||||
@ -38,6 +40,12 @@ export const App = () => {
|
|||||||
? routes.filter(route => !route.enterprise)
|
? routes.filter(route => !route.enterprise)
|
||||||
: routes;
|
: routes;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (hasFetchedAuth && Boolean(user?.id)) {
|
||||||
|
refetchUiConfig();
|
||||||
|
}
|
||||||
|
}, [authDetails, user]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ErrorBoundary FallbackComponent={Error}>
|
<ErrorBoundary FallbackComponent={Error}>
|
||||||
<SWRProvider>
|
<SWRProvider>
|
||||||
|
Loading…
Reference in New Issue
Block a user