Commit Graph
93 Commits
Author SHA1 Message Date
AndymickandClaude Haiku 4.5 f770428556 Feature: Add database-driven shipping rates management
- Add ShippingRate model to Prisma schema with service name, base price, per-kg surcharge, estimated delivery days, and international flag
- Create migration to add shipping_rates table
- Update seed.ts to populate initial Royal Mail rates (domestic and international)
- Refactor getRoyalMailShippingQuotes to fetch rates from database with fallback to defaults
- Add /admin/shipping-rates page for managing rates
- Add ShippingRatesForm component with inline editing and add/remove functionality
- Add server actions for saving and deleting rates
- Add "Shipping rates" link to admin navigation

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-19 11:30:31 +01:00
AndymickandClaude Haiku 4.5 809cd16ec5 UX: Add Dashboard link to admin menu on main site
- Admin users now see "Admin" dropdown in header when on main site
- Dashboard link added as first item in admin menu
- Quick access to admin panel from any page on main site
- Allows admins to navigate between site and admin panel easily

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-19 10:29:44 +01:00
AndymickandClaude Haiku 4.5 df4a95b3c8 Feature: Add customer search and selection to email page
- Create CustomerSelector component for searching and selecting customers
- Search by name or email with real-time filtering
- Select individual customers or select all with one click
- Shows count of selected customers
- Shows subscribed customer count in search results
- Updated email form to use selected customers
- Falls back to all subscribed if no customers selected
- Displays preview of recipient count before sending

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-19 10:25:04 +01:00
AndymickandClaude Haiku 4.5 98b64ecd60 Feature: Add collapsible login tables and customer activity report
- Make login activity tables collapsible (show/hide on demand)
- Display only last 10 logins in collapsed tables
- Add "Most Active Customers" report on customer login activity page
- Shows top 10 most active customers with login counts
- Fix back links on both login activity pages (was /admin, now /admin/orders)
- Create CollapsibleLoginTable component for customer logins
- Create CollapsibleAdminLoginTable component for admin logins

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-19 10:05:15 +01:00
AndymickandClaude Haiku 4.5 9623ac2fdb Feature: Add password change functionality for admin and customers
- Add customer password change page at /account/change-password
- Add admin password change page at /admin/change-password
- Create AdminUser database table for storing admin credentials
- Admin login now checks database first, falls back to env vars
- Update admin auth to support bcrypt password hashing
- Add change password links to customer account and admin nav
- Fix customer login logs back link (was pointing to non-existent /admin)
- Add success/error message handling for password changes

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-19 09:51:52 +01:00
AndymickandClaude Haiku 4.5 36cc6dddff Feature: Add WhatsApp notifications for collection-ready orders
- Implement WhatsApp Business API integration via Meta Cloud API
- Add phoneNumber field to Order model for storing customer phone numbers
- Update admin order detail page with phone number input for collection orders
- Send WhatsApp notification when admin marks order as ready for collection
- Add WhatsApp service module with phone number formatting and message sending
- Create database migrations for collection-related fields
- Add WhatsApp credentials to .env configuration

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-19 09:29:09 +01:00
Andymick 560e172880 Fix: Update notification badge label to 'Waiting payment' 2026-07-19 07:55:14 +01:00
AndymickandClaude Haiku 4.5 a1c463fb49 Feature: Add unread message notifications to admin badge
- Add isRead boolean field to Message model (default: false)
- Create migration to update database schema
- Update admin notifications to count unread messages
- Display unread message count in notification badge tooltip
- Admins now see all notifications: pending orders, design approvals, photo requests, unread messages
- Color-coded tooltip: orange (orders), blue (designs), clay (photos), pink (messages)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-19 07:54:03 +01:00
AndymickandClaude Haiku 4.5 3e90928986 Feature: Add 24-hour cleanup for incomplete orders and update status display
- Create cleanupOrders utility to delete pending orders older than 24 hours
- Update admin notifications to only count recent pending orders (< 24h old)
- Automatically call cleanup when customer initiates checkout
- Change status display from "PENDING" to "Waiting payment" for customer-facing views
- Update both customer account page and admin orders page with new status label
- Incomplete orders automatically purged, reducing admin clutter

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-19 07:50:55 +01:00
AndymickandClaude Haiku 4.5 fa202db4a7 Feature: Add admin notification system
- Create AdminNotifications server component to fetch notification counts
- Add AdminNotificationsBadge client component to display notifications
- Show badge with total count next to Admin menu in header
- Display breakdown tooltip: pending orders, design approvals, photo requests
- Graceful error handling with fallback to zero notifications
- Integrate into Header component for all pages

