From 4d9cfa40238a2851589815c8f0d85ffe673025c6 Mon Sep 17 00:00:00 2001 From: Andymick Date: Sat, 18 Jul 2026 10:29:37 +0100 Subject: [PATCH] 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 --- .../migration.sql | 3 + prisma/schema.prisma | 2 + src/app/admin/orders/[id]/page.tsx | 6 + src/app/api/orders/[id]/design-spec/route.ts | 258 ++++++++++++++++++ 4 files changed, 269 insertions(+) create mode 100644 prisma/migrations/20260718092854_add_product_dimensions/migration.sql create mode 100644 src/app/api/orders/[id]/design-spec/route.ts diff --git a/prisma/migrations/20260718092854_add_product_dimensions/migration.sql b/prisma/migrations/20260718092854_add_product_dimensions/migration.sql new file mode 100644 index 0000000..0afa805 --- /dev/null +++ b/prisma/migrations/20260718092854_add_product_dimensions/migration.sql @@ -0,0 +1,3 @@ +-- AlterTable +ALTER TABLE "Product" ADD COLUMN "printAreaHeightMm" INTEGER NOT NULL DEFAULT 280, +ADD COLUMN "printAreaWidthMm" INTEGER NOT NULL DEFAULT 200; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 94ecab1..c6bbb32 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -37,6 +37,8 @@ model Product { mockup String // which SVG mockup component to render, e.g. "tshirt" | "hoodie" | "mug" | "phonecase" printArea String // JSON: {"xPct":..,"yPct":..,"wPct":..,"hPct":..} printAreaBack String? // same shape, for the back print area — only used when imageUrlBack is set + printAreaWidthMm Int @default(200) // width of the printable area in millimeters + printAreaHeightMm Int @default(280) // height of the printable area in millimeters imageUrl String? // optional real product photo — shown instead of the illustration when set imageUrlBack String? // optional back-view photo, toggled alongside the front photo photoRecolorable Boolean @default(false) // if true, the photo is treated as a grayscale diff --git a/src/app/admin/orders/[id]/page.tsx b/src/app/admin/orders/[id]/page.tsx index 201b5f3..c2100d6 100644 --- a/src/app/admin/orders/[id]/page.tsx +++ b/src/app/admin/orders/[id]/page.tsx @@ -23,6 +23,12 @@ export default async function OrderDetailPage({ params }: { params: { id: string

Order

{order.archived && Archived} + + ↓ Download specs +