Save local admin console and unified auth changes before pulling remote UI updates

This commit is contained in:
Shanmuga Krishnan S M
2026-08-19 08:34:31 +05:30
parent 1eebd10f3a
commit bba33ef05b
6 changed files with 857 additions and 423 deletions

View File

@@ -15,13 +15,28 @@ export default function BusRoutes() {
const [isSidebarOpen, setIsSidebarOpen] = useState(false);
useEffect(() => {
// 0. Check local storage if edited by Transport Admin
const localAdminRoutes = localStorage.getItem('RIT_LOCAL_BUS_ROUTES');
if (localAdminRoutes) {
try {
const parsed = JSON.parse(localAdminRoutes);
if (Array.isArray(parsed) && parsed.length > 0) {
setBusRoutes(parsed);
setSelectedBusRoute(parsed[0]);
setLoadingBus(false);
}
} catch {}
}
// 1. Instantly load static bus routes (0ms loading delay)
fetch('/bus_routes.json')
.then((res) => res.json())
.then((data) => {
if (Array.isArray(data) && data.length > 0) {
setBusRoutes(data);
setSelectedBusRoute(data[0]);
if (!localStorage.getItem('RIT_LOCAL_BUS_ROUTES')) {
setBusRoutes(data);
setSelectedBusRoute(data[0]);
}
}
})
.catch((err) => console.error('Local JSON load error:', err))