import React, { lazy } from "react";
import { Route } from "react-router-dom";
import ProtectedRoute from "../../auth/ProtectedRoute";
import { LazyRoute } from "../../common/LazyRoute";

const Dashboard = lazy(() => import("./Dashboard"));
const SeverityOfHarmStats = lazy(() => import("./pages/SeverityOfHarmStats"));
const LikelihoodOfHarmStats = lazy(() => import("./pages/LikelihoodOfHarmStats"));
const RpnAuditListPage = lazy(() => import("./pages/RpnAuditListPage"));
const ObservationsOpenClosedPage = lazy(() =>
  import("./pages/ObservationsOpenClosedPage"),
);
const SioOioCaListPage = lazy(() => import("./pages/SioOioCaListPage"));

/** Route nodes for `<Routes>` — must be direct children (arrays are ok). */
export const dashboardRoutes = [
  <Route
    key="dashboard-main"
    path="/dashboard"
    element={
      <ProtectedRoute>
        <LazyRoute>
          <Dashboard />
        </LazyRoute>
      </ProtectedRoute>
    }
  />,
  <Route
    key="dashboard-severity-of-harm"
    path="/dashboard/severity-of-harm-stats"
    element={
      <ProtectedRoute>
        <LazyRoute>
          <SeverityOfHarmStats />
        </LazyRoute>
      </ProtectedRoute>
    }
  />,
  <Route
    key="dashboard-likelihood-of-harm"
    path="/dashboard/likelihood-of-harm-stats"
    element={
      <ProtectedRoute>
        <LazyRoute>
          <LikelihoodOfHarmStats />
        </LazyRoute>
      </ProtectedRoute>
    }
  />,
  <Route
    key="dashboard-rpn-audit-list"
    path="/dashboard/rpn-audit-list/:rpnValue"
    element={
      <ProtectedRoute>
        <LazyRoute>
          <RpnAuditListPage />
        </LazyRoute>
      </ProtectedRoute>
    }
  />,
  <Route
    key="dashboard-observations-open-closed"
    path="/dashboard/observations-open-closed-page"
    element={
      <ProtectedRoute>
        <LazyRoute>
          <ObservationsOpenClosedPage />
        </LazyRoute>
      </ProtectedRoute>
    }
  />,
  <Route
    key="dashboard-sio-oio-ca-list"
    path="/dashboard/sio-oio-ca-list"
    element={
      <ProtectedRoute>
        <LazyRoute>
          <SioOioCaListPage />
        </LazyRoute>
      </ProtectedRoute>
    }
  />,
];
