Refactor: Streamline product management UI and enhance PWA behavior
**Product List Improvements:** - Move Import/Export to settings menu for cleaner interface - Replace Edit/Variants/Multi-Buys buttons with single Details action - Remove Blazor UI button from product list - Simplify product row actions for better mobile UX **Product Details Enhancements:** - Add Danger Zone section with Delete button at bottom - Improve visual hierarchy and action placement **Navigation Updates:** - Remove hamburger menu toggle (desktop nav always visible) - Rename Settings to Menu in mobile bottom nav - Update settings drawer header and icon **Code Cleanup:** - Remove unused Blazor, Variations, and Variants endpoints (243 lines) - Consolidate variant/multi-buy management within product details - Clean up ProductsController for better maintainability **PWA & Notifications:** - Add proper PWA support detection (only show if browser supports) - Implement session-based notification prompt tracking - Prevent repeated prompts after dismissal in same session - Respect permanent dismissal preferences - Enhance iOS Safari detection and instructions **Technical Details:** - 6 files changed, 96 insertions(+), 286 deletions(-) - Build successful with 0 errors - All features production-ready 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -42,11 +42,37 @@ class AdminNotificationManager {
|
||||
}
|
||||
|
||||
showAdminNotificationPrompt() {
|
||||
// Check if notifications are supported
|
||||
if (!('Notification' in window) || !('PushManager' in window)) {
|
||||
console.log('Admin Notifications: Push notifications not supported in this browser');
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if already enabled
|
||||
if (window.pwaManager && window.pwaManager.pushSubscription) {
|
||||
console.log('Admin Notifications: Already subscribed');
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if prompt already exists
|
||||
if (document.getElementById('admin-notification-prompt')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if dismissed in current session
|
||||
const sessionDismissed = sessionStorage.getItem('notificationPromptDismissed');
|
||||
if (sessionDismissed === 'true') {
|
||||
console.log('Admin Notifications: Prompt dismissed this session');
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if permanently dismissed
|
||||
const permanentlyDismissed = localStorage.getItem('pushNotificationDeclined');
|
||||
if (permanentlyDismissed === 'true') {
|
||||
console.log('Admin Notifications: Notifications declined permanently');
|
||||
return;
|
||||
}
|
||||
|
||||
const promptDiv = document.createElement('div');
|
||||
promptDiv.id = 'admin-notification-prompt';
|
||||
promptDiv.className = 'alert alert-warning alert-dismissible position-fixed';
|
||||
@@ -74,7 +100,7 @@ class AdminNotificationManager {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" id="close-notification-prompt"></button>
|
||||
`;
|
||||
|
||||
document.body.appendChild(promptDiv);
|
||||
@@ -84,6 +110,7 @@ class AdminNotificationManager {
|
||||
try {
|
||||
await this.enableNotifications();
|
||||
promptDiv.remove();
|
||||
sessionStorage.setItem('notificationPromptDismissed', 'true');
|
||||
} catch (error) {
|
||||
console.error('Failed to enable notifications:', error);
|
||||
this.showNotificationError('Failed to enable notifications. Please try again.');
|
||||
@@ -92,8 +119,14 @@ class AdminNotificationManager {
|
||||
|
||||
document.getElementById('remind-later').addEventListener('click', () => {
|
||||
promptDiv.remove();
|
||||
// Set reminder for 1 hour
|
||||
setTimeout(() => this.showAdminNotificationPrompt(), 60 * 60 * 1000);
|
||||
// Mark as dismissed for this session only
|
||||
sessionStorage.setItem('notificationPromptDismissed', 'true');
|
||||
});
|
||||
|
||||
document.getElementById('close-notification-prompt').addEventListener('click', () => {
|
||||
promptDiv.remove();
|
||||
// Mark as dismissed for this session only
|
||||
sessionStorage.setItem('notificationPromptDismissed', 'true');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -220,10 +220,20 @@ class PWAManager {
|
||||
}
|
||||
|
||||
showManualInstallButton() {
|
||||
// Don't show if PWA is not supported or already installed
|
||||
if (this.isInstalled() || document.getElementById('pwa-install-btn')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Only show if browser supports PWA (has beforeinstallprompt event or is iOS)
|
||||
const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
|
||||
const supportsPWA = 'serviceWorker' in navigator && ('BeforeInstallPromptEvent' in window || isIOS);
|
||||
|
||||
if (!supportsPWA) {
|
||||
console.log('PWA: Browser does not support PWA installation');
|
||||
return;
|
||||
}
|
||||
|
||||
const installBtn = document.createElement('button');
|
||||
installBtn.id = 'pwa-install-btn';
|
||||
installBtn.className = 'btn btn-primary btn-sm';
|
||||
@@ -269,12 +279,17 @@ class PWAManager {
|
||||
const isChrome = navigator.userAgent.includes('Chrome');
|
||||
const isEdge = navigator.userAgent.includes('Edge');
|
||||
const isFirefox = navigator.userAgent.includes('Firefox');
|
||||
const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
|
||||
|
||||
let instructions = 'To install this app:\n\n';
|
||||
|
||||
if (isChrome || isEdge) {
|
||||
if (isIOS) {
|
||||
instructions += '1. Tap the Share button (□↑) in Safari\n';
|
||||
instructions += '2. Scroll down and tap "Add to Home Screen"\n';
|
||||
instructions += '3. Tap "Add" to install';
|
||||
} else if (isChrome || isEdge) {
|
||||
instructions += '1. Look for the install icon (⬇️) in the address bar\n';
|
||||
instructions += '2. Or click the browser menu (⋮) → "Install LittleShop Admin"\n';
|
||||
instructions += '2. Or click the browser menu (⋮) → "Install TeleShop Admin"\n';
|
||||
instructions += '3. Or check if there\'s an "Install app" option in the browser menu';
|
||||
} else if (isFirefox) {
|
||||
instructions += '1. Firefox doesn\'t support PWA installation yet\n';
|
||||
|
||||
Reference in New Issue
Block a user