import { Toaster } from "@/components/ui/toaster";
import { Toaster as Sonner } from "@/components/ui/sonner";
import { TooltipProvider } from "@/components/ui/tooltip";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { BrowserRouter, Routes, Route } from "react-router-dom";
import { BottomNavigation } from "@/components/BottomNavigation";
import { LanguageProvider } from "@/contexts/LanguageContext";
import Dashboard from "./pages/Dashboard";
import Invoice from "./pages/Invoice";
import InvoiceEnhanced from "./pages/InvoiceEnhanced";
import PurchaseEntry from "./pages/PurchaseEntry";
import PurchaseEntryEnhanced from "./pages/PurchaseEntryEnhanced";
import StockManagement from "./pages/StockManagement";
import PartyLedger from "./pages/PartyLedger";
import PartyLedgerEnhanced from "./pages/PartyLedgerEnhanced";
import BillBook from "./pages/BillBook";
import BillBookEnhanced from "./pages/BillBookEnhanced";

const NotFound = () => <div>404 - Page Not Found</div>;

const queryClient = new QueryClient();

const App = () => (
  <QueryClientProvider client={queryClient}>
    <LanguageProvider>
      <TooltipProvider>
        <Toaster />
        <Sonner />
        <BrowserRouter>
          <div className="pb-16 md:pb-0">
            <Routes>
              <Route path="/" element={<Dashboard />} />
              <Route path="/invoice" element={<InvoiceEnhanced />} />
              <Route path="/invoice-old" element={<Invoice />} />
              <Route path="/purchase" element={<PurchaseEntryEnhanced />} />
              <Route path="/purchase-old" element={<PurchaseEntry />} />
              <Route path="/stock" element={<StockManagement />} />
              <Route path="/ledger" element={<PartyLedgerEnhanced />} />
              <Route path="/ledger-old" element={<PartyLedger />} />
              <Route path="/bill-book" element={<BillBookEnhanced />} />
              <Route path="/bill-book-old" element={<BillBook />} />
              {/* ADD ALL CUSTOM ROUTES ABOVE THE CATCH-ALL "*" ROUTE */}
              <Route path="*" element={<NotFound />} />
            </Routes>
          </div>
          <BottomNavigation />
        </BrowserRouter>
      </TooltipProvider>
    </LanguageProvider>
  </QueryClientProvider>
);

export default App;