Skip to content

Commit

Permalink
Merge pull request #339 from akaene/fix/system-tab-preselect
Browse files Browse the repository at this point in the history
Fix for system pre-select
  • Loading branch information
blcham authored Jun 2, 2024
2 parents f9bd40a + 59f3ebd commit 9bf7c71
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
7 changes: 2 additions & 5 deletions src/components/routes/AppRoutes.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from "react";
import Login from "@components/login/Login";
import { BrowserRouter, Route, Routes } from "react-router-dom";
import { BrowserRouter, Route, Routes, Navigate } from "react-router-dom";
import Logout from "@components/Logout";
import Register from "@components/register/Register";
import { createHashHistory } from "history";
Expand Down Expand Up @@ -68,10 +68,6 @@ const AppRoutes = () => {
path: ROUTES.FHA,
element: <FhaOverview />,
},
{
path: "/*",
element: <SystemsOverview />,
},
];

const getElement = (path, element) => {
Expand Down Expand Up @@ -101,6 +97,7 @@ const AppRoutes = () => {
<Routes>
<Route path={ROUTES.OIDC_SIGNIN_CALLBACK} element={<OidcSignInCallback />} />
<Route path={ROUTES.OIDC_SILENT_CALLBACK} element={<OidcSilentCallback />} />
<Route path={ROUTES.ROOT} element={<Navigate to={ROUTES.SYSTEMS} />} />

{routes.map((r) => {
if (isUsingOidcAuth()) {
Expand Down
6 changes: 1 addition & 5 deletions src/components/routes/PublicRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ import { ROUTES } from "@utils/constants";
const Element = ({ component: Component, loggedUser, restricted, ...props }) => {
return (
<>
{loggedUser && loggedUser.authenticated && restricted ? (
<Navigate to={ROUTES.DASHBOARD} />
) : (
<Component {...props} />
)}
{loggedUser && loggedUser.authenticated && restricted ? <Navigate to={ROUTES.ROOT} /> : <Component {...props} />}
</>
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/utils/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const ROUTES = {
OIDC_SIGNIN_CALLBACK: "/oidc-signin-callback",
OIDC_SILENT_CALLBACK: "/oidc-silent-callback",

DASHBOARD: "/",
ROOT: "/",
SYSTEMS: "/systems",
FTA: "/fta",
FMEA: "/fmea",
Expand Down

0 comments on commit 9bf7c71

Please sign in to comment.