Skip to content

Commit

Permalink
make redirect work
Browse files Browse the repository at this point in the history
  • Loading branch information
simlarsen committed Jun 1, 2023
1 parent 5f54f76 commit 41b4092
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
File renamed without changes.
9 changes: 9 additions & 0 deletions StatusPage/src/Pages/Accounts/SSO.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { DASHBOARD_API_URL, FILE_URL, IDENTITY_URL } from 'CommonUI/src/Config';
import ObjectID from 'Common/Types/ObjectID';
import StatusPageSSO from 'Model/Models/StatusPageSso';
import PageLoader from 'CommonUI/src/Components/Loader/PageLoader';
import LocalStorage from 'CommonUI/src/Utils/LocalStorage';

export interface ComponentProps {
statusPageId: ObjectID | null;
Expand Down Expand Up @@ -42,6 +43,14 @@ const LoginPage: FunctionComponent<ComponentProps> = (
);
}

if (Navigation.getQueryStringByName('redirectUrl')) {
// save this to local storage, so in the overview page. We can redirect to this page.
LocalStorage.setItem(
'redirectUrl',
Navigation.getQueryStringByName('redirectUrl')
);
}

if (isLoading) {
return <PageLoader isVisible={true} />;
}
Expand Down
13 changes: 13 additions & 0 deletions StatusPage/src/Pages/Overview/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ import MarkdownViewer from 'CommonUI/src/Components/Markdown.tsx/MarkdownViewer'
const Overview: FunctionComponent<PageComponentProps> = (
props: PageComponentProps
): ReactElement => {
if (LocalStorage.getItem('redirectUrl')) {
// const get item

const redirectUrl: string = LocalStorage.getItem(
'redirectUrl'
) as string;

// clear local storage.
LocalStorage.removeItem('redirectUrl');

Navigation.navigate(new Route(redirectUrl));
}

const [isLoading, setIsLoading] = useState<boolean>(true);
const [error, setError] = useState<string | null>(null);
const [
Expand Down

0 comments on commit 41b4092

Please sign in to comment.