mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-04 00:18:01 +01:00
feat: redirect to personal dashboard when no last project (#8318)
This commit is contained in:
parent
a6ab5326a0
commit
bf787b6deb
@ -1,11 +1,13 @@
|
||||
import { useCallback, useEffect } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import useProjects from '../hooks/api/getters/useProjects/useProjects';
|
||||
import { useLastViewedProject } from '../hooks/useLastViewedProject';
|
||||
import useProjects from 'hooks/api/getters/useProjects/useProjects';
|
||||
import { useLastViewedProject } from 'hooks/useLastViewedProject';
|
||||
import Loader from './common/Loader/Loader';
|
||||
import { getSessionStorageItem, setSessionStorageItem } from '../utils/storage';
|
||||
import { getSessionStorageItem, setSessionStorageItem } from 'utils/storage';
|
||||
import { useUiFlag } from 'hooks/useUiFlag';
|
||||
|
||||
export const InitialRedirect = () => {
|
||||
const personalDashboardUiEnabled = useUiFlag('personalDashboardUI');
|
||||
const { lastViewed } = useLastViewedProject();
|
||||
const { projects, loading } = useProjects();
|
||||
const navigate = useNavigate();
|
||||
@ -17,12 +19,16 @@ export const InitialRedirect = () => {
|
||||
return `/projects/${lastViewed}`;
|
||||
}
|
||||
|
||||
if (personalDashboardUiEnabled) {
|
||||
return '/personal';
|
||||
}
|
||||
|
||||
if (projects && !lastViewed && projects.length === 1) {
|
||||
return `/projects/${projects[0].id}`;
|
||||
}
|
||||
|
||||
return '/projects';
|
||||
}, [lastViewed, projects]);
|
||||
}, [lastViewed, projects, personalDashboardUiEnabled]);
|
||||
|
||||
const redirect = () => {
|
||||
navigate(sessionRedirect ?? getRedirect(), { replace: true });
|
||||
|
Loading…
Reference in New Issue
Block a user