From 83002318ecd2ece31c162340da0c9c1c3e3642b8 Mon Sep 17 00:00:00 2001 From: mheggelund Date: Wed, 31 Jan 2024 13:41:41 +0100 Subject: [PATCH] fix: test rewrite router --- src/features/AppBar/Navigation/Navigation.tsx | 12 ++- src/router.tsx | 86 ++++++++----------- 2 files changed, 48 insertions(+), 50 deletions(-) diff --git a/src/features/AppBar/Navigation/Navigation.tsx b/src/features/AppBar/Navigation/Navigation.tsx index f3cc07bf..5946c08e 100644 --- a/src/features/AppBar/Navigation/Navigation.tsx +++ b/src/features/AppBar/Navigation/Navigation.tsx @@ -1,8 +1,18 @@ import { Tabs } from '@equinor/eds-core-react'; import { useNavigate } from 'react-router-dom'; -import { tabs } from '../../../router'; import * as Styled from './Navigation.styled'; +interface Tab { + title: string; + path: string; +} + +const tabs: Tab[] = [ + { title: 'Models', path: '/' }, + { title: 'API', path: 'api' }, + { title: 'About', path: 'about' }, +]; + export const Navigation = () => { const navigate = useNavigate(); diff --git a/src/router.tsx b/src/router.tsx index 5eeffc0b..d4d77f34 100644 --- a/src/router.tsx +++ b/src/router.tsx @@ -1,4 +1,4 @@ -import { createBrowserRouter, NonIndexRouteObject } from 'react-router-dom'; +import { createBrowserRouter } from 'react-router-dom'; import { App } from './App'; import { ModelView } from './features/ModelView/ModelView'; import { About } from './pages/About/About'; @@ -11,69 +11,57 @@ import { Model } from './pages/ModelPages/Model/Model'; import { ObjectResult } from './pages/ModelPages/Results/ObjectResult/ObjectResult'; import { VariogramResults } from './pages/ModelPages/Results/VariogramResults/VariogramResults'; -interface Tab extends Required> { - title: string; -} - -const tabs: Tab[] = [ - { title: 'Models', path: '/', element: }, - { title: 'API', path: 'api', element: }, - { title: 'About', path: 'about', element: }, -]; - -const appRoutes = [ - { - index: true, - element: , - }, - { - path: 'api', - element: , - }, - { - path: 'about', - element: , - }, +const router = createBrowserRouter([ { - path: ':modelId/', - element: , + path: '/', + element: , children: [ { - path: 'details', - element: , + index: true, + element: , }, - { - path: 'compute/variogram', - element: , + path: 'api', + element: , }, { - path: 'compute/object', - element: , - }, - - { - path: 'results/variogram', - element: , + path: 'about', + element: , }, { - path: 'results/object', - element: , + path: ':modelId/', + element: , + children: [ + { + path: 'details', + element: , + }, + + { + path: 'compute/variogram', + element: , + }, + { + path: 'compute/object', + element: , + }, + + { + path: 'results/variogram', + element: , + }, + { + path: 'results/object', + element: , + }, + ], }, ], }, -]; - -const router = createBrowserRouter([ - { - path: '/', - element: , - children: appRoutes, - }, { path: '*', element: , }, ]); -export { router, tabs }; +export { router };