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

const CreateAudit = lazy(() => import("./CreateAudit"));
const CreateAuditObservationsPage = lazy(() =>
  import("./CreateAuditObservationsPage"),
);
const UpdateAudit = lazy(() => import("./UpdateAudit"));
const FormSubmission = lazy(() => import("./FormSubmission"));
const SelectForm = lazy(() => import("./SelectForm"));
const SelectFormForCreate = lazy(() => import("./SelectFormForCreate"));
const SelectFormForUpdate = lazy(() => import("./SelectFormForUpdate"));
const SubmissionsList = lazy(() => import("./SubmissionsList"));
const ViewSubmission = lazy(() => import("./ViewSubmission"));
const AuditStatus = lazy(() => import("./AuditStatus"));
const CriticalFindingsAudits = lazy(() => import("./CriticalFindingsAudits"));
const MyAudits = lazy(() => import("./MyAudits"));
const AuditFormsPage = lazy(() => import("./AuditFormsPage"));
const SelectClosingForm = lazy(() => import("./SelectClosingForm"));
const AuditScheduling = lazy(() => import("./AuditScheduling"));
const AuditScheduleDateDetail = lazy(() => import("./AuditScheduleDateDetail"));
const UserWiseAuditDetails = lazy(() => import("./UserWiseAuditDetails"));

export const auditManagementRoutes = [
  <Route
    key="create-audit"
    path="/create-audit"
    element={
      <ProtectedRoute>
        <LazyRoute>
          <CreateAudit />
        </LazyRoute>
      </ProtectedRoute>
    }
  />,
  <Route
    key="create-audit-observations"
    path="/create-audit-observations"
    element={
      <ProtectedRoute>
        <LazyRoute>
          <CreateAuditObservationsPage />
        </LazyRoute>
      </ProtectedRoute>
    }
  />,
  <Route
    key="update-audit-root"
    path="/update-audit"
    element={
      <ProtectedRoute>
        <LazyRoute>
          <UpdateAudit />
        </LazyRoute>
      </ProtectedRoute>
    }
  />,
  <Route
    key="update-audit-id"
    path="/update-audit/:id"
    element={
      <ProtectedRoute>
        <LazyRoute>
          <UpdateAudit />
        </LazyRoute>
      </ProtectedRoute>
    }
  />,
  <Route
    key="select-form"
    path="/select-form"
    element={
      <ProtectedRoute>
        <LazyRoute>
          <SelectForm />
        </LazyRoute>
      </ProtectedRoute>
    }
  />,
  <Route
    key="select-form-for-create"
    path="/select-form-for-create"
    element={
      <ProtectedRoute>
        <LazyRoute>
          <SelectFormForCreate />
        </LazyRoute>
      </ProtectedRoute>
    }
  />,
  <Route
    key="select-form-update"
    path="/select-form-update"
    element={
      <ProtectedRoute>
        <LazyRoute>
          <SelectFormForUpdate />
        </LazyRoute>
      </ProtectedRoute>
    }
  />,
  <Route
    key="submit-form"
    path="/submit-form"
    element={
      <ProtectedRoute>
        <LazyRoute>
          <FormSubmission />
        </LazyRoute>
      </ProtectedRoute>
    }
  />,
  <Route
    key="submissions"
    path="/submissions"
    element={
      <ProtectedRoute>
        <LazyRoute>
          <SubmissionsList />
        </LazyRoute>
      </ProtectedRoute>
    }
  />,
  <Route
    key="audit-status"
    path="/audit-status"
    element={
      <ProtectedRoute>
        <LazyRoute>
          <AuditStatus />
        </LazyRoute>
      </ProtectedRoute>
    }
  />,
  <Route
    key="user-wise-audits"
    path="/user-wise-audits"
    element={
      <ProtectedRoute>
        <LazyRoute>
          <UserWiseAuditDetails />
        </LazyRoute>
      </ProtectedRoute>
    }
  />,
  <Route
    key="critical-findings"
    path="/critical-findings"
    element={
      <ProtectedRoute>
        <LazyRoute>
          <CriticalFindingsAudits />
        </LazyRoute>
      </ProtectedRoute>
    }
  />,
  <Route
    key="my-audits"
    path="/my-audits"
    element={
      <ProtectedRoute>
        <LazyRoute>
          <MyAudits />
        </LazyRoute>
      </ProtectedRoute>
    }
  />,
  <Route
    key="audit-schedule"
    path="/audit-schedule"
    element={
      <ProtectedRoute>
        <LazyRoute>
          <AuditScheduling />
        </LazyRoute>
      </ProtectedRoute>
    }
  />,
  <Route
    key="audit-schedule-date"
    path="/audit-schedule/date/:dateStr"
    element={
      <ProtectedRoute>
        <LazyRoute>
          <AuditScheduleDateDetail />
        </LazyRoute>
      </ProtectedRoute>
    }
  />,
  <Route
    key="audit-forms"
    path="/audit/:auditId/forms"
    element={
      <ProtectedRoute>
        <LazyRoute>
          <AuditFormsPage />
        </LazyRoute>
      </ProtectedRoute>
    }
  />,
  <Route
    key="audit-close-form"
    path="/audit/:auditId/close/:openingSubmissionId"
    element={
      <ProtectedRoute>
        <LazyRoute>
          <SelectClosingForm />
        </LazyRoute>
      </ProtectedRoute>
    }
  />,
  <Route
    key="view-submission"
    path="/view-submission/:id"
    element={
      <ProtectedRoute>
        <LazyRoute>
          <ViewSubmission />
        </LazyRoute>
      </ProtectedRoute>
    }
  />,
];
