8 Commits

Author SHA1 Message Date
de7156583b Fix Reports page mobile layout
Add data-label attributes to all report table cells and hide bar chart
column on small screens so tables render as labeled cards on mobile.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 21:47:42 -06:00
75caed2f29 Add comprehensive CHANGELOG documenting all changes
Covers all work from this session:
- Restock history tracking (stock_adjustments table, logging)
- Payment tracking (payment_method, amount_paid on orders)
- Reports page (5 report sections, date filtering)
- Girl Scouts trefoil logo
- Mobile network access (Vite host: true)
- Bugs found and fixed during development iteration
- Full code review fixes (P0-P3): batching bug, ID validation,
  delete reference checks, audit trail enforcement, global error
  handler, input validation, client robustness, schema migrations,
  useEffect deps
- README and CLAUDE.md documentation updates

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 21:40:11 -06:00
c00bb90cc0 Update CLAUDE.md with current architecture and documentation policy
- Add documentation requirement: all changes must be meticulously
  documented in commits and relevant docs updated
- Update architecture docs to reflect new files (utils.js, reports
  route, Reports/Restock pages)
- Document validation patterns (parseId, date validation, 409 on
  delete with references)
- Document schema migration approach (schema_version table)
- Update schema section (6 tables, payment fields, stock_adjustments)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 21:37:05 -06:00
7068ea354e Fix bugs, harden validation, and improve robustness
P0 fixes:
- Fix OrderDetail product change overwriting product_id due to React
  state batching (single setItems call now updates both fields)
- Validate all :id route params via parseId helper; return 400 for
  invalid IDs instead of passing raw strings to SQLite
- Product/customer delete now checks for references first, returns
  409 Conflict instead of letting FK constraint produce 500

P1 fixes:
- Disallow quantity_on_hand in product PUT so all stock changes go
  through PATCH /stock (preserves audit trail)
- Add global Express error handler and unhandledRejection listener

P2 fixes:
- Validate report date params (YYYY-MM-DD format) and stock-history
  limit (positive integer, capped at 1000)
- Add jsonSafe() helper to api.js for safe 204 handling
- OrderNew setSubmitting now runs in finally block
- Login shows specific message for 429 rate limit, generic message
  for other auth failures

P3 fixes:
- Replace brittle try/catch ALTER TABLE with schema_version migration
  table and versioned migrations
- Fix OrderDetail useEffect missing dependency (useCallback + [load])

Also: expanded README with full production deployment instructions
(PM2, nginx, backups)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 21:35:53 -06:00
1ed2642e20 Add restock history tracking, payment tracking, and reports page
- New stock_adjustments table logs every stock change (restock, order
  create/update/delete) with reason and reference
- Orders now track payment_method and amount_paid with validation
- New /api/reports endpoint with 5 aggregation queries and date filtering
- Reports page with date range presets and sales, customer, revenue,
  status, and inventory sections
- Payment fields added to OrderNew and OrderDetail pages with balance due
- Girl Scouts trefoil logo added to header
- Vite dev server exposed on network for mobile access

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 21:20:59 -06:00
596b0b6f03 Add walk-in customer name field and bulk restock page
When "Walk-in" is selected on the new order form, an optional name input
now appears. If filled, a new customer is created and linked to the order;
if left blank, the order remains a nameless walk-in as before.

Adds a new Restock page that lists all products with their current stock
and lets the user enter quantities to add in bulk, using the existing
PATCH /products/:id/stock endpoint.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 18:30:10 -06:00
39b2ce73da Fix critical security vulnerabilities and data integrity issues
- Use timing-safe comparisons for HMAC verification and password checks
- Add login rate limiting (5 attempts/minute per IP)
- Lock down CORS to Vite dev origin only (not needed in production)
- Derive signing key from APP_PASSWORD instead of using it directly
- Replace hand-rolled cookie parsing with cookie-parser middleware
- Wrap all order mutations in SQLite transactions
- Fix TOCTOU race on stock with atomic UPDATE...WHERE quantity >= ?
- Fix APP_SECERT typo in .env (gitignored, local fix only)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 18:04:24 -06:00
b0e4e977c1 Initial commit: cookie-tracker
Girl Scout Cookie tracking app with Express/SQLite API and React/Vite client.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 17:48:42 -06:00