Commit Graph
35 Commits
Author SHA1 Message Date
AndymickandClaude Haiku 4.5 b97d015cd1 Load design elements for admin editing
Pass designJson to DesignCanvas and parse it to restore the design
elements that were submitted for approval, so admins can see and edit
the actual design.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 19:15:53 +01:00
AndymickandClaude Haiku 4.5 c982c983e5 Add delete button to design approvals page
Allow admins to delete individual design submissions to clean up test data.
Includes confirmation dialog and reloads page on successful deletion.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 19:13:03 +01:00
AndymickandClaude Haiku 4.5 0d2e874f14 Fetch designs without relations to avoid database corruption issues
Query designs and products separately instead of using Prisma relations,
which allows the page to load even if there's corrupted data in the table.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 19:11:19 +01:00
AndymickandClaude Haiku 4.5 ca11baf1ae Fix Prisma query by excluding problematic designImageDimensions field
Use explicit select instead of include to avoid querying fields that
might have corrupted data, allowing the admin designs page to load.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 19:10:19 +01:00
AndymickandClaude Haiku 4.5 a5f09e9f75 Disable Submit for Approval button when admin is editing design
Added isAdminEditing prop to DesignCanvas. When true, the Submit for Approval
button is disabled (grayed out) since the admin should use the Send to Customer
for Review button instead. This is a safer approach than hiding the button.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 18:27:00 +01:00
AndymickandClaude Haiku 4.5 04f45c6e6b Fix loading state not being cleared when design data loads successfully
The setLoading(false) call was only in the catch block, so when the API
call succeeded, the page would stay in a "Loading..." state indefinitely.
Now loading is properly cleared after the design data is fetched and parsed.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 18:08:02 +01:00
Andymick 82f5c96fd3 Revert "Hide customer action buttons (Submit/Add to bag) when in admin editing mode"
This reverts commit 30e4a0c229.
2026-07-18 18:07:10 +01:00
AndymickandClaude Haiku 4.5 30e4a0c229 Hide customer action buttons (Submit/Add to bag) when in admin editing mode
Added isAdminEditing prop to DesignCanvas component. When true, hides the
"Submit for Approval" and "Add to bag" buttons since these are customer-facing
actions. The admin edit page now only shows the design canvas and the
"Send to Customer for Review" button.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 18:05:55 +01:00
AndymickandClaude Haiku 4.5 dda63e559b Fix admin design edit page to properly parse JSON product fields
The DesignCanvas component expects product.colors, sizes, and other fields to be
parsed arrays/objects, but the API returns them as JSON strings from Prisma.
Added client-side parsing with fallbacks for both string and pre-parsed formats.

Also removed unused getCurrentAdmin import from the API route.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 17:58:00 +01:00
AndymickandClaude Haiku 4.5 ac27cc554b Add design approval workflow infrastructure: PATCH endpoint, email notifications, and message types
- Add PATCH method to /api/designs/[id]/route.ts for status updates
- Create sendDesignReadyForReview email template for customer notifications
- Enhance /api/designs/[id]/messages to support messageType field (MESSAGE | CHANGE_REQUEST)
- Add database migration for messageType field with MESSAGE default

This completes the backend infrastructure for the multi-step design approval workflow:
1. Admin edits and sends design to customer for review
2. Customer approves design or requests changes
3. Admin receives notifications for change requests

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 17:11:10 +01:00
AndymickandClaude Haiku 4.5 4d124b1550 Add customer approval status messages and admin delete option
Customer-facing changes:
- Show approval status message when design is submitted
- Display pending approval notification with email confirmation
- Show approved confirmation when design is ready
- Show rejection message for designs needing changes

Admin-facing changes:
- Add delete button to design approval detail page
- Confirmation dialog before deletion
- Proper cleanup of design and associated messages
- Redirect to designs list after deletion

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 16:48:35 +01:00
AndymickandClaude Haiku 4.5 5c4774be84 Add design approval workflow and per-image dimension tracking
- Add DesignApproval and DesignApprovalMessage models for design review workflow
- Add design approval admin interface (list, detail, chat, approve/reject)
- Add per-image dimension tracking to OrderItem
- Add design submission API endpoint
- Add AdminDesignEditor for admin-side design modifications
- Add DesignApprovalChat component for customer-admin communication
- Update design specification generation with image dimension details
- Add design persistence across login with next parameter redirect
- Add font properties UI with font size and color display

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 16:21:19 +01:00
AndymickandClaude Haiku 4.5 0e14fc7981 Add reference size fields to product admin editor
- Add referenceWidthCm and referenceHeightCm to ProductDTO
- Update toProductDTO to include reference size fields
- Add reference size inputs to admin product edit page
- Update updateProduct action to handle reference sizes
- Rulers on personalization page use product reference size

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 12:26:16 +01:00
Andymick 4d9cfa4023 Add product dimensions and downloadable design specification sheet
- Add printAreaWidthMm and printAreaHeightMm fields to Product model
- Create API endpoint to generate design specs with CM measurements
- Add download button to order detail page
- Specs include design elements with positions/sizes in centimeters
2026-07-18 10:29:37 +01:00
Andymick ac61d95ac8 Add design element details (size, position, rotation) to order detail page 2026-07-18 10:25:37 +01:00
Andymick 0145f425b1 Add filter to show only personalised orders 2026-07-18 10:13:21 +01:00
Andymick 64b57b8680 Add 'Personalised' badge to orders with custom designs 2026-07-18 10:12:51 +01:00
Andymick cee1013a7a Add error handling to customers/mailing list page 2026-07-18 08:54:32 +01:00
Andymick a891acca63 Add error handling to orders page 2026-07-18 08:54:21 +01:00
Andymick 2db94f6bd3 Add error handling to accounts/ledger page 2026-07-18 08:54:04 +01:00
Andymick 3b5d1947dd Add error handling to stock page for Prisma queries 2026-07-18 08:53:05 +01:00
Andymick cf1d40b1c1 Fix color name detection with fuzzy matching, fix checkout syntax errors, add error handling for products page 2026-07-18 08:44:59 +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 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
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 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 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