Spaces:
Sleeping
Sleeping
| import React, { useEffect } from 'react'; | |
| import { HashRouter, Routes, Route, Navigate } from 'react-router-dom'; | |
| import Layout from './components/Layout'; | |
| import Dashboard from './pages/Dashboard'; | |
| import JawaakBill from './pages/JawaakBill'; | |
| import AwaakBill from './pages/AwaakBill'; | |
| import StockReport from './pages/StockReport'; | |
| import PartyLedger from './pages/PartyLedger'; | |
| import Settings from './pages/Settings'; | |
| import Analysis from './pages/Analysis'; | |
| import PWAInstallPrompt from './components/PWAInstallPrompt'; | |
| import { PWAProvider } from './context/PWAContext'; | |
| const App = () => { | |
| // Register Service Worker for PWA | |
| useEffect(() => { | |
| if ('serviceWorker' in navigator) { | |
| window.addEventListener('load', () => { | |
| navigator.serviceWorker.register('/service-worker.js') | |
| .then(registration => { | |
| console.log('✅ PWA Service Worker registered:', registration); | |
| }) | |
| .catch(error => { | |
| console.log('❌ SW registration failed:', error); | |
| }); | |
| }); | |
| } | |
| }, []); | |
| return ( | |
| <PWAProvider> | |
| <HashRouter> | |
| <Layout> | |
| <Routes> | |
| <Route path="/" element={<Dashboard />} /> | |
| <Route path="/jawaak" element={<JawaakBill />} /> | |
| <Route path="/awaak" element={<AwaakBill />} /> | |
| <Route path="/stock" element={<StockReport />} /> | |
| <Route path="/ledger" element={<PartyLedger />} /> | |
| <Route path="/analysis" element={<Analysis />} /> | |
| <Route path="/settings" element={<Settings />} /> | |
| <Route path="*" element={<Navigate to="/" replace />} /> | |
| </Routes> | |
| </Layout> | |
| <PWAInstallPrompt /> | |
| </HashRouter> | |
| </PWAProvider> | |
| ); | |
| }; | |
| export default App; |