Spaces:
Running
Running
Initial DeepSite commit
Browse filesFiles changed (7)
- README.md+9-6
- auth.jsAdded+615
- icons/README.mdAdded+19
- index.html+621-19
- manifest.jsonAdded+58
- script.jsAdded+608
- service-worker.jsAdded+140
12345678910---title: Deepsite Project 41q2aemoji: 👀colorFrom: bluecolorTo: indigosdk: staticpinned: false---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference12345678910111213---title: DeepSite ProjectcolorFrom: redcolorTo: pinksdk: staticemoji: 🎉tags:- deepsite-v4---# DeepSite ProjectThis project has been created with [DeepSite](https://deepsite.hf.co) AI Vibe Coding.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615// Authentication and Multi-Language System for Supplier QC Tracker
document.addEventListener('DOMContentLoaded', function() { // Initialize Lucide icons if (typeof lucide !== 'undefined') { lucide.createIcons(); } // DOM Elements const loginPage = document.getElementById('login-page'); const dashboard = document.getElementById('dashboard'); const loginForm = document.getElementById('login-form'); const logoutBtn = document.getElementById('logout-btn'); const languageToggle = document.getElementById('language-toggle'); const languageToggleNav = document.getElementById('language-toggle-nav'); const languageText = document.getElementById('language-text'); const adminPanelLink = document.getElementById('admin-panel-link'); const adminPanelModal = document.getElementById('admin-panel-modal'); const closeAdminPanel = document.getElementById('close-admin-panel'); const userAvatar = document.getElementById('user-avatar'); const userName = document.getElementById('user-name'); const userRoleBadge = document.getElementById('user-role-badge'); const newOrderBtn = document.getElementById('new-order-btn'); // Current user and language state let currentUser = null; let currentLanguage = localStorage.getItem('qc-language') || 'en'; // Demo user database (in real app, this would be on a server) const users = { 'admin': { password: 'admin123', role: 'admin', name: 'Administrator', email: 'admin@company.com', avatarText: 'AD' }, 'staff': { password: 'staff123', role: 'staff', name: 'Your Staff Member', email: 'staff@company.com', avatarText: 'ST' }, 'china': { password: 'china123', role: 'china_staff', name: 'China Staff Li', email: 'li@china.company.cn', avatarText: '李' } }; // Language translations const translations = { 'en': { // Login page 'Supplier QC Tracker': 'Supplier QC Tracker', 'Secure Login for Supply Chain Management': 'Secure Login for Supply Chain Management', 'Username / Email': 'Username / Email', 'Password': 'Password', 'Login As': 'Login As', 'Select your role': 'Select your role', 'Admin (You)': 'Admin (You)', 'Your Staff': 'Your Staff', 'China Staff': 'China Staff', 'Remember me': 'Remember me', 'Sign In': 'Sign In', '切换到中文 (Switch to Chinese)': '切换到中文 (Switch to Chinese)', 'Demo Login Credentials': 'Demo Login Credentials', // Dashboard 'Dashboard': 'Dashboard', 'Orders': 'Orders', 'Suppliers': 'Suppliers', 'Analytics': 'Analytics', 'Admin Panel': 'Admin Panel', 'New Order': 'New Order', 'Logout': 'Logout', 'EN': 'EN', // Admin panel 'Administration Panel': 'Administration Panel', 'User Management': 'User Management', 'Admin Users': 'Admin Users', 'Staff Users': 'Staff Users', 'China Staff Users': 'China Staff Users', 'Manage Users': 'Manage Users', 'System Settings': 'System Settings', 'QC Required for Custom Items': 'QC Required for Custom Items', 'Email Notifications': 'Email Notifications', 'Mandatory Photos for All Orders': 'Mandatory Photos for All Orders', 'Save Settings': 'Save Settings', 'Discrepancy Reports': 'Discrepancy Reports', 'Order ID': 'Order ID', 'Issue': 'Issue', 'Responsible': 'Responsible', 'Status': 'Status', 'Wrong dimensions': 'Wrong dimensions', 'Open': 'Open', 'Close': 'Close', // Footer 'Supplier QC Tracker v2.0 • Multi-Language System': 'Supplier QC Tracker v2.0 • Multi-Language System', 'Web-based accessible on all devices': 'Web-based accessible on all devices' }, 'zh': { // Login page 'Supplier QC Tracker': '供应商质量跟踪系统', 'Secure Login for Supply Chain Management': '供应链管理安全登录', 'Username / Email': '用户名 / 邮箱', 'Password': '密码', 'Login As': '登录身份', 'Select your role': '选择您的身份', 'Admin (You)': '管理员 (您)', 'Your Staff': '您的员工', 'China Staff': '中国员工', 'Remember me': '记住登录', 'Sign In': '登录', '切换到中文 (Switch to Chinese)': 'Switch to English', 'Demo Login Credentials': '演示登录凭据', // Dashboard 'Dashboard': '仪表板', 'Orders': '订单', 'Suppliers': '供应商', 'Analytics': '分析', 'Admin Panel': '管理面板', 'New Order': '新订单', 'Logout': '登出', 'EN': '中文', // Admin panel 'Administration Panel': '管理面板', 'User Management': '用户管理', 'Admin Users': '管理员用户', 'Staff Users': '员工用户', 'China Staff Users': '中国员工用户', 'Manage Users': '管理用户', 'System Settings': '系统设置', 'QC Required for Custom Items': '定制产品必须QC审核', 'Email Notifications': '电子邮件通知', 'Mandatory Photos for All Orders': '所有订单必须拍照', 'Save Settings': '保存设置', 'Discrepancy Reports': '差异报告', 'Order ID': '订单号', 'Issue': '问题', 'Responsible': '责任人', 'Status': '状态', 'Wrong dimensions': '尺寸错误', 'Open': '未解决', 'Close': '关闭', // Footer 'Supplier QC Tracker v2.0 • Multi-Language System': '供应商质量跟踪 v2.0 • 多语言系统', 'Web-based accessible on all devices': '基于网页,所有设备均可访问' } }; // Role-based permissions const rolePermissions = { 'admin': { canCreateOrder: true, canEditOrder: true, canApproveShipment: true, canViewAllOrders: true, canAccessAdminPanel: true, canManageUsers: true }, 'staff': { canCreateOrder: true, canEditOrder: true, canApproveShipment: false, canViewAllOrders: true, canAccessAdminPanel: false, canManageUsers: false }, 'china_staff': { canCreateOrder: true, canEditOrder: true, canApproveShipment: true, canViewAllOrders: false, canAccessAdminPanel: false, canManageUsers: false } }; // Check if user is already logged in function checkExistingLogin() { const savedUser = localStorage.getItem('qc-user'); const savedLanguage = localStorage.getItem('qc-language'); if (savedUser && savedLanguage) { try { currentUser = JSON.parse(savedUser); currentLanguage = savedLanguage; if (currentUser && users[currentUser.username]) { showDashboard(); updateUIForUser(); applyLanguage(currentLanguage); return true; } } catch (e) { console.error('Error parsing saved user:', e); } } return false; } // Show login page function showLoginPage() { loginPage.classList.remove('hidden'); dashboard.classList.add('hidden'); } // Show dashboard function showDashboard() { loginPage.classList.add('hidden'); dashboard.classList.remove('hidden'); } // Update UI based on user role function updateUIForUser() { if (!currentUser) return; const userData = users[currentUser.username]; // Update user info display userAvatar.textContent = userData.avatarText; userName.textContent = userData.name; // Update role badge let roleText = ''; let roleColor = ''; switch(currentUser.role) { case 'admin': roleText = 'Administrator'; roleColor = 'text-red-600'; break; case 'staff': roleText = 'Your Staff'; roleColor = 'text-blue-600'; break; case 'china_staff': roleText = 'China Staff'; roleColor = 'text-green-600'; break; } userRoleBadge.textContent = roleText; userRoleBadge.className = `text-xs ${roleColor} hidden md:block`; // Show/hide admin panel link if (currentUser.role === 'admin') { adminPanelLink.classList.remove('hidden'); } else { adminPanelLink.classList.add('hidden'); } // Apply permissions to new order button if (!rolePermissions[currentUser.role].canCreateOrder) { newOrderBtn.disabled = true; newOrderBtn.classList.add('opacity-50', 'cursor-not-allowed'); } else { newOrderBtn.disabled = false; newOrderBtn.classList.remove('opacity-50', 'cursor-not-allowed'); } } // Apply language to the page function applyLanguage(lang) { currentLanguage = lang; document.documentElement.setAttribute('data-lang', lang); document.documentElement.lang = lang; // Update language text languageText.textContent = lang === 'en' ? 'EN' : '中文'; // Update all elements with data attributes document.querySelectorAll('[data-en]').forEach(element => { const key = element.getAttribute('data-en'); if (translations[lang] && translations[lang][key]) { if (element.tagName === 'INPUT' && element.type !== 'submit') { element.placeholder = translations[lang][key]; } else if (element.tagName === 'TITLE') { document.title = translations[lang][key]; } else { element.textContent = translations[lang][key]; } } }); // Save language preference localStorage.setItem('qc-language', lang); } // Toggle language function toggleLanguage() { const newLang = currentLanguage === 'en' ? 'zh' : 'en'; applyLanguage(newLang); } // Handle login function handleLogin(event) { event.preventDefault(); const username = document.getElementById('username').value.trim().toLowerCase(); const password = document.getElementById('password').value; const role = document.getElementById('user-role').value; // Validate inputs if (!username || !password || !role) { alert(currentLanguage === 'zh' ? '请填写所有字段' : 'Please fill in all fields'); return; } // Check if user exists and credentials match if (users[username] && users[username].password === password && users[username].role === role) { // Create user object currentUser = { username: username, role: role, loginTime: new Date().toISOString() }; // Save to localStorage localStorage.setItem('qc-user', JSON.stringify(currentUser)); // Show dashboard showDashboard(); updateUIForUser(); // Show welcome message const welcomeMsg = currentLanguage === 'zh' ? `欢迎回来,${users[username].name}!` : `Welcome back, ${users[username].name}!`; // Show role-specific message let roleMsg = ''; if (role === 'admin') { roleMsg = currentLanguage === 'zh' ? '您拥有完全的管理权限。' : 'You have full administrative privileges.'; } else if (role === 'china_staff') { roleMsg = currentLanguage === 'zh' ? '请记得为定制产品上传QC照片。' : 'Remember to upload QC photos for custom fabrication items.'; } alert(`${welcomeMsg}\n\n${roleMsg}`); } else { // Invalid credentials const errorMsg = currentLanguage === 'zh' ? '用户名、密码或角色不正确。请使用演示凭据。' : 'Invalid username, password, or role. Please use demo credentials.'; alert(errorMsg); } } // Handle logout function handleLogout() { const confirmMsg = currentLanguage === 'zh' ? '确定要退出登录吗?' : 'Are you sure you want to logout?'; if (confirm(confirmMsg)) { currentUser = null; localStorage.removeItem('qc-user'); showLoginPage(); loginForm.reset(); } } // Initialize the page function init() { // Check for existing login if (!checkExistingLogin()) { showLoginPage(); applyLanguage(currentLanguage); } // Event listeners loginForm.addEventListener('submit', handleLogin); if (logoutBtn) { logoutBtn.addEventListener('click', handleLogout); } if (languageToggle) { languageToggle.addEventListener('click', toggleLanguage); } if (languageToggleNav) { languageToggleNav.addEventListener('click', toggleLanguage); } if (adminPanelLink) { adminPanelLink.addEventListener('click', function(e) { e.preventDefault(); adminPanelModal.classList.remove('hidden'); }); } if (closeAdminPanel) { closeAdminPanel.addEventListener('click', function() { adminPanelModal.classList.add('hidden'); }); } // Close admin panel when clicking outside if (adminPanelModal) { adminPanelModal.addEventListener('click', function(e) { if (e.target === this) { adminPanelModal.classList.add('hidden'); } }); } // Add keyboard shortcuts document.addEventListener('keydown', function(e) { // Ctrl/Cmd + L toggles language if ((e.ctrlKey || e.metaKey) && e.key === 'l') { e.preventDefault(); toggleLanguage(); } // Escape key closes modals if (e.key === 'Escape') { if (!adminPanelModal.classList.contains('hidden')) { adminPanelModal.classList.add('hidden'); } } }); } // Initialize the application init(); // Register Service Worker for PWA registerServiceWorker();});
// PWA Service Worker Registrationfunction registerServiceWorker() { if ('serviceWorker' in navigator) { window.addEventListener('load', () => { navigator.serviceWorker.register('/service-worker.js') .then(registration => { console.log('Service Worker registered:', registration); // Check for app updates registration.addEventListener('updatefound', () => { const newWorker = registration.installing; console.log('New service worker found:', newWorker); }); // Show install prompt for PWA showInstallPrompt(); }) .catch(error => { console.error('Service Worker registration failed:', error); }); }); }}
// Show PWA install promptfunction showInstallPrompt() { let deferredPrompt; const installBanner = document.getElementById('pwa-install-banner'); const installMainButton = document.getElementById('install-pwa-main-btn'); window.addEventListener('beforeinstallprompt', (e) => { // Prevent Chrome from automatically showing the prompt e.preventDefault(); deferredPrompt = e; // Show install banner if (installBanner) { installBanner.classList.remove('hidden'); // Add event listener to install button installMainButton.addEventListener('click', () => { installBanner.classList.add('hidden'); deferredPrompt.prompt(); deferredPrompt.userChoice.then((choiceResult) => { if (choiceResult.outcome === 'accepted') { console.log('User accepted the install prompt'); showInstallSuccess(); } else { console.log('User dismissed the install prompt'); } deferredPrompt = null; }); }); // Close banner button document.getElementById('close-install-banner').addEventListener('click', () => { installBanner.classList.add('hidden'); // Save preference to not show again for 7 days localStorage.setItem('hide-install-banner', Date.now()); }); // Check if user previously hid the banner const hideTime = localStorage.getItem('hide-install-banner'); if (hideTime) { const sevenDays = 7 * 24 * 60 * 60 * 1000; if (Date.now() - parseInt(hideTime) < sevenDays) { installBanner.classList.add('hidden'); } } } }); window.addEventListener('beforeinstallprompt', (e) => { // Prevent Chrome 67 and earlier from automatically showing the prompt e.preventDefault(); deferredPrompt = e; // Show install button const installContainer = document.getElementById('pwa-install-container'); if (installContainer) { installContainer.classList.remove('hidden'); // Add event listener to install button document.getElementById('install-pwa-btn').addEventListener('click', () => { installContainer.classList.add('hidden'); deferredPrompt.prompt(); deferredPrompt.userChoice.then((choiceResult) => { if (choiceResult.outcome === 'accepted') { console.log('User accepted the install prompt'); } else { console.log('User dismissed the install prompt'); } deferredPrompt = null; }); }); // Close button document.getElementById('close-install-btn').addEventListener('click', () => { installContainer.classList.add('hidden'); }); } }); // Detect if app is already installed window.addEventListener('appinstalled', () => { console.log('PWA installed successfully'); const installContainer = document.getElementById('pwa-install-container'); if (installContainer) { installContainer.classList.add('hidden'); } });}
// Show success message after installationfunction showInstallSuccess() { const successDiv = document.createElement('div'); successDiv.id = 'install-success'; successDiv.className = 'fixed bottom-4 right-4 z-50 bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded-lg shadow-lg'; successDiv.innerHTML = ` <div class="flex items-center"> <i data-lucide="check-circle" class="h-5 w-5 text-green-600 mr-2"></i> <div> <p class="font-medium" data-en="App installed successfully!" data-zh="应用安装成功!">App installed successfully!</p> <p class="text-sm" data-en="Access from your home screen anytime" data-zh="可从主屏幕随时访问">Access from your home screen anytime</p> </div> <button id="close-success" class="ml-4 text-green-700 hover:text-green-900"> <i data-lucide="x" class="h-4 w-4"></i> </button> </div> `; document.getElementById('dashboard').appendChild(successDiv); // Reinitialize icons if (typeof lucide !== 'undefined') { lucide.createIcons(); } // Auto-hide after 5 seconds setTimeout(() => { const success = document.getElementById('install-success'); if (success) success.remove(); }, 5000); // Close button document.getElementById('close-success').addEventListener('click', () => { const success = document.getElementById('install-success'); if (success) success.remove(); });}
// Check if app is running in standalone mode (installed)function isRunningAsPWA() { return window.matchMedia('(display-mode: standalone)').matches || window.navigator.standalone === true || document.referrer.includes('android-app://');}
// Initialize PWA features if running as installed appif (isRunningAsPWA()) { console.log('Running as installed PWA'); // Hide install banner if already installed const installBanner = document.getElementById('pwa-install-banner'); if (installBanner) { installBanner.classList.add('hidden'); }}12345678910111213141516171819# App Icons for PWA
To generate icons for your PWA:
1. Create a 512x512 PNG logo for your app (blue color, simple design)2. Use an online tool to generate all sizes: https://realfavicongenerator.net/3. Place the generated PNG files in this folder: - icon-72x72.png - icon-96x96.png - icon-128x128.png - icon-144x144.png - icon-152x152.png - icon-192x192.png - icon-384x384.png - icon-512x512.png
For now, you can use these placeholder URLs in manifest.json:- https://static.photos/technology/192x192/1- https://static.photos/technology/512x512/112345678910111213141516171819<!doctype html><html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width" /><title>My static Space</title><link rel="stylesheet" href="style.css" /></head><body><div class="card"><h1>Welcome to your static Space!</h1><p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p><p>Also don't forget to check the<a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.</p></div></body></html>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621<!DOCTYPE html><html lang="en" data-lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="theme-color" content="#3b82f6"><meta name="description" content="Supply chain quality control system with multi-language support and mobile app capabilities"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"><meta name="apple-mobile-web-app-title" content="QC Tracker"><link rel="manifest" href="manifest.json"><link rel="icon" href="icons/icon-192x192.png" type="image/png"><link rel="apple-touch-icon" href="icons/icon-192x192.png"><title data-en="Supplier QC Tracker | Order Management System" data-zh="供应商质量跟踪 | 订单管理系统">Supplier QC Tracker | Order Management System</title><script src="https://cdn.tailwindcss.com"></script><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"><script src="https://unpkg.com/lucide@latest"></script><style>/* Custom styles for better UX */.status-pending { background-color: #fef3c7; color: #92400e; }.status-in-progress { background-color: #dbeafe; color: #1e40af; }.status-qc-required { background-color: #fef3c7; color: #92400e; }.status-approved { background-color: #d1fae5; color: #065f46; }.status-shipped { background-color: #e0e7ff; color: #3730a3; }.status-received { background-color: #dcfce7; color: #166534; }.status-discrepancy { background-color: #fee2e2; color: #991b1b; }.step-completed { background-color: #10b981; color: white; }.step-current { background-color: #3b82f6; color: white; }.step-pending { background-color: #e5e7eb; color: #6b7280; }.order-card:hover { transform: translateY(-2px); box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1); }.file-upload-area { border: 2px dashed #d1d5db; transition: all 0.3s ease; }.file-upload-area:hover, .file-upload-area.dragover { border-color: #3b82f6; background-color: #eff6ff; }/* Smooth transitions */* { transition: background-color 0.2s ease, border-color 0.2s ease; }</style></head><body class="bg-gray-50 min-h-screen" id="main-content"><!-- Login Page (Will be shown first) --><div id="login-page" class="min-h-screen flex items-center justify-center bg-gradient-to-br from-blue-50 to-gray-100 px-4"><div class="max-w-md w-full bg-white rounded-lg shadow-xl overflow-hidden"><div class="px-8 py-12"><div class="text-center mb-8"><div class="flex justify-center mb-4"><i data-lucide="package" class="h-12 w-12 text-blue-600"></i></div><h2 class="text-3xl font-bold text-gray-800 mb-2" data-en="Supplier QC Tracker" data-zh="供应商质量跟踪系统">Supplier QC Tracker</h2><p class="text-gray-600" data-en="Secure Login for Supply Chain Management" data-zh="供应链管理安全登录">Secure Login for Supply Chain Management</p></div><form id="login-form" class="space-y-6"><div><label for="username" class="block text-sm font-medium text-gray-700 mb-1" data-en="Username / Email" data-zh="用户名 / 邮箱">Username / Email</label><input type="text" id="username" required class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition"></div><div><label for="password" class="block text-sm font-medium text-gray-700 mb-1" data-en="Password" data-zh="密码">Password</label><input type="password" id="password" required class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition"></div><div><label for="user-role" class="block text-sm font-medium text-gray-700 mb-1" data-en="Login As" data-zh="登录身份">Login As</label><select id="user-role" required class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition"><option value="" data-en="Select your role" data-zh="选择您的身份">Select your role</option><option value="admin" data-en="Admin (You)" data-zh="管理员 (您)">Admin (You)</option><option value="staff" data-en="Your Staff" data-zh="您的员工">Your Staff</option><option value="china_staff" data-en="China Staff" data-zh="中国员工">China Staff</option></select></div><div class="flex items-center"><input type="checkbox" id="remember-me" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"><label for="remember-me" class="ml-2 block text-sm text-gray-700" data-en="Remember me" data-zh="记住登录">Remember me</label></div><button type="submit" class="w-full bg-blue-600 hover:bg-blue-700 text-white font-medium py-3 px-4 rounded-lg transition duration-300" data-en="Sign In" data-zh="登录">Sign In</button><div class="text-center mt-6"><button type="button" id="language-toggle" class="text-sm text-blue-600 hover:text-blue-800 font-medium" data-en="切换到中文 (Switch to Chinese)" data-zh="Switch to English">切换到中文 (Switch to Chinese)</button></div></form><div class="mt-8 pt-6 border-t border-gray-200"><div class="text-center text-sm text-gray-500"><h4 class="font-medium mb-2" data-en="Demo Login Credentials" data-zh="演示登录凭据">Demo Login Credentials</h4><div class="grid grid-cols-1 gap-2 text-left"><div><span class="font-medium">Admin:</span> admin / admin123</div><div><span class="font-medium">Your Staff:</span> staff / staff123</div><div><span class="font-medium">China Staff:</span> china / china123</div></div></div></div><div class="mt-6 pt-4 border-t border-gray-200"><div class="text-center text-sm text-gray-500"><p class="mb-2" data-en="📱 Install as Mobile App:" data-zh="📱 安装为手机应用:">📱 Install as Mobile App:</p><p class="text-xs text-gray-600" data-en="100% FREE to install • No app store fees" data-zh="100%免费安装 • 无需应用商店费用">100% FREE to install • No app store fees</p><div class="mt-2 flex justify-center space-x-2"><div class="text-xs px-2 py-1 bg-green-100 text-green-800 rounded font-bold" data-en="iOS: FREE • Add to Home Screen" data-zh="iOS: 免费 • 添加到主屏幕">iOS: FREE • Add to Home</div><div class="text-xs px-2 py-1 bg-green-100 text-green-800 rounded font-bold" data-en="Android: FREE • Install App" data-zh="Android: 免费 • 安装应用">Android: FREE • Install</div></div><div class="mt-2"><div class="text-xs px-2 py-1 bg-blue-100 text-blue-800 rounded" data-en="Works offline in factories" data-zh="工厂离线可用">Works offline in factories</div></div></div></div></div></div></div><!-- Main Dashboard (Hidden until login) --><div id="dashboard" class="hidden"><!-- Navigation --><nav class="bg-white shadow-sm border-b"><div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"><div class="flex justify-between h-16"><div class="flex items-center"><div class="flex-shrink-0 flex items-center"><i data-lucide="package" class="h-8 w-8 text-blue-600 mr-2"></i><span class="font-bold text-xl text-gray-800" data-en="Supplier QC Tracker" data-zh="供应商质量跟踪">Supplier QC Tracker</span></div><div class="hidden md:ml-8 md:flex md:space-x-8"><a href="#" class="border-blue-500 text-gray-900 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium" data-en="Dashboard" data-zh="仪表板">Dashboard</a><a href="#" class="border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium" data-en="Orders" data-zh="订单">Orders</a><a href="#" class="border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium" data-en="Suppliers" data-zh="供应商">Suppliers</a><a href="#" class="border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium" data-en="Analytics" data-zh="分析">Analytics</a><a href="#" id="admin-panel-link" class="border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium hidden" data-en="Admin Panel" data-zh="管理面板">Admin Panel</a></div></div><div class="flex items-center"><div class="mr-4"><button id="language-toggle-nav" class="flex items-center text-sm text-gray-700 hover:text-blue-600"><i data-lucide="languages" class="h-4 w-4 mr-1"></i><span id="language-text" data-en="EN" data-zh="中文">EN</span></button></div><button id="new-order-btn" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-md text-sm font-medium flex items-center mr-4"><i data-lucide="plus-circle" class="h-4 w-4 mr-2"></i><span data-en="New Order" data-zh="新订单">New Order</span></button><div class="ml-4 flex items-center md:ml-6"><button class="bg-gray-100 p-1 rounded-full text-gray-400 hover:text-gray-500 focus:outline-none"><i data-lucide="bell" class="h-6 w-6"></i></button><div class="ml-3 relative"><div class="flex items-center"><div id="user-avatar" class="h-8 w-8 rounded-full bg-blue-100 flex items-center justify-center text-blue-600 font-medium text-sm"></div><div class="ml-2"><span id="user-name" class="text-sm font-medium text-gray-700 hidden md:block"></span><span id="user-role-badge" class="text-xs text-gray-500 hidden md:block"></span></div><button id="logout-btn" class="ml-4 text-sm text-gray-500 hover:text-gray-700" data-en="Logout" data-zh="登出">Logout</button></div></div></div></div></div></div></nav><!-- PWA Install Banner (Free) --><div id="pwa-install-banner" class="bg-gradient-to-r from-green-500 to-green-600 text-white py-2 px-4 text-center hidden"><div class="max-w-7xl mx-auto flex items-center justify-between"><div class="flex items-center"><i data-lucide="smartphone" class="h-5 w-5 mr-2"></i><span class="text-sm font-medium" data-en="Install FREE app for offline use" data-zh="免费安装应用,离线可用">Install FREE app for offline use</span></div><div><button id="install-pwa-main-btn" class="bg-white text-green-600 hover:bg-green-50 px-4 py-1 rounded-md text-sm font-medium"><span data-en="FREE Install" data-zh="免费安装">FREE Install</span></button><button id="close-install-banner" class="ml-2 text-white hover:text-green-100"><i data-lucide="x" class="h-4 w-4"></i></button></div></div></div><!-- Main Content --><div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8"><!-- Dashboard Header --><div class="md:flex md:items-center md:justify-between mb-8"><div class="flex-1 min-w-0"><h2 class="text-2xl font-bold leading-7 text-gray-900 sm:text-3xl sm:truncate">Order Management Dashboard</h2><p class="mt-2 text-sm text-gray-600">Track orders from creation to warehouse receipt with full accountability</p></div><div class="mt-4 flex md:mt-0 md:ml-4"><button type="button" class="inline-flex items-center px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none"><i data-lucide="filter" class="h-4 w-4 mr-2"></i> Filter</button><button type="button" class="ml-3 inline-flex items-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none"><i data-lucide="download" class="h-4 w-4 mr-2"></i> Export</button></div></div><!-- Stats Overview --><div class="grid grid-cols-1 gap-5 sm:grid-cols-2 lg:grid-cols-4 mb-8"><div class="bg-white overflow-hidden shadow rounded-lg"><div class="p-5"><div class="flex items-center"><div class="flex-shrink-0 bg-blue-100 rounded-md p-3"><i data-lucide="package" class="h-6 w-6 text-blue-600"></i></div><div class="ml-5 w-0 flex-1"><dl><dt class="text-sm font-medium text-gray-500 truncate">Total Orders</dt><dd class="text-lg font-medium text-gray-900">24</dd></dl></div></div></div></div><div class="bg-white overflow-hidden shadow rounded-lg"><div class="p-5"><div class="flex items-center"><div class="flex-shrink-0 bg-yellow-100 rounded-md p-3"><i data-lucide="alert-circle" class="h-6 w-6 text-yellow-600"></i></div><div class="ml-5 w-0 flex-1"><dl><dt class="text-sm font-medium text-gray-500 truncate">Pending QC</dt><dd class="text-lg font-medium text-gray-900">5</dd></dl></div></div></div></div><div class="bg-white overflow-hidden shadow rounded-lg"><div class="p-5"><div class="flex items-center"><div class="flex-shrink-0 bg-green-100 rounded-md p-3"><i data-lucide="check-circle" class="h-6 w-6 text-green-600"></i></div><div class="ml-5 w-0 flex-1"><dl><dt class="text-sm font-medium text-gray-500 truncate">Approved</dt><dd class="text-lg font-medium text-gray-900">14</dd></dl></div></div></div></div><div class="bg-white overflow-hidden shadow rounded-lg"><div class="p-5"><div class="flex items-center"><div class="flex-shrink-0 bg-red-100 rounded-md p-3"><i data-lucide="alert-triangle" class="h-6 w-6 text-red-600"></i></div><div class="ml-5 w-0 flex-1"><dl><dt class="text-sm font-medium text-gray-500 truncate">Discrepancies</dt><dd class="text-lg font-medium text-gray-900">3</dd></dl></div></div></div></div></div><!-- Workflow Steps --><div class="mb-8"><h3 class="text-lg font-medium text-gray-900 mb-4">Order Workflow Process</h3><div class="bg-white shadow rounded-lg p-6"><div class="flex flex-wrap md:flex-nowrap items-center justify-between"><div class="flex flex-col items-center w-1/6 md:w-auto mb-4 md:mb-0"><div class="step-completed rounded-full h-12 w-12 flex items-center justify-center"><i data-lucide="file-text" class="h-6 w-6"></i></div><p class="mt-2 text-sm font-medium text-gray-900">1. Order Brief</p><p class="text-xs text-gray-500 text-center">Create detailed order</p></div><div class="hidden md:block w-8 h-0.5 bg-gray-300 mx-2"></div><div class="flex flex-col items-center w-1/6 md:w-auto mb-4 md:mb-0"><div class="step-completed rounded-full h-12 w-12 flex items-center justify-center"><i data-lucide="box" class="h-6 w-6"></i></div><p class="mt-2 text-sm font-medium text-gray-900">2. Item Type</p><p class="text-xs text-gray-500 text-center">Select ready-made or custom</p></div><div class="hidden md:block w-8 h-0.5 bg-gray-300 mx-2"></div><div class="flex flex-col items-center w-1/6 md:w-auto mb-4 md:mb-0"><div class="step-completed rounded-full h-12 w-12 flex items-center justify-center"><i data-lucide="link" class="h-6 w-6"></i></div><p class="mt-2 text-sm font-medium text-gray-900">3. Supplier Confirm</p><p class="text-xs text-gray-500 text-center">Link to supplier</p></div><div class="hidden md:block w-8 h-0.5 bg-gray-300 mx-2"></div><div class="flex flex-col items-center w-1/6 md:w-auto mb-4 md:mb-0"><div class="step-current rounded-full h-12 w-12 flex items-center justify-center"><i data-lucide="camera" class="h-6 w-6"></i></div><p class="mt-2 text-sm font-medium text-gray-900">4. QC Upload</p><p class="text-xs text-gray-500 text-center">Conditional for custom items</p></div><div class="hidden md:block w-8 h-0.5 bg-gray-300 mx-2"></div><div class="flex flex-col items-center w-1/6 md:w-auto mb-4 md:mb-0"><div class="step-pending rounded-full h-12 w-12 flex items-center justify-center"><i data-lucide="ship" class="h-6 w-6"></i></div><p class="mt-2 text-sm font-medium text-gray-900">5. Shipment Approval</p><p class="text-xs text-gray-500 text-center">Final verification</p></div></div></div></div><!-- Orders Table --><div class="bg-white shadow rounded-lg overflow-hidden mb-8"><div class="px-4 py-5 sm:px-6 border-b border-gray-200"><h3 class="text-lg font-medium text-gray-900">Recent Orders</h3><p class="mt-1 text-sm text-gray-600">All orders with current status and accountability trail</p></div><div class="overflow-x-auto"><table class="min-w-full divide-y divide-gray-200"><thead class="bg-gray-50"><tr><th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Order #</th><th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Item</th><th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Type</th><th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Status</th><th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Responsible</th><th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th></tr></thead><tbody class="bg-white divide-y divide-gray-200" id="orders-table"><!-- Orders will be dynamically inserted here --></tbody></table></div></div><!-- New Order Modal --><div id="new-order-modal" class="fixed inset-0 overflow-y-auto hidden z-50"><div class="flex items-center justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0"><div class="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity" aria-hidden="true"></div><div class="inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-3xl sm:w-full"><div class="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4"><div class="sm:flex sm:items-start"><div class="mx-auto flex-shrink-0 flex items-center justify-center h-12 w-12 rounded-full bg-blue-100 sm:mx-0 sm:h-10 sm:w-10"><i data-lucide="package" class="h-6 w-6 text-blue-600"></i></div><div class="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left w-full"><h3 class="text-lg leading-6 font-medium text-gray-900">Create New Order</h3><div class="mt-6 space-y-6"><!-- Step 1: Order Brief --><div id="step-1"><h4 class="text-md font-medium text-gray-900 mb-3">1. Order Brief</h4><div class="grid grid-cols-1 gap-4 sm:grid-cols-2"><div><label for="order-name" class="block text-sm font-medium text-gray-700">Order Name</label><input type="text" id="order-name" class="mt-1 focus:ring-blue-500 focus:border-blue-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md p-2 border"></div><div><label for="order-description" class="block text-sm font-medium text-gray-700">Description</label><input type="text" id="order-description" class="mt-1 focus:ring-blue-500 focus:border-blue-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md p-2 border"></div><div class="sm:col-span-2"><label for="order-specs" class="block text-sm font-medium text-gray-700">Detailed Specifications</label><textarea id="order-specs" rows="3" class="mt-1 focus:ring-blue-500 focus:border-blue-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md p-2 border" placeholder="Include materials, dimensions, colors, packaging requirements, etc."></textarea></div></div></div><!-- Step 2: Item Type Selector --><div id="step-2" class="hidden"><h4 class="text-md font-medium text-gray-900 mb-3">2. Item Type Selector</h4><div class="grid grid-cols-1 sm:grid-cols-2 gap-4"><div class="relative"><input type="radio" id="ready-made" name="item-type" value="ready-made" class="sr-only" checked><label for="ready-made" class="relative flex flex-col p-4 border border-gray-300 rounded-lg cursor-pointer hover:border-blue-500"><div class="flex items-center"><div class="h-5 w-5 text-blue-600 border border-gray-300 rounded-full flex items-center justify-center mr-3"><div class="h-2.5 w-2.5 rounded-full bg-blue-600"></div></div><span class="block text-sm font-medium text-gray-900">Ready-made</span></div><p class="mt-2 text-sm text-gray-500 ml-8">Common items available in the market. QC photos optional.</p></label></div><div class="relative"><input type="radio" id="custom-fabrication" name="item-type" value="custom" class="sr-only"><label for="custom-fabrication" class="relative flex flex-col p-4 border border-gray-300 rounded-lg cursor-pointer hover:border-blue-500"><div class="flex items-center"><div class="h-5 w-5 text-blue-600 border border-gray-300 rounded-full flex items-center justify-center mr-3"><div class="h-2.5 w-2.5 rounded-full bg-blue-600 hidden"></div></div><span class="block text-sm font-medium text-gray-900">Custom Fabrication</span></div><p class="mt-2 text-sm text-gray-500 ml-8">Custom manufactured items. QC photos <strong class="font-semibold">required</strong> before shipment.</p></label></div></div></div><!-- Step 3: Supplier Confirmation --><div id="step-3" class="hidden"><h4 class="text-md font-medium text-gray-900 mb-3">3. Supplier Confirmation</h4><div class="space-y-4"><div><label for="supplier-select" class="block text-sm font-medium text-gray-700">Select Supplier</label><select id="supplier-select" class="mt-1 block w-full pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm rounded-md"><option value="">Choose a supplier</option><option value="supplier-1">ABC Manufacturing Co.</option><option value="supplier-2">XYZ Industrial Supplies</option><option value="supplier-3">Global Parts Ltd.</option><option value="supplier-4">Precision Components Inc.</option></select></div><div><label for="supplier-link" class="block text-sm font-medium text-gray-700">Supplier Order Link/Reference</label><input type="text" id="supplier-link" class="mt-1 focus:ring-blue-500 focus:border-blue-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md p-2 border" placeholder="https://supplier.com/order/12345 or PO #"></div><div><label for="china-staff" class="block text-sm font-medium text-gray-700">China Staff Responsible</label><div class="mt-1 flex items-center"><div class="h-8 w-8 rounded-full bg-blue-100 flex items-center justify-center text-blue-600 font-medium mr-3">CS</div><span class="text-sm font-medium text-gray-900">China Staff (Default)</span></div></div></div></div><!-- Step 4: Conditional QC Upload --><div id="step-4" class="hidden"><h4 class="text-md font-medium text-gray-900 mb-3">4. QC Photo Requirements</h4><div class="bg-blue-50 p-4 rounded-md mb-4"><div class="flex"><i data-lucide="info" class="h-5 w-5 text-blue-500 mr-2 flex-shrink-0"></i><p class="text-sm text-blue-700">Based on your selection of <strong class="font-semibold">Ready-made</strong> items, QC photos are <strong class="font-semibold">optional but recommended</strong>. For custom fabrication, QC photos would be required before shipment approval.</p></div></div><div class="file-upload-area p-8 rounded-lg border-2 border-dashed text-center cursor-pointer hover:border-blue-500 hover:bg-blue-50" id="qc-upload-area"><i data-lucide="upload-cloud" class="h-12 w-12 text-gray-400 mx-auto"></i><p class="mt-2 text-sm text-gray-600">Drag & drop QC photos here, or <span class="text-blue-600 hover:text-blue-500">browse</span></p><p class="text-xs text-gray-500 mt-1">Upload fabrication progress photos, final product photos, or packing photos</p><input type="file" id="qc-photos" class="hidden" multiple accept="image/*"></div><div id="uploaded-files" class="mt-4 hidden"><h5 class="text-sm font-medium text-gray-700 mb-2">Uploaded Files</h5><div class="space-y-2" id="file-list"></div></div></div><!-- Step 5: Shipment Approval --><div id="step-5" class="hidden"><h4 class="text-md font-medium text-gray-900 mb-3">5. Shipment Approval & Final Check</h4><div class="space-y-4"><div class="bg-yellow-50 p-4 rounded-md"><div class="flex"><i data-lucide="alert-triangle" class="h-5 w-5 text-yellow-500 mr-2 flex-shrink-0"></i><div><p class="text-sm text-yellow-700 font-medium">Accountability Note</p><p class="text-sm text-yellow-600 mt-1">Once approved, the China staff will be accountable for ensuring the correct items are loaded. If discrepancies are found at warehouse, this approval trail will identify where the error occurred.</p></div></div></div><div><label class="flex items-center"><input type="checkbox" id="final-approval" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"><span class="ml-2 block text-sm text-gray-900">I confirm all details are correct and approve this order for shipment</span></label></div><div><label for="approver-name" class="block text-sm font-medium text-gray-700">Approver Name</label><input type="text" id="approver-name" class="mt-1 focus:ring-blue-500 focus:border-blue-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md p-2 border" value="China Staff" readonly></div></div></div></div></div></div></div><div class="bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse"><button type="button" id="next-step-btn" class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-blue-600 text-base font-medium text-white hover:bg-blue-700 focus:outline-none sm:ml-3 sm:w-auto sm:text-sm">Next Step</button><button type="button" id="prev-step-btn" class="mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none sm:mt-0 sm:ml-3 sm:w-auto sm:text-sm hidden">Previous</button><button type="button" id="cancel-order-btn" class="mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none sm:mt-0 sm:w-auto sm:text-sm">Cancel</button></div></div></div></div></div><!-- Admin Panel Modal --><div id="admin-panel-modal" class="fixed inset-0 overflow-y-auto hidden z-50"><div class="flex items-center justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0"><div class="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity" aria-hidden="true"></div><div class="inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-4xl sm:w-full"><div class="bg-white px-4 pt-5 pb-4 sm:p-6 sm:pb-4"><div class="sm:flex sm:items-start"><div class="mx-auto flex-shrink-0 flex items-center justify-center h-12 w-12 rounded-full bg-red-100 sm:mx-0 sm:h-10 sm:w-10"><i data-lucide="shield" class="h-6 w-6 text-red-600"></i></div><div class="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left w-full"><h3 class="text-lg leading-6 font-medium text-gray-900" data-en="Administration Panel" data-zh="管理面板">Administration Panel</h3><div class="mt-6"><div class="grid grid-cols-1 md:grid-cols-2 gap-6"><div class="bg-gray-50 p-4 rounded-lg"><h4 class="font-medium text-gray-900 mb-3" data-en="User Management" data-zh="用户管理">User Management</h4><div class="space-y-3"><div class="flex justify-between items-center"><span data-en="Admin Users" data-zh="管理员用户">Admin Users</span><span class="font-medium">1</span></div><div class="flex justify-between items-center"><span data-en="Staff Users" data-zh="员工用户">Staff Users</span><span class="font-medium">3</span></div><div class="flex justify-between items-center"><span data-en="China Staff Users" data-zh="中国员工用户">China Staff Users</span><span class="font-medium">2</span></div></div><button class="mt-4 w-full bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded-md text-sm" data-en="Manage Users" data-zh="管理用户">Manage Users</button></div><div class="bg-gray-50 p-4 rounded-lg"><h4 class="font-medium text-gray-900 mb-3" data-en="System Settings" data-zh="系统设置">System Settings</h4><div class="space-y-3"><div class="flex items-center"><input type="checkbox" id="enable-qc-required" class="h-4 w-4 text-blue-600" checked><label for="enable-qc-required" class="ml-2 text-sm" data-en="QC Required for Custom Items" data-zh="定制产品必须QC审核">QC Required for Custom Items</label></div><div class="flex items-center"><input type="checkbox" id="enable-email-notifications" class="h-4 w-4 text-blue-600" checked><label for="enable-email-notifications" class="ml-2 text-sm" data-en="Email Notifications" data-zh="电子邮件通知">Email Notifications</label></div><div class="flex items-center"><input type="checkbox" id="enable-mandatory-photos" class="h-4 w-4 text-blue-600"><label for="enable-mandatory-photos" class="ml-2 text-sm" data-en="Mandatory Photos for All Orders" data-zh="所有订单必须拍照">Mandatory Photos for All Orders</label></div></div><button class="mt-4 w-full bg-gray-800 hover:bg-gray-900 text-white py-2 px-4 rounded-md text-sm" data-en="Save Settings" data-zh="保存设置">Save Settings</button></div><div class="bg-gray-50 p-4 rounded-lg md:col-span-2"><h4 class="font-medium text-gray-900 mb-3" data-en="Discrepancy Reports" data-zh="差异报告">Discrepancy Reports</h4><div class="overflow-x-auto"><table class="min-w-full divide-y divide-gray-200"><thead><tr><th class="px-4 py-2 text-left text-xs font-medium text-gray-500" data-en="Order ID" data-zh="订单号">Order ID</th><th class="px-4 py-2 text-left text-xs font-medium text-gray-500" data-en="Issue" data-zh="问题">Issue</th><th class="px-4 py-2 text-left text-xs font-medium text-gray-500" data-en="Responsible" data-zh="责任人">Responsible</th><th class="px-4 py-2 text-left text-xs font-medium text-gray-500" data-en="Status" data-zh="状态">Status</th></tr></thead><tbody><tr><td class="px-4 py-2 text-sm">ORD-004</td><td class="px-4 py-2 text-sm" data-en="Wrong dimensions" data-zh="尺寸错误">Wrong dimensions</td><td class="px-4 py-2 text-sm">China Staff</td><td class="px-4 py-2"><span class="px-2 py-1 text-xs bg-red-100 text-red-800 rounded-full" data-en="Open" data-zh="未解决">Open</span></td></tr></tbody></table></div></div></div></div></div></div></div><div class="bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse"><button type="button" id="close-admin-panel" class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-blue-600 text-base font-medium text-white hover:bg-blue-700 focus:outline-none sm:ml-3 sm:w-auto sm:text-sm" data-en="Close" data-zh="关闭">Close</button></div></div></div></div></div><!-- Footer --><footer class="bg-white border-t border-gray-200"><div class="max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8"><div class="md:flex md:items-center md:justify-between"><div class="flex items-center"><i data-lucide="shield" class="h-5 w-5 text-gray-400 mr-2"></i><span class="text-sm text-gray-500" data-en="Supplier QC Tracker v2.0 • Multi-Language System" data-zh="供应商质量跟踪 v2.0 • 多语言系统">Supplier QC Tracker v2.0 • Multi-Language System</span></div><div class="mt-4 md:mt-0"><span class="text-sm text-gray-500" data-en="Web-based accessible on all devices" data-zh="基于网页,所有设备均可访问">Web-based accessible on all devices</span></div></div></div></footer><script src="script.js"></script><script src="auth.js"></script><script>lucide.createIcons();</script><script src="https://deepsite.hf.co/deepsite-badge.js"></script></body></html>
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758{ "name": "Supplier QC Tracker (FREE)", "short_name": "QC Tracker", "description": "FREE supply chain quality control app with multi-language support", "start_url": "/", "display": "standalone", "background_color": "#ffffff", "theme_color": "#3b82f6", "orientation": "portrait", "categories": ["business", "productivity", "utilities"], "lang": "en", "dir": "ltr", "scope": "/", "related_applications": [], "prefer_related_applications": false, "icons": [ { "src": "icons/icon-72x72.png", "sizes": "72x72", "type": "image/png" }, { "src": "icons/icon-96x96.png", "sizes": "96x96", "type": "image/png" }, { "src": "icons/icon-128x128.png", "sizes": "128x128", "type": "image/png" }, { "src": "icons/icon-144x144.png", "sizes": "144x144", "type": "image/png" }, { "src": "icons/icon-152x152.png", "sizes": "152x152", "type": "image/png" }, { "src": "icons/icon-192x192.png", "sizes": "192x192", "type": "image/png" }, { "src": "icons/icon-384x384.png", "sizes": "384x384", "type": "image/png" }, { "src": "icons/icon-512x512.png", "sizes": "512x512", "type": "image/png" } ]}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608// Supplier QC Tracker System - Main JavaScript
document.addEventListener('DOMContentLoaded', function() { // Initialize Lucide icons if (typeof lucide !== 'undefined') { lucide.createIcons(); } // Check if user is logged in before running main script const currentUser = localStorage.getItem('qc-user'); if (!currentUser) { // Not logged in, script won't run (auth.js will handle login) return; } // Sample orders data const orders = [ { id: 'ORD-001', name: 'Plastic Containers', description: 'Food-grade plastic containers with lids', type: 'ready-made', status: 'approved', supplier: 'ABC Manufacturing Co.', responsible: 'China Staff', orderDate: '2023-10-15', expectedShipDate: '2023-11-05', qcPhotos: 0, hasDiscrepancy: false, discrepancyNotes: '' }, { id: 'ORD-002', name: 'Custom Metal Brackets', description: 'Custom fabricated steel brackets', type: 'custom', status: 'qc-required', supplier: 'Precision Components Inc.', responsible: 'China Staff', orderDate: '2023-10-20', expectedShipDate: '2023-11-15', qcPhotos: 2, hasDiscrepancy: false, discrepancyNotes: '' }, { id: 'ORD-003', name: 'Electronic Components', description: 'Standard resistors and capacitors', type: 'ready-made', status: 'shipped', supplier: 'Global Parts Ltd.', responsible: 'China Staff', orderDate: '2023-10-10', expectedShipDate: '2023-10-30', qcPhotos: 1, hasDiscrepancy: false, discrepancyNotes: '' }, { id: 'ORD-004', name: 'Custom Packaging Boxes', description: 'Custom printed cardboard boxes', type: 'custom', status: 'discrepancy', supplier: 'XYZ Industrial Supplies', responsible: 'China Staff', orderDate: '2023-09-28', expectedShipDate: '2023-10-25', qcPhotos: 3, hasDiscrepancy: true, discrepancyNotes: 'Wrong dimensions received at warehouse' }, { id: 'ORD-005', name: 'Office Chairs', description: 'Ergonomic office chairs', type: 'ready-made', status: 'received', supplier: 'ABC Manufacturing Co.', responsible: 'China Staff', orderDate: '2023-09-15', expectedShipDate: '2023-10-10', qcPhotos: 0, hasDiscrepancy: false, discrepancyNotes: '' }, { id: 'ORD-006', name: 'Custom Display Stands', description: 'Acrylic display stands with branding', type: 'custom', status: 'in-progress', supplier: 'Precision Components Inc.', responsible: 'China Staff', orderDate: '2023-10-25', expectedShipDate: '2023-11-30', qcPhotos: 0, hasDiscrepancy: false, discrepancyNotes: '' } ]; // DOM Elements const ordersTable = document.getElementById('orders-table'); const newOrderBtn = document.getElementById('new-order-btn'); const newOrderModal = document.getElementById('new-order-modal'); const cancelOrderBtn = document.getElementById('cancel-order-btn'); const nextStepBtn = document.getElementById('next-step-btn'); const prevStepBtn = document.getElementById('prev-step-btn'); const qcUploadArea = document.getElementById('qc-upload-area'); const qcPhotosInput = document.getElementById('qc-photos'); const fileList = document.getElementById('file-list'); const uploadedFilesDiv = document.getElementById('uploaded-files'); // Get current language const currentLanguage = localStorage.getItem('qc-language') || 'en'; // New order form steps const steps = ['step-1', 'step-2', 'step-3', 'step-4', 'step-5']; let currentStep = 0; let uploadedFiles = []; // Language-specific status texts const statusTranslations = { 'en': { 'pending': 'Pending', 'in-progress': 'In Progress', 'qc-required': 'QC Required', 'approved': 'Approved', 'shipped': 'Shipped', 'received': 'Received', 'discrepancy': 'Discrepancy', 'Custom': 'Custom', 'Ready-made': 'Ready-made', 'Discrepancy': 'Discrepancy', 'View': 'View', 'Edit': 'Edit', 'Next Step': 'Next Step', 'Create Order': 'Create Order', 'Previous': 'Previous', 'Cancel': 'Cancel' }, 'zh': { 'pending': '待处理', 'in-progress': '进行中', 'qc-required': '需要QC审核', 'approved': '已批准', 'shipped': '已发货', 'received': '已收货', 'discrepancy': '差异', 'Custom': '定制', 'Ready-made': '现成产品', 'Discrepancy': '差异', 'View': '查看', 'Edit': '编辑', 'Next Step': '下一步', 'Create Order': '创建订单', 'Previous': '上一步', 'Cancel': '取消' } }; // Get localized text function getLocalizedText(key) { return statusTranslations[currentLanguage][key] || key; } // Render orders table function renderOrdersTable() { if (!ordersTable) return; ordersTable.innerHTML = ''; orders.forEach(order => { const statusClass = getStatusClass(order.status); const statusText = getLocalizedText(order.status); const typeText = getLocalizedText(order.type === 'custom' ? 'Custom' : 'Ready-made'); const typeBadgeClass = order.type === 'custom' ? 'bg-purple-100 text-purple-800' : 'bg-green-100 text-green-800'; const discrepancyText = getLocalizedText('Discrepancy'); const discrepancyBadge = order.hasDiscrepancy ? `<span class="ml-2 px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-red-100 text-red-800">${discrepancyText}</span>` : ''; const viewText = getLocalizedText('View'); const editText = getLocalizedText('Edit'); const row = document.createElement('tr'); row.innerHTML = ` <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900"> ${order.id} ${discrepancyBadge} </td> <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500"> <div class="font-medium text-gray-900">${order.name}</div> <div class="text-gray-500 text-xs">${order.description}</div> </td> <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500"> <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full ${typeBadgeClass}"> ${typeText} </span> </td> <td class="px-6 py-4 whitespace-nowrap"> <span class="${statusClass} px-2 inline-flex text-xs leading-5 font-semibold rounded-full"> ${statusText} </span> </td> <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500"> <div class="flex items-center"> <div class="h-6 w-6 rounded-full bg-blue-100 flex items-center justify-center text-blue-600 text-xs font-medium mr-2">CS</div> ${order.responsible} </div> </td> <td class="px-6 py-4 whitespace-nowrap text-sm font-medium"> <button class="text-blue-600 hover:text-blue-900 mr-3 view-order-btn" data-order-id="${order.id}"> <i data-lucide="eye" class="h-4 w-4 inline"></i> ${viewText} </button> <button class="text-indigo-600 hover:text-indigo-900 edit-order-btn" data-order-id="${order.id}"> <i data-lucide="edit" class="h-4 w-4 inline"></i> ${editText} </button> </td> `; ordersTable.appendChild(row); }); // Re-initialize icons if (typeof lucide !== 'undefined') { lucide.createIcons(); } // Add event listeners to view buttons document.querySelectorAll('.view-order-btn').forEach(btn => { btn.addEventListener('click', function() { const orderId = this.getAttribute('data-order-id'); viewOrderDetails(orderId); }); }); // Add event listeners to edit buttons document.querySelectorAll('.edit-order-btn').forEach(btn => { btn.addEventListener('click', function() { const orderId = this.getAttribute('data-order-id'); editOrder(orderId); }); }); } // Get status class for styling function getStatusClass(status) { switch(status) { case 'pending': return 'status-pending'; case 'in-progress': return 'status-in-progress'; case 'qc-required': return 'status-qc-required'; case 'approved': return 'status-approved'; case 'shipped': return 'status-shipped'; case 'received': return 'status-received'; case 'discrepancy': return 'status-discrepancy'; default: return 'status-pending'; } } // View order details function viewOrderDetails(orderId) { const order = orders.find(o => o.id === orderId); if (!order) return; const typeText = order.type === 'custom' ? (currentLanguage === 'zh' ? '定制产品' : 'Custom Fabrication') : (currentLanguage === 'zh' ? '现成产品' : 'Ready-made'); const message = currentLanguage === 'zh' ? `订单详情:\n\n` + `订单号: ${order.id}\n` + `名称: ${order.name}\n` + `描述: ${order.description}\n` + `类型: ${typeText}\n` + `状态: ${getLocalizedText(order.status)}\n` + `供应商: ${order.supplier}\n` + `负责人: ${order.responsible}\n` + `订单日期: ${order.orderDate}\n` + `预计发货日期: ${order.expectedShipDate}\n` + `QC照片: ${order.qcPhotos}\n` + `差异: ${order.hasDiscrepancy ? '是 - ' + order.discrepancyNotes : '否'}` : `Order Details:\n\n` + `Order ID: ${order.id}\n` + `Name: ${order.name}\n` + `Description: ${order.description}\n` + `Type: ${typeText}\n` + `Status: ${getLocalizedText(order.status)}\n` + `Supplier: ${order.supplier}\n` + `Responsible: ${order.responsible}\n` + `Order Date: ${order.orderDate}\n` + `Expected Ship Date: ${order.expectedShipDate}\n` + `QC Photos: ${order.qcPhotos}\n` + `Discrepancy: ${order.hasDiscrepancy ? 'Yes - ' + order.discrepancyNotes : 'No'}`; alert(message); } // Edit order function editOrder(orderId) { const message = currentLanguage === 'zh' ? `编辑订单 ${orderId}。完整实现中,这将打开编辑表单。` : `Editing order ${orderId}. In a full implementation, this would open an edit form.`; alert(message); } // New order modal functions function showNewOrderModal() { newOrderModal.classList.remove('hidden'); resetNewOrderForm(); showStep(0); } function hideNewOrderModal() { newOrderModal.classList.add('hidden'); } function resetNewOrderForm() { currentStep = 0; uploadedFiles = []; // Reset form fields document.getElementById('order-name').value = ''; document.getElementById('order-description').value = ''; document.getElementById('order-specs').value = ''; document.getElementById('ready-made').checked = true; document.getElementById('supplier-select').value = ''; document.getElementById('supplier-link').value = ''; document.getElementById('final-approval').checked = false; // Reset file display fileList.innerHTML = ''; uploadedFilesDiv.classList.add('hidden'); // Update button text nextStepBtn.textContent = getLocalizedText('Next Step'); prevStepBtn.textContent = getLocalizedText('Previous'); cancelOrderBtn.textContent = getLocalizedText('Cancel'); } function showStep(stepIndex) { // Hide all steps steps.forEach(stepId => { const stepElement = document.getElementById(stepId); if (stepElement) { stepElement.classList.add('hidden'); } }); // Show current step const currentStepElement = document.getElementById(steps[stepIndex]); if (currentStepElement) { currentStepElement.classList.remove('hidden'); } // Update button visibility prevStepBtn.classList.toggle('hidden', stepIndex === 0); // Update next button text if (stepIndex === steps.length - 1) { nextStepBtn.textContent = getLocalizedText('Create Order'); } else { nextStepBtn.textContent = getLocalizedText('Next Step'); } // Update QC requirements based on item type if (stepIndex === 3) { updateQCRequirements(); } } function updateQCRequirements() { const isCustom = document.getElementById('custom-fabrication').checked; const qcInfoDiv = document.querySelector('#step-4 .bg-blue-50 p'); if (isCustom) { if (currentLanguage === 'zh') { qcInfoDiv.innerHTML = `根据您选择的<strong class="font-semibold">定制产品</strong>,QC照片在发货批准前是<strong class="font-semibold">必需的</strong>。请上传制造进度照片和���终产品照片。`; } else { qcInfoDiv.innerHTML = `Based on your selection of <strong class="font-semibold">Custom Fabrication</strong>, QC photos are <strong class="font-semibold">required</strong> before shipment approval. Please upload fabrication progress photos and final product photos.`; } } else { if (currentLanguage === 'zh') { qcInfoDiv.innerHTML = `根据您选择的<strong class="font-semibold">现成产品</strong>,QC照片是<strong class="font-semibold">可选但推荐</strong>的。对于定制产品,QC照片在发货批准前是必需的。`; } else { qcInfoDiv.innerHTML = `Based on your selection of <strong class="font-semibold">Ready-made</strong> items, QC photos are <strong class="font-semibold">optional but recommended</strong>. For custom fabrication, QC photos would be required before shipment approval.`; } } } function goToNextStep() { if (currentStep < steps.length - 1) { currentStep++; showStep(currentStep); } else { // Create the order createNewOrder(); } } function goToPrevStep() { if (currentStep > 0) { currentStep--; showStep(currentStep); } } function createNewOrder() { // Get form values const orderName = document.getElementById('order-name').value; const orderDescription = document.getElementById('order-description').value; const orderSpecs = document.getElementById('order-specs').value; const itemType = document.querySelector('input[name="item-type"]:checked').value; const supplier = document.getElementById('supplier-select').value; const supplierLink = document.getElementById('supplier-link').value; const finalApproval = document.getElementById('final-approval').checked; // Validation if (!orderName || !orderDescription || !supplier) { const errorMsg = currentLanguage === 'zh' ? '请填写所有必填字段。' : 'Please fill in all required fields.'; alert(errorMsg); return; } if (!finalApproval && currentStep === steps.length - 1) { const errorMsg = currentLanguage === 'zh' ? '请在创建订单前确认批准。' : 'Please confirm approval before creating the order.'; alert(errorMsg); return; } // Create new order object const newOrder = { id: `ORD-${String(orders.length + 1).padStart(3, '0')}`, name: orderName, description: orderDescription, type: itemType, status: itemType === 'custom' ? 'qc-required' : 'pending', supplier: document.getElementById('supplier-select').options[document.getElementById('supplier-select').selectedIndex].text, responsible: 'China Staff', orderDate: new Date().toISOString().split('T')[0], expectedShipDate: new Date(Date.now() + 20 * 24 * 60 * 60 * 1000).toISOString().split('T')[0], // 20 days from now qcPhotos: uploadedFiles.length, hasDiscrepancy: false, discrepancyNotes: '' }; // Add to orders array orders.unshift(newOrder); // Re-render table renderOrdersTable(); // Hide modal hideNewOrderModal(); // Show success message if (currentLanguage === 'zh') { alert(`订单 ${newOrder.id} 创建成功!\n\n已建立责任跟踪。${itemType === 'custom' ? '发货前需要QC照片。' : '对于此现成产品,QC照片是可选的。'}`); } else { alert(`Order ${newOrder.id} created successfully!\n\nAccountability trail established. ${itemType === 'custom' ? 'QC photos are required before shipment.' : 'QC photos are optional for this ready-made item.'}`); } } // File upload handling function handleFileUpload(files) { for (let i = 0; i < files.length; i++) { const file = files[i]; // Check if file is an image if (!file.type.startsWith('image/')) { const errorMsg = currentLanguage === 'zh' ? 'QC照片只允许上传图像文件。' : 'Only image files are allowed for QC photos.'; alert(errorMsg); continue; } // Add to uploaded files array uploadedFiles.push({ name: file.name, size: file.size, type: file.type, url: URL.createObjectURL(file) }); } // Update file list display updateFileListDisplay(); } function updateFileListDisplay() { if (uploadedFiles.length === 0) { uploadedFilesDiv.classList.add('hidden'); return; } fileList.innerHTML = ''; uploadedFiles.forEach((file, index) => { const fileSize = file.size > 1024 * 1024 ? `${(file.size / (1024 * 1024)).toFixed(1)} MB` : `${(file.size / 1024).toFixed(1)} KB`; const fileItem = document.createElement('div'); fileItem.className = 'flex items-center justify-between p-2 bg-gray-50 rounded'; fileItem.innerHTML = ` <div class="flex items-center"> <i data-lucide="image" class="h-5 w-5 text-gray-500 mr-3"></i> <div> <p class="text-sm font-medium text-gray-900 truncate max-w-xs">${file.name}</p> <p class="text-xs text-gray-500">${fileSize}</p> </div> </div> <button class="text-red-500 hover:text-red-700 remove-file-btn" data-index="${index}"> <i data-lucide="trash-2" class="h-4 w-4"></i> </button> `; fileList.appendChild(fileItem); }); uploadedFilesDiv.classList.remove('hidden'); // Re-initialize icons if (typeof lucide !== 'undefined') { lucide.createIcons(); } // Add event listeners to remove buttons document.querySelectorAll('.remove-file-btn').forEach(btn => { btn.addEventListener('click', function() { const index = parseInt(this.getAttribute('data-index')); uploadedFiles.splice(index, 1); updateFileListDisplay(); }); }); } // Event Listeners newOrderBtn.addEventListener('click', showNewOrderModal); cancelOrderBtn.addEventListener('click', hideNewOrderModal); nextStepBtn.addEventListener('click', goToNextStep); prevStepBtn.addEventListener('click', goToPrevStep); // Close modal when clicking outside newOrderModal.addEventListener('click', function(e) { if (e.target === this) { hideNewOrderModal(); } }); // File upload event listeners qcUploadArea.addEventListener('click', () => { qcPhotosInput.click(); }); qcUploadArea.addEventListener('dragover', (e) => { e.preventDefault(); qcUploadArea.classList.add('dragover'); }); qcUploadArea.addEventListener('dragleave', () => { qcUploadArea.classList.remove('dragover'); }); qcUploadArea.addEventListener('drop', (e) => { e.preventDefault(); qcUploadArea.classList.remove('dragover'); const files = e.dataTransfer.files; handleFileUpload(files); }); qcPhotosInput.addEventListener('change', (e) => { handleFileUpload(e.target.files); e.target.value = ''; // Reset input }); // Item type change listener to update QC requirements document.querySelectorAll('input[name="item-type"]').forEach(radio => { radio.addEventListener('change', updateQCRequirements); }); // Initialize the page renderOrdersTable(); // Add keyboard shortcuts document.addEventListener('keydown', (e) => { // Escape key closes modal if (e.key === 'Escape' && !newOrderModal.classList.contains('hidden')) { hideNewOrderModal(); } // Ctrl/Cmd + N creates new order if ((e.ctrlKey || e.metaKey) && e.key === 'n') { e.preventDefault(); showNewOrderModal(); } });});123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140// Service Worker for Supplier QC Tracker PWA
const CACHE_NAME = 'qc-tracker-v2.0';const urlsToCache = [ '/', '/index.html', '/manifest.json', '/style.css', '/script.js', '/auth.js', 'https://cdn.tailwindcss.com', 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css', 'https://unpkg.com/lucide@latest', 'https://static.photos/technology/192x192/1', 'https://static.photos/technology/512x512/1'];
// Install event - cache resourcesself.addEventListener('install', event => { event.waitUntil( caches.open(CACHE_NAME) .then(cache => { console.log('Service Worker: Caching app shell'); return cache.addAll(urlsToCache); }) .then(() => self.skipWaiting()) );});
// Activate event - clean up old cachesself.addEventListener('activate', event => { event.waitUntil( caches.keys().then(cacheNames => { return Promise.all( cacheNames.map(cacheName => { if (cacheName !== CACHE_NAME) { console.log('Service Worker: Deleting old cache', cacheName); return caches.delete(cacheName); } }) ); }).then(() => self.clients.claim()) );});
// Fetch event - serve from cache, fallback to networkself.addEventListener('fetch', event => { // Skip cross-origin requests if (!event.request.url.startsWith(self.location.origin)) { return; }
event.respondWith( caches.match(event.request) .then(response => { // Return cached response if found if (response) { return response; }
// Clone the request const fetchRequest = event.request.clone();
// Make network request return fetch(fetchRequest).then(response => { // Check if valid response if (!response || response.status !== 200 || response.type !== 'basic') { return response; }
// Clone the response const responseToCache = response.clone();
// Cache the new response caches.open(CACHE_NAME).then(cache => { cache.put(event.request, responseToCache); });
return response; }).catch(() => { // If network fails and request is for HTML, return offline page if (event.request.headers.get('accept').includes('text/html')) { return caches.match('/'); } }); }) );});
// Push notification eventself.addEventListener('push', event => { const options = { body: event.data ? event.data.text() : 'New order update available', icon: 'icons/icon-192x192.png', badge: 'icons/icon-72x72.png', tag: 'qc-tracker-notification', renotify: true, actions: [ { action: 'open', title: 'Open App' }, { action: 'close', title: 'Close' } ] };
event.waitUntil( self.registration.showNotification('Supplier QC Tracker', options) );});
// Notification click eventself.addEventListener('notificationclick', event => { event.notification.close();
if (event.action === 'open') { event.waitUntil( clients.openWindow('/') ); }});
// Periodic sync for background updates (if browser supports)if ('periodicSync' in self.registration) { self.addEventListener('periodicsync', event => { if (event.tag === 'sync-orders') { event.waitUntil(syncOrders()); } });}
// Background sync functionfunction syncOrders() { return fetch('/api/orders/sync', { method: 'POST' }) .then(response => response.json()) .then(data => { console.log('Background sync completed:', data); return data; }) .catch(error => { console.error('Background sync failed:', error); });}README.md+9-6
auth.jsAdded+615
icons/README.mdAdded+19
index.html+621-19
manifest.jsonAdded+58
script.jsAdded+608
service-worker.jsAdded+140