import { createBrowserRouter, Navigate } from 'react-router-dom';
import { Layout } from './components';
import { 
  Home, 
  Login, 
  MedicineList, 
  MedicineDetail, 
  AddMedicine, 
  QuickDispense, 
  Search, 
  Notifications, 
  Settings 
} from './pages';

const router = createBrowserRouter([
  {
    path: '/login',
    element: <Login />
  },
  {
    path: '/',
    element: <Layout><Home /></Layout>
  },
  {
    path: '/medicines',
    element: <Layout title="药品列表" showBack><MedicineList /></Layout>
  },
  {
    path: '/medicines/add',
    element: <Layout title="添加药品" showBack><AddMedicine /></Layout>
  },
  {
    path: '/medicines/:id',
    element: <Layout title="药品详情" showBack><MedicineDetail /></Layout>
  },
  {
    path: '/medicines/edit/:id',
    element: <Layout title="编辑药品" showBack><AddMedicine /></Layout>
  },
  {
    path: '/quick-dispense',
    element: <Layout title="快速取药"><QuickDispense /></Layout>
  },
  {
    path: '/search',
    element: <Layout title="搜索" showBack><Search /></Layout>
  },
  {
    path: '/notifications',
    element: <Layout title="通知中心"><Notifications /></Layout>
  },
  {
    path: '/settings',
    element: <Layout title="设置"><Settings /></Layout>
  },
  {
    path: '*',
    element: <Navigate to="/" replace />
  }
]);

export default router;