chore(dashboard): render main layout as home page for v2 (#6823)

* chore(dashboard): render main layout as home page for v2

* chore: throw an error on store not existing
This commit is contained in:
Riqwan Thamir
2024-03-26 15:29:06 +01:00
committed by GitHub
parent a843b121cd
commit 448a30d030
7 changed files with 246 additions and 6 deletions
@@ -1,13 +1,14 @@
import { Navigate, RouteObject, useLocation } from "react-router-dom"
import { MainLayout } from "../../components/layout-v2/main-layout"
import { SettingsLayout } from "../../components/layout/settings-layout"
import { Outlet } from "react-router-dom"
import { SidebarProvider } from "../sidebar-provider"
import { SearchProvider } from "../search-provider"
import { ErrorBoundary } from "../../components/error/error-boundary"
import { Spinner } from "@medusajs/icons"
import { ErrorBoundary } from "../../components/error/error-boundary"
import { useV2Session } from "../../lib/api-v2"
import { SearchProvider } from "../search-provider"
import { SidebarProvider } from "../sidebar-provider"
export const ProtectedRoute = () => {
const { user, isLoading } = useV2Session()
@@ -52,6 +53,30 @@ export const v2Routes: RouteObject[] = [
path: "*",
lazy: () => import("../../routes/no-match"),
},
{
element: <ProtectedRoute />,
errorElement: <ErrorBoundary />,
children: [
{
path: "/",
element: <MainLayout />,
children: [
{
path: "/orders",
handle: {
crumb: () => "Orders",
},
children: [
{
path: "",
lazy: () => import("../../v2-routes/orders/order-list"),
},
],
},
],
},
],
},
{
element: <ProtectedRoute />,
errorElement: <ErrorBoundary />,