diff --git a/src/App.tsx b/src/App.tsx
index 8dc0a71..1ca9de4 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -1,4 +1,4 @@
-import { BrowserRouter, Route, Routes } from "react-router";
+import { createBrowserRouter, RouterProvider } from "react-router";
import NavBar from "./components/nav/NavBar";
import AdminPage from "./pages/protected/AdminPage";
import GamePage from "./pages/protected/GamePage";
@@ -13,98 +13,82 @@ import HomePage from "./pages/public/HomePage";
import LoginPage from "./pages/public/LoginPage";
import SignupPage from "./pages/public/SignupPage";
import { ProtectedRoute } from "./providers/AuthProvider";
+import ErrorBoundary from "./providers/ErrorBoundary";
-const publicRoutes: { path: string; element: React.ReactElement; }[] = [
+const routes = createBrowserRouter([
{
- path: "/",
- element:
- },
- {
- path: "/login",
- element:
- },
- {
- path: "/signup",
- element:
+ element: ,
+ children: [
+ {
+ errorElement: ,
+ children: [
+ {
+ path: "/",
+ element:
+ },
+ {
+ path: "/login",
+ element:
+ },
+ {
+ path: "/signup",
+ element:
+ },
+ {
+ element: ,
+ children: [
+ {
+ path: "/logout",
+ element:
+ },
+ {
+ path: "/admin",
+ element:
+ },
+ {
+ path: "/game",
+ element:
+ },
+ {
+ path: "/game/:gameId",
+ element:
+ },
+ {
+ path: "/raidGroup",
+ element:
+ },
+ {
+ path: "/raidGroup/:raidGroupId",
+ element:
+ },
+ {
+ path: "/raidGroup/:raidGroupId/person/:personId",
+ element:
+ },
+ {
+ path: "/raidGroup/:raidGroupId/raidLayout/:raidLayoutId",
+ element:
+ },
+ {
+ path: "/raidGroup/:raidGroupId/raidInstance",
+ element:
+ },
+ {
+ path: "/raidGroup/:raidGroupId/raidInstance/:raidInstanceId",
+ element:
+ }
+ ]
+ }
+ ]
+ }
+ ]
}
-];
-
-const protectedRoutes: { path: string; element: React.ReactElement; }[] = [
- {
- path: "/logout",
- element:
- },
- {
- path: "/admin",
- element:
- },
- {
- path: "/game",
- element:
- },
- {
- path: "/game/:gameId",
- element:
- },
- {
- path: "/raidGroup",
- element:
- },
- {
- path: "/raidGroup/:raidGroupId",
- element:
- },
- {
- path: "/raidGroup/:raidGroupId/person/:personId",
- element:
- },
- {
- path: "/raidGroup/:raidGroupId/raidLayout/:raidLayoutId",
- element:
- },
- {
- path: "/raidGroup/:raidGroupId/raidInstance",
- element:
- },
- {
- path: "/raidGroup/:raidGroupId/raidInstance/:raidInstanceId",
- element:
- }
-];
+]);
export default function App(){
return (
-
- {/* Nav Bar */}
-
-
- {/* Routing */}
-
- {/* Public Routes */}
- {
- publicRoutes.map((route) => (
-
- ))
- }
- {/* Protected Routes */}
- }>
- {
- protectedRoutes.map((route) => (
-
- ))
- }
-
-
-
+
);
}
diff --git a/src/components/nav/NavBar.tsx b/src/components/nav/NavBar.tsx
index 20f5da2..be89d8b 100644
--- a/src/components/nav/NavBar.tsx
+++ b/src/components/nav/NavBar.tsx
@@ -1,6 +1,6 @@
import clsx from "clsx";
import { BsList } from "react-icons/bs";
-import { Link } from "react-router";
+import { Link, Outlet } from "react-router";
import DarkModeToggle from "./DarkModeToggle";
import ProtectedNavLinks from "./ProtectedNavLinks";
import PublicNavLinks from "./PublicNavLinks";
@@ -9,48 +9,51 @@ import raidBuilderIcon from "/raidBuilderIcon.svg";
export default function NavBar(){
return (
-
+
+
+ >
);
}
diff --git a/src/providers/ErrorBoundary.tsx b/src/providers/ErrorBoundary.tsx
new file mode 100644
index 0000000..9933e8b
--- /dev/null
+++ b/src/providers/ErrorBoundary.tsx
@@ -0,0 +1,16 @@
+import { useRouteError } from "react-router";
+
+
+export default function ErrorBoundary(){
+ const error = useRouteError();
+
+ console.log("error");
+ console.log(error);
+
+
+ return (
+
+ Error Boundary
+
+ );
+}