import { createBrowserRouter, Navigate } from 'react-router-dom';
import LoginPage from '../pages/login/LoginPage';
import UsersListPage from '../pages/users/UsersListPage';
import UserFormPage from '../pages/users/UserFormPage';
import RequireSuperAdmin from './RequireSuperAdmin';

export const router = createBrowserRouter([
  { path: '/login', element: <LoginPage /> },
  {
    path: '/users',
    element: (
      <RequireSuperAdmin>
        <UsersListPage />
      </RequireSuperAdmin>
    ),
  },
  {
    path: '/users/new',
    element: (
      <RequireSuperAdmin>
        <UserFormPage mode="create" />
      </RequireSuperAdmin>
    ),
  },
  {
    path: '/users/:userId',
    element: (
      <RequireSuperAdmin>
        <UserFormPage mode="edit" />
      </RequireSuperAdmin>
    ),
  },
  { path: '*', element: <Navigate to="/users" replace /> },
]);
