From f536e554d66b037975f2d97db766ba0f11429fee Mon Sep 17 00:00:00 2001 From: jjgancfer Date: Tue, 20 Feb 2024 18:50:47 +0100 Subject: [PATCH 1/2] feat: replaced the JSON-based routing for a declarative one --- webapp/src/components/Router.jsx | 50 ++++++++++++++++++-------------- webapp/src/index.js | 3 +- 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/webapp/src/components/Router.jsx b/webapp/src/components/Router.jsx index d883add9..fed9374a 100644 --- a/webapp/src/components/Router.jsx +++ b/webapp/src/components/Router.jsx @@ -3,26 +3,34 @@ import Root from "../pages/Root"; // import Login from "../pages/Login"; // import Register from "../pages/Register"; import Layout from "./Layout"; +import { Route, createBrowserRouter, createRoutesFromElements } from "react-router-dom"; -const router = [ - { - path: "/", - element: , - children: [ - { - path: "/", - element: , - } - // },{ - // path: "/login", - // element: - // }, - // { - // path: "/register", - // element: - // } - ] - } -]; +// const router = [ +// { +// path: "/", +// element: , +// children: [ +// { +// path: "/", +// element: , +// } +// // },{ +// // path: "/login", +// // element: +// // }, +// // { +// // path: "/register", +// // element: +// // } +// ] +// } +// ]; -export default router; \ No newline at end of file + +export default createBrowserRouter( + createRoutesFromElements( + } > + } /> + + ) +) \ No newline at end of file diff --git a/webapp/src/index.js b/webapp/src/index.js index 2a34dfff..25b392f3 100644 --- a/webapp/src/index.js +++ b/webapp/src/index.js @@ -9,11 +9,10 @@ import { ChakraProvider } from '@chakra-ui/react'; import "./i18n"; const root = ReactDOM.createRoot(document.querySelector("body")); -const browserRouter = createBrowserRouter(router); root.render( - + ); From 023c2255ccfb7be91290ef63548652adf009c074 Mon Sep 17 00:00:00 2001 From: jjgancfer Date: Wed, 21 Feb 2024 09:37:21 +0100 Subject: [PATCH 2/2] chore: clean up code from last commit --- webapp/src/components/Router.jsx | 30 ++---------------------------- webapp/src/index.js | 3 ++- 2 files changed, 4 insertions(+), 29 deletions(-) diff --git a/webapp/src/components/Router.jsx b/webapp/src/components/Router.jsx index fed9374a..499cde86 100644 --- a/webapp/src/components/Router.jsx +++ b/webapp/src/components/Router.jsx @@ -1,36 +1,10 @@ import React from "react"; import Root from "../pages/Root"; -// import Login from "../pages/Login"; -// import Register from "../pages/Register"; import Layout from "./Layout"; import { Route, createBrowserRouter, createRoutesFromElements } from "react-router-dom"; -// const router = [ -// { -// path: "/", -// element: , -// children: [ -// { -// path: "/", -// element: , -// } -// // },{ -// // path: "/login", -// // element: -// // }, -// // { -// // path: "/register", -// // element: -// // } -// ] -// } -// ]; - - -export default createBrowserRouter( - createRoutesFromElements( +export default createRoutesFromElements( } > } /> - ) -) \ No newline at end of file + ) \ No newline at end of file diff --git a/webapp/src/index.js b/webapp/src/index.js index 25b392f3..2a34dfff 100644 --- a/webapp/src/index.js +++ b/webapp/src/index.js @@ -9,10 +9,11 @@ import { ChakraProvider } from '@chakra-ui/react'; import "./i18n"; const root = ReactDOM.createRoot(document.querySelector("body")); +const browserRouter = createBrowserRouter(router); root.render( - + );