feat(pos): add 5 quick improvements — dark mode, email quotes, barcode scan, returns, offline catalog

1. Auto dark mode: detect system prefers-color-scheme, auto-switch industrial/modern theme
2. Email quotation endpoint: POST /quotations/:id/email sends HTML email via SMTP
3. Camera barcode scanner: BarcodeDetector API with getUserMedia overlay in catalog
4. Returns with warranty: POST /returns endpoint with stock restoration and sale status tracking
5. Partial offline catalog: cache top 500 parts in IndexedDB, search when offline

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-04 08:03:28 +00:00
parent 39f2aaf98f
commit c61e58ac6a
9 changed files with 751 additions and 23 deletions

View File

@@ -128,8 +128,16 @@
});
// ─── Theme management ───
// Persist theme in localStorage, apply on load
var savedTheme = localStorage.getItem('pos_theme') || 'industrial';
// Determine theme: saved preference > system preference > default 'industrial'
var savedTheme = localStorage.getItem('pos_theme');
if (!savedTheme) {
// No saved preference — use system color scheme
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
savedTheme = 'industrial';
} else {
savedTheme = 'modern';
}
}
document.documentElement.setAttribute('data-theme', savedTheme);
// Hide all theme bars (they overlap content with position:fixed)
@@ -146,6 +154,18 @@
// Override any page-level setTheme functions so they use our persistent version
window.setTheme = window.posSetTheme;
// Listen for system color scheme changes and auto-switch (only if user hasn't manually set a preference)
if (window.matchMedia) {
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', function(e) {
// Only auto-switch if user hasn't explicitly set a preference
var userExplicit = localStorage.getItem('pos_theme');
if (!userExplicit) {
var autoTheme = e.matches ? 'industrial' : 'modern';
document.documentElement.setAttribute('data-theme', autoTheme);
}
});
}
// Also prevent any DOMContentLoaded theme switchers from overriding
// by re-applying our saved theme after a tick
setTimeout(function() {