mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
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 <andreas@getunleash.ai>
This commit is contained in:
parent
84e341bbb7
commit
dda0fd3fd4
@ -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]);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user