Product-enhancements-and-validation-fixes

This commit is contained in:
sysadmin
2025-09-01 08:03:00 +01:00
parent c8a55c143b
commit ee4a5c3578
12 changed files with 340 additions and 211 deletions

View File

@@ -1,12 +1,9 @@
// LittleShop Admin - Service Worker
// Provides offline functionality and app-like experience
const CACHE_NAME = 'littleshop-admin-v1';
const CACHE_NAME = 'littleshop-admin-v2';
const urlsToCache = [
'/Admin/Dashboard',
'/Admin/Orders',
'/Admin/Products',
'/Admin/Categories',
// Only cache static assets, not dynamic admin pages
'/lib/bootstrap/css/bootstrap.min.css',
'/lib/fontawesome/css/all.min.css',
'/lib/bootstrap-icons/bootstrap-icons.css',
@@ -14,6 +11,7 @@ const urlsToCache = [
'/lib/jquery/jquery.min.js',
'/lib/bootstrap/js/bootstrap.bundle.min.js',
'/js/modern-mobile.js',
'/js/pwa.js',
'/lib/fontawesome/webfonts/fa-solid-900.woff2',
'/lib/fontawesome/webfonts/fa-brands-400.woff2'
];
@@ -121,13 +119,27 @@ self.addEventListener('notificationclick', (event) => {
);
});
// Fetch event - serve from cache, fallback to network
// Fetch event - network-first for admin pages, cache-first for assets
self.addEventListener('fetch', (event) => {
// Only handle GET requests
if (event.request.method !== 'GET') {
return;
}
const url = new URL(event.request.url);
// Network-first strategy for admin pages (always fresh data)
if (url.pathname.startsWith('/Admin/')) {
event.respondWith(
fetch(event.request).catch(() => {
// If network fails, try cache as fallback
return caches.match(event.request);
})
);
return;
}
// Cache-first strategy for static assets
event.respondWith(
caches.match(event.request)
.then((response) => {