Commit Graph
18 Commits
Author SHA1 Message Date
Andymick 43da81bd66 Fix: Ensure cart is completely cleared after payment success
ClearCartOnMount now explicitly deletes the IndexedDB storage in addition
to clearing the in-memory state. This prevents the cart from being
restored from IndexedDB on subsequent page loads after payment completes.

Fixes issue where cart items remained in bag after successful checkout.
2026-07-18 20:23:45 +01:00
Andymick 06cfe52a95 Fix: Handle undefined designElements in design spec SVG rendering
The SVG element markers were trying to map over designElements without
checking if it was defined first. Now safely checks for array existence
before calling .map() to prevent errors when generating spec sheets.
2026-07-18 20:20:21 +01:00
Andymick 9dc62210b1 Improve: Design specification sheet now shows previews and info
- Always show design sections if preview images exist, even without elements
- Add design preview images to the spec sheet
- Add better error handling for designJson parsing
- Show more useful information even when elements table is empty
- Makes spec sheet more useful for reference and planning
2026-07-18 20:09:24 +01:00
Andymick 7a7e1964bf Fix: Safely parse designJson in admin order detail page
The order detail page was trying to access design.front.length and
design.back.length without safely checking if they exist. Now wraps
the parse in try-catch and uses optional chaining to handle errors
gracefully.
2026-07-18 20:04:07 +01:00
Andymick 404f17acb2 Fix: Show personalised price on design review page
Design review pages are always for personalised products, so display
the personalised price instead of the base effective price. This ensures
the preview page shows the same price that will be charged at checkout.
2026-07-18 20:02:48 +01:00
Andymick 121d469d06 Fix: Safely access designJson properties in admin orders page
The admin orders page was trying to access .front.length and .back.length
without safely checking if they exist, causing 'Cannot read properties of
undefined' error. Now uses optional chaining and try-catch to handle parsing
errors gracefully.
2026-07-18 19:59:52 +01:00
Andymick 6b2072b0a7 Fix: Use personalised price in design approval cart add
When adding personalised designs to cart, use personalisedPrice instead
of just effectivePrice. This ensures the cart shows the correct price
for made-to-order items from the start, matching what Stripe calculates.
2026-07-18 19:59:25 +01:00
Andymick fae1ce04c2 Fix: Handle designJson as string in checkout API
The designJson field can be either a parsed object or a JSON string
depending on how it was stored. The checkout API was assuming it was
always an object and casting it, which caused 'Cannot read properties
of undefined' error when trying to access .length on front/back arrays.

Now properly parses the string if needed and safely accesses array
properties with optional chaining.
2026-07-18 19:54:53 +01:00
Andymick 60cb73f8a4 Fix: Calculate effectivePrice in design API endpoints
The design API was returning raw product data without calculating
effectivePrice, which caused prices to not be set when items were added
to the cart. Now uses toProductDTO to properly calculate the effective
price (accounting for sales) before returning design data.

Fixes issue where design reviews showed correct price but cart showed £0.00
2026-07-18 19:51:07 +01:00
Andymick 62ae2755f0 Fix price display issues and layout in design review page
- Add defensive checks in cart store to handle missing/NaN unitPrice values
- Display '—' for items with invalid prices instead of NaN
- Fix design review page grid layout to align buttons at top of page
- Ensure buttons don't get pushed below images on review page
2026-07-18 19:46:11 +01:00
AndymickandClaude Haiku 4.5 609cfdb7d6 Update local settings tracking
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 18:27:33 +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 10af792261 Remove reviews section from product pages
- Delete Reviews.tsx component
- Remove Reviews from standard product page
- Remove Reviews from made-to-order product page
- Simplify page layout by removing review section

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 16:24:28 +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 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
Andymick 41937ffc15 Initial commit: Craft2Prints with Stages 1-3 2026-07-15 18:09:59 +01:00