Commit Graph
78 Commits
Author SHA1 Message Date
AndymickandClaude Haiku 4.5 0d575f5231 Move login activity items from Finance menu to Admin menu
- Move 'Admin login activity' from Financial submenu to top-level Admin menu
- Move 'Customer login activity' from Financial submenu to top-level Admin menu
- Keep Financial menu focused on accounting: Accounts, Reports, Bank Reconciliation, Audit Trail
- Login activity now easier to access at main menu level

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 06:04:47 +01:00
AndymickandClaude Haiku 4.5 8646b42438 Add download photo button to custom request detail page
- Create DownloadPhotoButton component for downloading customer photos
- Add download button before 'Start a design for this' button
- Allows admin to save photo locally for editing in design software before approval

Addresses user request: admin should be able to download photo from request
for editing before uploading final design to the approval flow.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-17 23:00:58 +01:00
AndymickandClaude Haiku 4.5 d134d3a93c Fix dark mode text visibility in all form inputs
Add bg-paper class to global input/textarea/select styling. Previously text-ink
was applied but inputs lacked background color, causing light text on light backgrounds.

Now all form inputs globally have:
- bg-paper for proper dark mode background
- text-ink for readable text in both light and dark modes

Fixes visibility issues on custom-request, contact, and all other form pages.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-17 22:56:53 +01:00
AndymickandClaude Haiku 4.5 b7379e379b Add login prompt when non-authenticated users add items to cart
- Create LoginPromptModal component for authentication encouragement
- Check customer authentication before adding items to cart
- Show modal for non-logged-in users with options to create account, log in, or continue as guest
- Allow guests to add items (stored in IndexedDB) while prompting to sign up
- Implemented in both StandardProductView (ready-made products) and DesignCanvas (personalized items)
- Add server action checkCustomerAuth() for authentication checks

Addresses user request: prompt guests to create account or log in when adding items to cart.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-17 22:53:36 +01:00
AndymickandClaude Haiku 4.5 0cc072fda4 Improve cart and dark mode UX
- Clear cart when customer logs out
- Hide cart bag button for non-authenticated users (only show for logged-in customers)
- Fix dark mode text visibility in all form inputs (input/textarea/select elements)

Addresses user request: cart should clear on logout and only be accessible to logged-in customers.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-17 22:47:43 +01:00
AndymickandClaude Haiku 4.5 c8dc3467f9 Rebuild documentation with comprehensive setup guide
- Rewrote README.md with current feature set (accounting, auth, checkout)
- Lists all major features: design tool, cart, customer accounts, dark mode
- Financial system overview: reports, bank reconciliation, audit trail
- Quick start for local development in 5 steps
- Configuration reference table
- Created SETUP_AND_BUILD.md with complete deployment guide:
  - Local development setup (prerequisites, environment, database)
  - Configuration reference for all .env variables
  - Database management (push, seed, backup, reset)
  - Feature setup (Stripe, email, CAPTCHA)
  - Production build process
  - Deployment options (self-hosted, Vercel, Docker)
  - Post-deployment checklist
  - Troubleshooting common issues
  - Maintenance tasks and security hardening

Helps new developers get running quickly and provides clear deployment path.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-17 22:34:49 +01:00
AndymickandClaude Haiku 4.5 3aa2b730bc Auto-logout users when page is closed
- 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>
2026-07-17 22:31:40 +01:00
AndymickandClaude Haiku 4.5 a2908e8ae1 Fix checkout page to hide login prompt when user is logged in
- Refactor checkout page into server component (page.tsx) + client component (client.tsx)
- Server component checks getCurrentCustomer() and passes isLoggedIn prop
- When logged in, show direct checkout button instead of login/guest options
- When not logged in, show login/guest choice as before
- Hides the 'Your cart will be saved...' message from logged-in users

