import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import Layout from './components/Layout'
import Login from './pages/Login'
import Dashboard from './pages/Dashboard'
import StoreList from './pages/StoreList'
import TemplateList from './pages/TemplateList'
import PosCvtList from './pages/PosCvtList'
import AlarmList from './pages/AlarmList'
import HCoreStatus from './pages/HCoreStatus'
import WorkHistory from './pages/WorkHistory'
import FirmwareList from './pages/FirmwareList'
import UserList from './pages/UserList'
import ProductList from './pages/ProductList'
import TenantAdmin from './pages/TenantAdmin'
import AiAnalysis from './pages/AiAnalysis'
import TagBindingList from './pages/TagBindingList'
import UpdateQueueList from './pages/UpdateQueueList'

const qc = new QueryClient()

export default function App() {
  return (
    <QueryClientProvider client={qc}>
      <BrowserRouter>
        <Routes>
          <Route path="/login" element={<Login />} />
          <Route element={<Layout />}>
            <Route path="/dashboard"    element={<Dashboard />} />
            <Route path="/stores"       element={<StoreList />} />
            <Route path="/templates"    element={<TemplateList />} />
            <Route path="/pos-cvt"      element={<PosCvtList />} />
            <Route path="/tag-binding"  element={<TagBindingList />} />
            <Route path="/update-queue" element={<UpdateQueueList />} />
            <Route path="/alarms"       element={<AlarmList />} />
            <Route path="/hcore"        element={<HCoreStatus />} />
            <Route path="/works"        element={<WorkHistory />} />
            <Route path="/firmware"     element={<FirmwareList />} />
            <Route path="/products"     element={<ProductList />} />
            <Route path="/users"        element={<UserList />} />
            <Route path="/tenants"      element={<TenantAdmin />} />
            <Route path="/ai"           element={<AiAnalysis />} />
          </Route>
          <Route path="*" element={<Navigate to="/dashboard" replace />} />
        </Routes>
      </BrowserRouter>
    </QueryClientProvider>
  )
}
