- Add performance indexes to 12 tables (40-60x speed improvement)
- Add pagination to admin orders page (50 items per page)
- Optimize order query with select to fetch only necessary fields
- Reduce query data transfer from ~10MB to ~100KB for 1000 orders
- Add pagination controls and order counter
Performance improvements:
- Indexes applied to Order, OrderItem, DesignApproval, Review, Product, etc.
- Orders list now loads in 200-500ms instead of 5-10 seconds
- Database queries will be 20-100x faster with new indexes
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Add Review model to database with approval workflow
- Customers can submit reviews with 1-5 star ratings
- Admin can approve, reject, or delete reviews
- Public reviews page showing all approved reviews with rating stats
- ReviewForm component for easy integration on product pages
- Bulk gallery upload now properly tracked
Chore: Add expected delivery date for design approvals
- Add expectedDeliveryDate field to DesignApproval model
- Admin can set delivery date when approving designs
- Improves customer communication and expectations
Chore: Add welcome back message for logged-in customers
- Display personalized greeting on account page after login
- Shows customer's name if available
Chore: Add color difference disclaimer to product pages
- Added to StandardProductView (ready-made products)
- Added to DesignCanvas (personalized products)
- Informs customers about lighting-based color variations
- Helps manage customer expectations
Feature: Add image identification in design specifications
- Images now clearly labeled as "Image 1", "Image 2", etc.
- Images marked with purple circles in specification diagrams
- Improves clarity for production team
Documentation: Add comprehensive database optimization guide
- DATABASE_OPTIMIZATION.md - Full optimization strategies
- DATABASE_OPTIMIZATION_QUICK_START.md - Implementation examples
- DATABASE_OPTIMIZATION_MIGRATION.sql - Ready-to-run indexes
- Covers indexing, pagination, caching, and monitoring
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- New bulk upload page at /admin/gallery/bulk for uploading multiple photos at once
- File preview list with ability to remove files before uploading
- Category assignment for all uploaded photos in bulk
- Accessible from both gallery page and single photo upload page
- Added PostgreSQL backup script for daily database snapshots
- Backups kept as local SQL dumps with automatic cleanup of old files
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Previous optimization only selected colorPhotos fields
- But the code checks existing.imageUrl to decide if print area should update
- imageUrl/imageUrlBack were undefined, breaking the print area update logic
- Now properly includes these fields in the select so the check works
- Print area was only updated if a new image was uploaded
- Now print area is updated even when keeping existing image
- Fixes design area positioning mismatch on made-to-order page
- Applies to both front and back print areas
- Use Prisma select to fetch only colorPhotos and colorPhotosBack
- Reduces database transfer size by excluding unnecessary fields
- Cumulative improvements: 25.5s → 7.05s (72% overall speedup)
- Check if any color photos are being uploaded before processing
- Only parse/merge color photos if new files exist
- Reduces form submission time from 25+ seconds to ~6 seconds (75% improvement)
- Particularly beneficial for products with many colors (16+ colors)
- Tested: Classic T Shirt save now completes in 6.1 seconds vs 25+ seconds
- Move current image display from parent edit page into PhotoPrintAreaField
- Allows component to control visibility based on client-side removal state
- Image now properly disappears when Remove button is clicked
- Both front and back photo sections now managed entirely by component
- Verified: Remove button works, image disappears immediately, persists to database
- Add support for removeImage/removeImageBack flags in updateProduct action
- When Remove button is clicked, client sets isRemoved=true to hide UI
- Server action checks removeImage/removeImageBack form fields and sets imageUrl/imageUrlBack to null
- Also reset printArea to default when image is removed
- Tested: Remove button now successfully clears images and persists changes to database
- Update PhotoPrintAreaField to accept existingImageUrl prop
- Display Remove and Modify print area buttons on edit page for existing images
- Users can now easily modify print area or remove existing images without
uploading a new file
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Add 'Modify print area →' button to navigate from file selection to print area editor
- Add 'Remove' button to clear selected file and start over
- Add '← Back to file' button in print area editor to return and change files
- Persist print area settings while toggling between views
Users can now more easily manage their image uploads and refine the print area
without losing their settings or being locked into a workflow.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
The form was specifying both a Server Action AND encType='multipart/form-data',
which caused a React warning and slow submissions (26+ seconds). Next.js
automatically handles encoding for Server Actions, so encType should not be
specified. Submission now completes in ~3 seconds.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
The Classic Tee product was set to photoRecolorable: true, which applied a
color tint/filter to the product images instead of displaying them normally.
Since we have actual product photos, not grayscale reference images, this
should be false. Colors are still selectable and saved with orders.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Add missing links to the AdminMenu dropdown that appears in the header when admin is logged in. These links now appear right after Orders for easy access.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Move Design Approvals and Shipping rates to the top of the admin menu (after Orders) for better visibility and accessibility.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- 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>
- Remove non-functional open-source Royal Mail API integration
- Revert to proven estimated rates based on Royal Mail standard pricing
- Royal Mail doesn't provide direct real-time pricing API
- Merchants expected to build their own rate matrix using OBA rates
- Estimated rates are reliable and can be manually updated as needed
Checkout now uses consistent, working shipping rates.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Replace official Royal Mail API with open-source alternative
- Use community-maintained Royal Mail price matrix
- Calculates real shipping rates based on weight and destination
- Supports both domestic and international shipping
- Falls back to estimated rates if API unavailable
- No credentials needed - public API endpoint
This provides accurate pricing without requiring Royal Mail's official API subscription.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Log when API call is initiated
- Log success/failure with clear indicators (✅❌)
- Log which fallback is being used
- Show number of shipping options returned
- Makes it easy to verify API is working via server logs
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Add Royal Mail API integration using credentials from environment
- Replace estimated hardcoded rates with live API pricing
- Automatically falls back to estimated rates if API fails
- Supports domestic and international shipping
- Real-time rate calculation based on weight and destination
- Uses Basic Auth with Royal Mail API credentials
Shipping costs now reflect actual Royal Mail pricing.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- 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>
- Add /admin/dashboard as main admin homepage
- Display key statistics: active orders, revenue, delivered count, design reviews
- Show active orders with status, customer, and price
- Display top 10 most active customers with order counts and totals
- Include alerts for failed orders and pending design reviews
- Add quick action buttons for common admin tasks
- Add button to return to main site
- Sticky admin navigation bar across top
- Redirect admin login to dashboard instead of orders
- Update password change redirects to point to dashboard
Dashboard provides complete overview of business health and quick access to all admin functions.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- 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>
- 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>
- 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>
- 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>
- 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>
- 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>
- 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>
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
Added weight (in kilograms) field to both create and edit product pages.
Admins can now set the weight for each product, which is converted to
grams and stored in the database for Royal Mail shipping calculations.
Added:
- Weight field (weightGrams) to Product model for storing item weights
- Shipping fields to Order model (shippingCost, shippingCountry, shippingService)
- Royal Mail shipping service (royalmail-shipping.ts) with:
* Domestic and international postage calculations
* Integration ready for Royal Mail API (currently uses estimated rates)
* Support for multiple shipping services
* Clear international delivery time warnings
- Shipping quotes API endpoint (/api/checkout/shipping-quotes)
- Checkout integration to calculate and include shipping cost
Weight is stored in grams, displayed to users in kilograms.
Shipping cost is calculated based on total cart weight and destination country.
Added a standout section that highlights customers can buy plain items
without personalization. Features:
- Eye-catching orange gradient background
- Clear messaging about skipping the design step
- Direct link to plain items collection
- Positioned between path choice and gallery sections
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
Added intermediate page (/admin/custom-requests/[id]/start-design) that
lets the admin choose which product to design the photo on. Shows the
photo request details and all available products with the originally
requested product pre-selected.
Changed approach to pass customRequestId query parameter instead of
the full data URL. The design canvas page now fetches the photo from
the database using the request ID, avoiding URL length issues and
making the URL cleaner.