From 0e14fc7981475ce328b36534186350b6a0992379 Mon Sep 17 00:00:00 2001 From: Andymick Date: Sat, 18 Jul 2026 12:26:16 +0100 Subject: [PATCH] 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 --- src/app/admin/products/[id]/edit/page.tsx | 35 +++++++++++++++++++++++ src/app/admin/products/actions.ts | 8 ++++++ src/lib/product.ts | 2 ++ src/lib/types.ts | 2 ++ 4 files changed, 47 insertions(+) diff --git a/src/app/admin/products/[id]/edit/page.tsx b/src/app/admin/products/[id]/edit/page.tsx index df138a3..a202724 100644 --- a/src/app/admin/products/[id]/edit/page.tsx +++ b/src/app/admin/products/[id]/edit/page.tsx @@ -285,6 +285,41 @@ export default async function EditProductPage({ params }: { params: { id: string +
+
+ + +

Width of garment/object for ruler reference (optional)

+
+
+ + +

Height of garment/object for ruler reference (optional)

+
+
+
String(v)); + const referenceWidthCmInput = String(formData.get('referenceWidthCm') ?? '').trim(); + const referenceHeightCmInput = String(formData.get('referenceHeightCm') ?? '').trim(); + const referenceWidthCm = referenceWidthCmInput ? Number(referenceWidthCmInput) : null; + const referenceHeightCm = referenceHeightCmInput ? Number(referenceHeightCmInput) : null; if (!id) throw new Error('Missing product id.'); if (!name || !category || !priceDollars) { @@ -228,6 +232,8 @@ export async function updateProduct(formData: FormData) { photoRecolorable: boolean; showOnPersonalised: boolean; showOnProducts: boolean; + referenceWidthCm: number | null; + referenceHeightCm: number | null; imageUrl?: string; imageUrlBack?: string; printArea?: string; @@ -247,6 +253,8 @@ export async function updateProduct(formData: FormData) { photoRecolorable, showOnPersonalised, showOnProducts, + referenceWidthCm, + referenceHeightCm, }; // Only touch the front photo/print area if a new photo was actually uploaded — diff --git a/src/lib/product.ts b/src/lib/product.ts index 9b707d7..778d614 100644 --- a/src/lib/product.ts +++ b/src/lib/product.ts @@ -21,6 +21,8 @@ export function toProductDTO(p: PrismaProduct, activePromotions: ActivePromotion printAreaBack: p.printAreaBack ? JSON.parse(p.printAreaBack) : null, printAreaWidthMm: p.printAreaWidthMm, printAreaHeightMm: p.printAreaHeightMm, + referenceWidthCm: p.referenceWidthCm, + referenceHeightCm: p.referenceHeightCm, imageUrl: p.imageUrl, imageUrlBack: p.imageUrlBack, photoRecolorable: p.photoRecolorable, diff --git a/src/lib/types.ts b/src/lib/types.ts index 8216760..9eefe24 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -45,6 +45,8 @@ export type ProductDTO = { printAreaBack: PrintArea | null; printAreaWidthMm: number; printAreaHeightMm: number; + referenceWidthCm: number | null; + referenceHeightCm: number | null; imageUrl: string | null; imageUrlBack: string | null; photoRecolorable: boolean;