Fixes: Login/guest prompt appearing even when user is already authenticated

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-17 22:26:14 +01:00
AndymickandClaude Haiku 4.5 84454da5c9 Fix login form text contrast in dark mode
- Add explicit text-ink color to username/email/password input fields
- Add explicit bg-paper background class to inputs for proper styling
- Fixes visibility issue where input text was too light to read in dark mode
- Improves contrast and readability for both admin and customer login forms

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-17 22:13:15 +01:00
AndymickandClaude Haiku 4.5 26ac37b1df Replace hex color codes with friendly color names for customers
- 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>
2026-07-17 20:08:56 +01:00
AndymickandClaude Haiku 4.5 47bc87692d Consolidate financial pages into Financial submenu
- 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>
2026-07-17 17:31:05 +01:00
Andymick 560fbb3978 Fix build errors and prepare for deployment
- Fix const reassignment in Phase 2 reports export (use let for mutable vars)
- Fix TypeScript interface to match Prisma reconciliation schema
- Fix array comparison logic in bank CSV parsing
- Temporarily disable pdf-parse due to module compatibility issue (pre-existing)

All phases now build successfully with zero errors.
2026-07-17 16:58:51 +01:00
AndymickandClaude Haiku 4.5 7f88379d3b Phase 3: Bank reconciliation system
Added complete bank statement reconciliation workflow:

Database Schema:
- BankStatement: metadata for uploaded statements
- BankStatementLine: individual transactions from statements
- BankReconciliation: links system transactions to bank lines

Features:
- CSV import with flexible format detection (DD/MM/YYYY, YYYY-MM-DD dates)
- Auto-matching algorithm: exact amount+date = 100% confidence, fuzzy matching up to 7 days
- Manual matching UI for unmatched transactions
- Discrepancy detection (amount mismatches)
- Reconciliation dashboard with summary stats
- Statement history view with status tracking

Pages:
- /admin/accounts/reconciliation: Dashboard and statement list
- /admin/accounts/reconciliation?id=X: Statement detail with matching UI
- /admin/accounts/reconciliation/upload: CSV upload form

Server Actions:
- uploadBankStatement: CSV parsing and auto-matching
- manualMatch: User-initiated transaction linking
- unmatchBankLine: Remove incorrect match
- archiveStatement: Mark statement as complete
- markReconciled: Finalize reconciliation

Utils:
- parseCSV: Flexible bank statement parser
- autoMatchTransactions: Fuzzy matching algorithm
- getReconciliationSummary: Stats calculation

UI Components:
- ReconciliationClient: Interactive matching interface with tabs
- Manual match form: User-friendly transaction linking

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-17 15:58:23 +01:00
AndymickandClaude Haiku 4.5 2d55203c1c Phase 2 Complete: Comprehensive reporting UI with all features
Added 10 major enhancements:
1. KPI Dashboard with Year-to-Date (YTD) summary cards
2. Income breakdown by source (web vs manual sales)
3. Expense breakdown with pie chart visualization
4. Revenue vs Operating Expenses comparison chart
5. Growth metrics (Month-over-Month % changes)
6. Monthly drill-down modal (click bars/rows for transaction details)
7. UK Tax Year summary (April-April) with HMRC export
8. Sortable tables (click headers to sort by date/amount)
9. Better export options (all/income/expenses/tax-year formats)
10. Quick filters for expense categories

Features:
- 9 report tabs: KPIs, Trends, Monthly Profit, Income, Expenses, Revenue vs Expenses, Cash Flow, Tax Year, HMRC
- Interactive charts with click-to-drill functionality
- SVG visualizations for profit trends and expense distribution
- Real-time calculations for YTD, tax year, growth metrics
- Accountant-friendly exports with proper formatting
- UK tax compliance with April-April year tracking

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-17 15:41:16 +01:00
AndymickandClaude Haiku 4.5 78487affbd Phase 2: Better reporting UI with charts and exports
- Add CSV export utility for ledger data (generateLedgerCSV)
- Export formatters: pence to pounds, proper CSV escaping
- Date range filtering (from/to inputs) on reports page
- Export CSV button with proper formatting for accountants
- New \"Trends\" tab with visual profit trend chart
- SVG bar chart shows last 12 months of profit
- Charts color-coded: green (profit), red (loss)
- Shows monthly values and best/worst month stats
- Export functionality:
  - Filters by date range
  - Combines all income sources (orders + manual sales)
  - Includes COGS (purchases) and expenses
  - Generates PDF-ready CSV with summary rows
  - Downloads with proper date-stamped filename