Also recreate missing AddressFormSection and OlderOrders components
from previous work that weren't being tracked.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-19 07:42:41 +01:00
AndymickandClaude Haiku 4.5 08038dffb1 Feature: Add quantity adjustment and fix shipping selection
- Add quantity adjustment controls (+ and -) on checkout order summary
- Prevent quantity from going below 1 with disabled minus button at qty=1
- Fix shipping selector not updating by wrapping callback in useCallback
- Shipping option changes now properly update order total
- Totals recalculate reactively when adjusting quantities or shipping

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-19 07:33:03 +01:00
Andymick 5538938020 Add: Shipping selector component and checkout integration
Added ShippingSelector component that:
- Displays country selection dropdown
- Fetches available Royal Mail shipping quotes based on cart weight
- Shows delivery estimates and international delivery warnings
- Lets customers select preferred shipping service
- Auto-selects cheapest option by default

Integrated into checkout:
- Shows shipping selector in both logged-in and guest flows
- Displays shipping cost breakdown in order summary
- Passes shipping country and service to checkout API
- Validates shipping selection before processing payment
2026-07-19 06:53:10 +01:00
Andymick df6aeb1dfe Fix: Add custom photo as editable design element instead of background
When a custom photo is provided (from photo request), automatically add it
as an editable image element on the design canvas instead of replacing
the product background. This allows the admin to:
- Move and position the photo on the product
- Resize and rotate the photo
- Add text and other design elements on top
- Edit it just like any other design element
2026-07-18 21:13:23 +01:00
Andymick 77c0fc6d0d Remove debug logging - custom photo feature working correctly 2026-07-18 21:12:17 +01:00
Andymick d1b82e9fe9 Debug: Add logging for custom photo prop 2026-07-18 21:10:34 +01:00
Andymick 8e7d242c58 Fix: Route photo requests to design canvas instead of approval upload
When admin clicks 'Start a design for this' on a photo request, now routes
to the design canvas at /made-to-order/{productSlug} with the custom photo
passed as a query parameter. The DesignCanvas component now accepts and
displays the custom photo as the background for designing.

Changes:
- Updated photo request link to go to design canvas page
- Added customPhoto query parameter to pass custom image URL
- Updated DesignCanvas to accept and use customPhoto prop
- Modified renderPhoto() to display custom photo when provided
- Updated getPhotoInfo() to use custom photo for compositing
2026-07-18 20:58:44 +01:00
Andymick 4ec39d8618 Fix: Remove function prop from client component
Remove onSuccess callback from SyncRoyalMailButton since event handlers
cannot be passed to client components from server components. The button
already shows success/error messages, so the callback wasn't necessary.
2026-07-18 20:41:16 +01:00
Andymick c476f92a66 Feature: Royal Mail tracking integration (hybrid approach)
Add ability to sync shipment tracking data from Royal Mail API:

- Create Royal Mail API service (src/lib/royalmail.ts) to fetch tracking status
- Add sync-tracking endpoint to pull latest status from Royal Mail
- Create SyncRoyalMailButton component for admin panel
- Add 'Sync from Royal Mail' button on order detail page
- Auto-update order status based on Royal Mail tracking status

Admin workflow:
1. Create shipping label in Royal Mail Click & Drop
2. Copy tracking number into tracking form
3. Click 'Sync from Royal Mail' to fetch and update status
4. System maps Royal Mail status to our order status (SHIPPED, DELIVERED, etc)

