From dda0fd3fd43e9e3ff2f7959951658ca703780884 Mon Sep 17 00:00:00 2001 From: andreas-unleash Date: Fri, 19 Jan 2024 14:31:42 +0200 Subject: [PATCH] Fix: losing redirect on provider login (#5970) Fixes the initial redirect to take into account the value from session storage --------- Signed-off-by: andreas-unleash --- frontend/src/component/InitialRedirect.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/src/component/InitialRedirect.tsx b/frontend/src/component/InitialRedirect.tsx index cc4c19a5c7..f88547846b 100644 --- a/frontend/src/component/InitialRedirect.tsx +++ b/frontend/src/component/InitialRedirect.tsx @@ -3,11 +3,13 @@ import { useNavigate } from 'react-router-dom'; 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'; export const InitialRedirect = () => { const { lastViewed } = useLastViewedProject(); const { projects, loading } = useProjects(); const navigate = useNavigate(); + const sessionRedirect = getSessionStorageItem('login-redirect'); // Redirect based on project and last viewed const getRedirect = useCallback(() => { @@ -23,10 +25,11 @@ export const InitialRedirect = () => { }, [lastViewed, projects]); const redirect = () => { - navigate(getRedirect(), { replace: true }); + navigate(sessionRedirect ?? getRedirect(), { replace: true }); }; useEffect(() => { + setSessionStorageItem('login-redirect'); redirect(); }, [getRedirect]);