diff --git a/src/app/admin/products/[id]/edit/page.tsx b/src/app/admin/products/[id]/edit/page.tsx
index 0e3327b..098b06e 100644
--- a/src/app/admin/products/[id]/edit/page.tsx
+++ b/src/app/admin/products/[id]/edit/page.tsx
@@ -266,7 +266,7 @@ export default async function EditProductPage({ params }: { params: { id: string
Current photo. Upload a new one below to replace it.
)}
-
+
@@ -281,7 +281,7 @@ export default async function EditProductPage({ params }: { params: { id: string
Current back photo and print area. Upload a new one below to replace both.
)}
-
+
diff --git a/src/components/PhotoPrintAreaField.tsx b/src/components/PhotoPrintAreaField.tsx
index 71c9c10..b355eae 100644
--- a/src/components/PhotoPrintAreaField.tsx
+++ b/src/components/PhotoPrintAreaField.tsx
@@ -7,7 +7,13 @@ type Box = { xPct: number; yPct: number; wPct: number; hPct: number }; // 0-100
const DEFAULT_BOX: Box = { xPct: 30, yPct: 25, wPct: 40, hPct: 35 };
const MIN_SIZE = 6; // percent
-export default function PhotoPrintAreaField({ variant = 'front' }: { variant?: 'front' | 'back' }) {
+export default function PhotoPrintAreaField({
+ variant = 'front',
+ existingImageUrl,
+}: {
+ variant?: 'front' | 'back';
+ existingImageUrl?: string;
+}) {
const [previewUrl, setPreviewUrl] = useState
(null);
const [box, setBox] = useState(DEFAULT_BOX);
const [showPrintAreaEditor, setShowPrintAreaEditor] = useState(false);
@@ -47,6 +53,8 @@ export default function PhotoPrintAreaField({ variant = 'front' }: { variant?: '
setShowPrintAreaEditor(false);
};
+ const currentImageUrl = previewUrl || existingImageUrl;
+
const onBoxMouseDown = (e: React.MouseEvent) => {
e.preventDefault();
dragState.current = { mode: 'move', startX: e.clientX, startY: e.clientY, startBox: box };
@@ -89,7 +97,7 @@ export default function PhotoPrintAreaField({ variant = 'front' }: { variant?: '
return (
- {!previewUrl || !showPrintAreaEditor ? (
+ {!currentImageUrl || !showPrintAreaEditor ? (
<>
)}
- {previewUrl && !showPrintAreaEditor && (
+ {currentImageUrl && !showPrintAreaEditor && (
) : null}
- {previewUrl && showPrintAreaEditor && (
+ {currentImageUrl && showPrintAreaEditor && (
Drag the box to mark the print area
@@ -158,7 +166,7 @@ export default function PhotoPrintAreaField({ variant = 'front' }: { variant?: '
>
{/* eslint-disable-next-line @next/next/no-img-element */}

)}
-
+