import { BrowserRouter, Navigate, Route, Routes } from 'react-router-dom'
import { AuthProvider } from './auth/AuthProvider'
import { LoginPage } from './screens/LoginPage'
import { ConsoleLayout } from './screens/ConsoleLayout'
import { OrdersPage } from './screens/OrdersPage'
import { MyOrdersPage } from './screens/MyOrdersPage'
import { CallsPage } from './screens/CallsPage'
import { StoresPage } from './screens/StoresPage'
import { DailyLogsPage } from './screens/DailyLogsPage'
import { DailySalesReportPage } from './screens/DailySalesReportPage'
import { ReportPage } from './screens/ReportPage'

function App() {
  return (
    <AuthProvider>
      <BrowserRouter basename="/krishna_sales">
        <Routes>
          <Route path="/login" element={<LoginPage />} />
          <Route element={<ConsoleLayout />}>
            <Route path="orders" element={<OrdersPage />} />
            <Route path="orders/:instanceId" element={<OrdersPage />} />

            <Route path="my-orders" element={<MyOrdersPage />} />
            <Route path="my-orders/:instanceId" element={<MyOrdersPage />} />

            <Route path="calls" element={<CallsPage />} />
            <Route path="calls/:instanceId" element={<CallsPage />} />

            <Route path="stores" element={<StoresPage />} />
            <Route path="stores/:instanceId" element={<StoresPage />} />

            <Route path="daily" element={<DailyLogsPage />} />
            <Route path="daily/:instanceId" element={<DailyLogsPage />} />

            <Route path="reports/:reportType" element={<ReportPage />} />
            <Route path="sales-report" element={<DailySalesReportPage />} />
            <Route path="*" element={<Navigate to="/orders" replace />} />
          </Route>
        </Routes>
      </BrowserRouter>
    </AuthProvider>
  )
}

export default App
