- Create LogoutOnUnload component that triggers logout on page close
- Uses beforeunload/unload events with navigator.sendBeacon() for reliability
- Create /api/logout endpoint that clears both admin and customer sessions
- Add LogoutOnUnload to root layout so it runs on all pages
- Works for both admin and customer users
Behavior:
- When user closes browser tab/window, logout happens automatically
- Session cookies are cleared via API endpoint
- Improves security by preventing session hijacking from closed windows
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Add colorNames utility with 80+ standard color names
- Map hex codes to human-readable names (Black, Navy, Red, Teal, etc)
- Display color names in product page (with hex tooltip for reference)
- Show selected color name below color swatches
- Update shopping cart to display color names instead of hex codes
- Admin color picker shows both name and hex code for clarity
Improves UX for customers who don't understand hex color codes.
Keeps hex codes for internal data and system tooltips.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Grouped accounts, reports, reconciliation, and audit logs under one menu
- All 6 financial tools now accessible from expandable Financial submenu
- Cleaner admin navigation with collapsible sections
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Add FinancialAuditLog model to track all financial changes
- Log action (CREATE, UPDATE, DELETE) with before/after values
- Capture who made changes (IP address)
- Record timestamp and reason for change
- Create /admin/financial-audit page to view audit trail
- Add filtering by entity type, action, date range
- Show summary stats (total changes, deletions, etc)
- Integrate with purchases: log create and delete operations
- Red-flag deletions for security awareness
- Add "Financial audit trail" link to admin menu
This provides foundation for Phase 2 (reporting UI) and Phase 3 (bank reconciliation).
All financial changes are now traceable and auditable for compliance.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Add CustomerLoginLog model to track customer login attempts
- Record successful and failed customer logins
- Capture email, IP address, and user agent for each attempt
- Create /admin/customer-login-logs page to view activity
- Show login stats (successes, failures, active customers)
- Display browser/device and IP for each login attempt
- Add "Customer login activity" link to admin menu
- Monitor customer access patterns and detect suspicious activity
- Last 30 days active customer count
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Add AdminLoginLog model to track all login attempts
- Record successful and failed login attempts
- Capture IP address and user agent for each login
- Create /admin/login-logs page to view activity history
- Show login stats (successes, failures, last 30 days)
- Display browser/device and IP for each login
- Add "Login activity" link to admin menu
- Useful for security auditing and monitoring access
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Install pdf-parse and tesseract.js for PDF/image processing
- Create /api/admin/parse-invoice endpoint to extract line items from invoices
- Parser extracts quantity and description from invoice text
- Attempts to match extracted items to products in database
- Update PurchaseForm with "Extract items" button
- Pre-fill purchase form with parsed items (user can edit/add more)
- Supports PDF files and image scans (JPG, PNG, etc)
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Import and use existing AdminMenu component instead of simple link
- Displays dropdown menu with all admin section links when clicked
- Includes logout button in admin menu
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Check isAdminAuthenticated() in Header component
- Show 'Admin' link to /admin/orders when user is logged in as admin
- Allows quick navigation to admin section after login
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Hide admin interface completely from public site. Admins access /admin/login
directly. Cleaner separation between customer-facing UI and back office.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>