Uses Royal Mail's public tracking API - no special credentials required.
Supports manual label creation workflow (hybrid approach).
2026-07-18 20:36:40 +01:00
Andymick f4a80d2a50 Improve: Cart clearing on success page with better state management
Use useCart.getState() to ensure we're clearing the current store state
and delete IndexedDB before clearing store. Add detailed logging to help
debug cart clearing issues. Ensures cart is completely emptied on checkout
success.
2026-07-18 20:29:51 +01:00
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
AndymickandClaude Haiku 4.5 548046d4bf Capture placement preview when sending design to customer
Also capture the design composited on the product photo, so customers
see both the design preview and how it looks on the actual product.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 19:26:34 +01:00
AndymickandClaude Haiku 4.5 07b43ac53d Fix undefined params reference in send button
Use designId prop instead of undefined params variable.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 19:24:23 +01:00
AndymickandClaude Haiku 4.5 87b269e57c Capture canvas preview when admin sends design to customer
Add 'Send to Customer for Review' button to canvas that captures the
current canvas state as preview images before sending, so customers
see the modified design instead of the original submission.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 19:19:38 +01:00
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 ae09d22004 Don't persist approval status to localStorage
The approval status should only be shown temporarily after submission,
not persisted across page loads. This allows users to start fresh
designs on the same product without seeing old approval messages.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 19:06:09 +01:00
AndymickandClaude Haiku 4.5 75518e3e5e Log approvalStatus value when rendering pending message
Add console log to show the actual value of approvalStatus when the
pending approval message is displayed.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 19:00:56 +01:00
AndymickandClaude Haiku 4.5 c9a7cab349 Add logging to debug approval status clearing
Log when addText is called and whether approvalStatus is being cleared
to help debug why the old approval message persists.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 18:58:05 +01:00
AndymickandClaude Haiku 4.5 63ae432793 Clear old approval status when user starts designing new item
When user adds text or image after a previous submission, clear the old
approval status and localStorage so they can design a fresh item on the
same product without seeing the old approval message.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 18:56:41 +01:00
AndymickandClaude Haiku 4.5 f64462c5fe Add logging to check if designDraft exists in localStorage
Log whether designDraft is found when component mounts to help debug
why old designs persist after submission.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 18:54:29 +01:00
AndymickandClaude Haiku 4.5 8cba443f5a Display submission success/error message after design submission
The submissionMessage state was being set but never displayed in the UI.
Added message display to show feedback when user submits for approval.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 18:51:39 +01:00
AndymickandClaude Haiku 4.5 b61ce99157 Add debugging logs for localStorage draft removal
Added console logs to verify when the designDraft is being removed
from localStorage after successful submission, and to catch any errors.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 18:48:06 +01:00
AndymickandClaude Haiku 4.5 746179885f Reset all design state when submission succeeds
Clear not just elements but also color, size, dimensions, quantity,
and image dimensions so a fresh canvas is guaranteed after submission.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 18:46:43 +01:00
AndymickandClaude Haiku 4.5 dae1df444a Clear localStorage draft when design submitted for approval
Also remove the designDraft from localStorage when submission succeeds,
so the cleared state doesn't get reloaded when the user creates another design.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 18:44:48 +01:00
AndymickandClaude Haiku 4.5 5daa380e9d Clear design state after submission for approval
After a design is successfully submitted for approval, clear the
elementsFront and elementsBack state so users start with a blank
canvas when creating their next design.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 18:43:39 +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
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 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 95c1255811 Make image dimensions and font properties collapsible sections
- Add expandedSections state to track which sections are open
- Image Dimensions section now collapses by default (click to expand)
- Font Properties section now collapses by default (click to expand)
- Shows count of items in each section
- Dramatically reduces vertical scrolling on the right sidebar
- More compact layout with accordion-style sections

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 16:32:09 +01:00
AndymickandClaude Haiku 4.5 5efc1155b9 Reorganize design canvas layout to be more compact
- Reduce main gap from gap-8 to gap-4 for tighter vertical spacing
- Put color and size in a 2-column grid layout
- Reduce image dimension section spacing and padding
- Reduce font properties section spacing and padding
- Smaller section headings to save vertical space
- More compact overall layout

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 16:26:03 +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 74f9db6501 Remove feedback messages to simplify design canvas layout
- Remove submission status message display
- Remove approval status messages (pending/approved/rejected)
- Keep layout cleaner and more focused on design controls

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 16:23:13 +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 10764f3a5b Fix JSX syntax errors in DesignCanvas - close bracket issues
- Line 245: Added closing brace for JSX expression in Horizontal Ruler
- Line 289: Added closing brace for JSX expression in Vertical Ruler
- Line 367: Removed extra closing paren before inner ternary else clause

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 16:00:39 +01:00
AndymickandClaude Haiku 4.5 313943aeaa Commit design approval workflow and related features
- Add design approval workflow components and API routes
- Update checkout process for design approval integration
- Add admin navigation for design management
- Update mail utilities for design notifications
- Update types for design approval system
- Update Prisma schema for design approval database

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 15:42:30 +01:00
AndymickandClaude Haiku 4.5 14fa3acc7a Add dragging support to curved text with path offset
- Make TextPath draggable
- On drag end, calculate delta (dx, dy) and add to element x/y
- Reset node position to 0 after drag so path offset recalculates
- Path is regenerated with new offset on next render
- Dragging now works smoothly without positioning conflicts

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 15:42:05 +01:00
AndymickandClaude Haiku 4.5 4807a6f3c3 Fix curved text positioning - bake offsets into path data
- Modify generateCurvePath to accept offsetX/offsetY parameters
- Path data now contains positioning - center at (280 + offsetX, 280 + offsetY)
- Remove confusing x/y/offset properties from TextPath element
- TextPath now renders with position baked into path, no additional positioning
- Curved text renders correctly without interfering with images or other elements
- Curved text not currently draggable (position set at creation time)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 15:38:59 +01:00
AndymickandClaude Haiku 4.5 5a228c2b08 Add dragging support to curved text
- Add x/y positioning and offset to TextPath for proper dragging
- Make TextPath draggable with onDragEnd handler
- Curved text can now be selected, moved, and toggled without issues
- Uses offset property to handle path-based positioning correctly

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 15:33:21 +01:00
AndymickandClaude Haiku 4.5 2718004ff4 Revert grid layout and fix curved text rendering
- Revert grid layout changes - boxes now stack vertically as before
- Remove Group wrapper from curved text - was causing image disappearance
- Curved text now renders as simple TextPath with click handlers
- Text can be selected but not dragged (will add dragging back safely later)
- Images should now display correctly when curved text is enabled

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-18 15:31:54 +01:00