import { createBrowserRouter, Navigate } from 'react-router-dom';
import App from '../App';
import Dashboard from '../Dashboard';
import Login from '../views/Login';
import ProtectedRoute from '../components/ProtectedRoute';
import ProcessDesigner from '../components/ProcessDesigner';
import FormDesigner from '../components/FormDesigner';
import WorkJobDetail from '../components/WorkJobDetail';
import WorkJobArchiveReport from '../components/WorkJobArchiveReport';
import LockCabinetDetail from '../components/lockCabinet/LockCabinetDetail';

// 路由配置
export const router = createBrowserRouter([
  {
    path: '/',
    element: <App />,
    children: [
      {
        index: true,
        element: <Navigate to="/login" replace />,
      },
      {
        path: 'login',
        element: <Login />,
      },
    ],
  },
  {
    path: '/dashboard',
    element: (
      <ProtectedRoute>
        <Dashboard />
      </ProtectedRoute>
    ),
  },
  {
    path: '/lock-cabinet/detail',
    element: (
      <ProtectedRoute>
        <LockCabinetDetail />
      </ProtectedRoute>
    ),
  },
  {
    path: '/system/cabinet',
    element: (
      <ProtectedRoute>
        <Dashboard />
      </ProtectedRoute>
    ),
  },
  {
    path: '/process-designer',
    element: (
      <ProtectedRoute>
        <ProcessDesigner />
      </ProtectedRoute>
    ),
  },
  {
    path: '/bpm/form/editor',
    element: (
      <ProtectedRoute>
        <FormDesigner key="form-designer" />
      </ProtectedRoute>
    ),
  },
  {
    path: '/work-job/detail',
    element: (
      <ProtectedRoute>
        <WorkJobDetail />
      </ProtectedRoute>
    ),
  },
  {
    path: '/work-job/archive',
    element: (
      <ProtectedRoute>
        <WorkJobArchiveReport />
      </ProtectedRoute>
    ),
  },
  {
    path: '/clientSystem/*',
    element: (
      <ProtectedRoute>
        <Dashboard />
      </ProtectedRoute>
    ),
  },
  {
    path: '*',
    element: <Navigate to="/login" replace />,
  },
]);

