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 useProjects from '../hooks/api/getters/useProjects/useProjects';
|
||||||
import { useLastViewedProject } from '../hooks/useLastViewedProject';
|
import { useLastViewedProject } from '../hooks/useLastViewedProject';
|
||||||
import Loader from './common/Loader/Loader';
|
import Loader from './common/Loader/Loader';
|
||||||
|
import { getSessionStorageItem, setSessionStorageItem } from '../utils/storage';
|
||||||
|
|
||||||
export const InitialRedirect = () => {
|
export const InitialRedirect = () => {
|
||||||
const { lastViewed } = useLastViewedProject();
|
const { lastViewed } = useLastViewedProject();
|
||||||
const { projects, loading } = useProjects();
|
const { projects, loading } = useProjects();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const sessionRedirect = getSessionStorageItem('login-redirect');
|
||||||
|
|
||||||
// Redirect based on project and last viewed
|
// Redirect based on project and last viewed
|
||||||
const getRedirect = useCallback(() => {
|
const getRedirect = useCallback(() => {
|
||||||
@ -23,10 +25,11 @@ export const InitialRedirect = () => {
|
|||||||
}, [lastViewed, projects]);
|
}, [lastViewed, projects]);
|
||||||
|
|
||||||
const redirect = () => {
|
const redirect = () => {
|
||||||
navigate(getRedirect(), { replace: true });
|
navigate(sessionRedirect ?? getRedirect(), { replace: true });
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
setSessionStorageItem('login-redirect');
|
||||||
redirect();
|
redirect();
|
||||||
}, [getRedirect]);
|
}, [getRedirect]);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user