Design Canvas (Primary) - FabricDesignCanvasV2: Fabric.js-based product customization canvas - Lazy-loads Fabric.js to minimize bundle impact - Renders product mockup with print area guide (magenta dashed box) - Supports front/back view switching with correct product images - Color swatch selection for garment customization - Text element creation with selection handles and transform controls - Fixed React dependency array to prevent infinite renders Support Components - DesignCanvasWrapper: Client-side wrapper for SSR compatibility - DesignCanvasErrorBoundary: Error boundary for canvas failures - ThemeInitializer: Theme detection and application Configuration - Updated .claude/launch.json with dev server settings - Updated .claude/settings.local.json with local preferences - Updated next.config.mjs for production build optimization - Dependency updates in package.json and package-lock.json Known Issues & TODO - Image element rendering disabled (Fabric.js compatibility investigation) - Text editing UI controls needed (font, size, color pickers) - Delete/undo functionality pending - Print area alignment needs visual verification - "Add to Cart" integration with design serialization pending Testing Artifacts - check_*.js: Product verification scripts for debugging Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
52 lines
1.8 KiB
TypeScript
52 lines
1.8 KiB
TypeScript
import { NextResponse } from 'next/server';
|
|
import { prisma } from '@/lib/prisma';
|
|
import { sendDesignReadyForReview } from '@/lib/mail';
|
|
|
|
export async function POST(
|
|
req: Request,
|
|
{ params }: { params: Promise<{ id: string }> }
|
|
) {
|
|
try {
|
|
const { id } = await params;
|
|
const { designPreviewUrl, designPreviewUrlBack, placementPreviewUrl, placementPreviewUrlBack } = await req.json().catch(() => ({}));
|
|
|
|
const design = await prisma.designApproval.findUnique({
|
|
where: { id: id },
|
|
include: { product: true },
|
|
});
|
|
|
|
if (!design) {
|
|
return NextResponse.json({ error: 'Design not found' }, { status: 404 });
|
|
}
|
|
|
|
// Update status to IN_REVIEW and save new preview if provided
|
|
const updateData: any = { status: 'IN_REVIEW' };
|
|
if (designPreviewUrl) updateData.designPreviewUrl = designPreviewUrl;
|
|
if (designPreviewUrlBack) updateData.designPreviewUrlBack = designPreviewUrlBack;
|
|
if (placementPreviewUrl) updateData.placementPreviewUrl = placementPreviewUrl;
|
|
if (placementPreviewUrlBack) updateData.placementPreviewUrlBack = placementPreviewUrlBack;
|
|
|
|
const updated = await prisma.designApproval.update({
|
|
where: { id: id },
|
|
data: updateData,
|
|
include: { product: true, messages: { orderBy: { createdAt: 'asc' } } },
|
|
});
|
|
|
|
// Send email to customer
|
|
await sendDesignReadyForReview({
|
|
customerName: design.customerName || 'Customer',
|
|
customerEmail: design.customerEmail,
|
|
productName: design.product.name,
|
|
reviewLink: `${process.env.NEXT_PUBLIC_SITE_URL || 'http://localhost:3000'}/designs/${id}/review`,
|
|
});
|
|
|
|
return NextResponse.json(updated);
|
|
} catch (err) {
|
|
console.error('Error sending design to customer:', err);
|
|
return NextResponse.json(
|
|
{ error: 'Failed to send design' },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|