From bf787b6deb39192cde149503b9426ae87015a1df Mon Sep 17 00:00:00 2001 From: Mateusz Kwasniewski Date: Tue, 1 Oct 2024 13:11:29 +0200 Subject: [PATCH] feat: redirect to personal dashboard when no last project (#8318) --- frontend/src/component/InitialRedirect.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/frontend/src/component/InitialRedirect.tsx b/frontend/src/component/InitialRedirect.tsx index 4377385f52..f65ba0e718 100644 --- a/frontend/src/component/InitialRedirect.tsx +++ b/frontend/src/component/InitialRedirect.tsx @@ -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 });