CSV exports are formatted for accountants and tax software:
- Includes summary totals
- Proper date formatting (DD/MM/YYYY)
- Escaped descriptions for safe import
- Clear categorization

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-17 15:26:20 +01:00
AndymickandClaude Haiku 4.5 d56f942a88 Phase 1: Financial audit logging foundation
- 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>
2026-07-17 15:23:05 +01:00
AndymickandClaude Haiku 4.5 e69759081c Add customer login activity logging
- 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>
2026-07-16 21:43:09 +01:00
AndymickandClaude Haiku 4.5 ea6f9d2e25 Add admin login activity logging
- 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>
2026-07-16 21:33:40 +01:00
AndymickandClaude Haiku 4.5 53dd963090 Add HMRC tax reporting to accounts
- Add new HMRC Report tab to accounts reports
- Show total turnover (web + manual sales)
- Calculate cost of goods sold from purchases
- Display gross profit and profit margin
- Show operating expenses breakdown
- Calculate net profit before tax
- Estimate tax liability (19% corporation tax)
- Include HMRC checklist of what needs to be reported
- Help admin prepare for Self Assessment submission

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-16 21:17:46 +01:00
AndymickandClaude Haiku 4.5 d596cbe836 Add automatic invoice parsing to extract purchase items
- 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>
2026-07-16 21:14:49 +01:00
AndymickandClaude Haiku 4.5 48017facf0 Use AdminMenu component in header
- 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>
2026-07-16 20:33:06 +01:00
AndymickandClaude Haiku 4.5 6c8d34edde Add admin menu link to header when authenticated
- 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>
2026-07-16 20:31:22 +01:00
AndymickandClaude Haiku 4.5 8edb5e1f5b Add guest checkout and admin login link
- Add guest checkout flow: customers can now complete orders without creating an account
  - New /checkout page with login or guest options
  - Guest form collects: full name, email, phone, address
  - Orders track guest info via guestName and guestPhone fields
- Update cart message to reflect guest option
- Add "Admin login" link to customer login page for clear navigation
- Update checkout API to accept and store guest information

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-16 20:10:42 +01:00
AndymickandClaude Haiku 4.5 39f54dedee Wire Stage 3 reports to real data
Created getReportData server action to fetch Orders, ManualSales, and
Expenses from database. Split reports page into server component (fetches
data) and client component (renders charts). Reports now display actual
business data instead of mock data - monthly profit, expense breakdown,
and cash flow tables.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-15 19:24:56 +01:00
AndymickandClaude Haiku 4.5 339b2d960e Remove AdminMenu from public site header
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>
2026-07-15 19:18:51 +01:00
AndymickandClaude Haiku 4.5 158c9cf934 Add ProductImage schema for bulk image upload
- ProductImage model links images to products with detected color
- Supports any product type (tees, hoodies, mugs, etc.)
- One image per color per product (unique constraint)

Bulk upload form + color detection coming next.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-15 18:14:43 +01:00
AndymickandClaude Haiku 4.5 7cb8d9b5a6 Stage 3: Complete expense pages + reports
- Add Expense CRUD pages (/expenses list, /new form, /[id] detail) + actions
- Expense form: date/description/category/amount/receipt, auto-create from purchases
- Reports page: 3 tabs (monthly profit, expense breakdown, cash flow) with tables
- Add Expenses + Reports to AccountsNav tabs

All expense features wired. Reports skeleton ready for data integration.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-15 18:14:14 +01:00
Andymick 41937ffc15 Initial commit: Craft2Prints with Stages 1-3 2026-07-15 18:09:59 +01:00