diff --git a/.claude/settings.local.json b/.claude/settings.local.json index 5816419..ede0d84 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -48,7 +48,11 @@ "Bash(rm -rf craft2prints)", "Bash(git commit -m 'Add design approval workflow and per-image dimension tracking *)", "Bash(git commit -m 'Remove feedback messages to simplify design canvas layout *)", - "Bash(git commit -m 'Remove reviews section from product pages *)" + "Bash(git commit -m 'Remove reviews section from product pages *)", + "Bash(git commit -m 'Reorganize design canvas layout to be more compact *)", + "Bash(git commit -m 'Make image dimensions and font properties collapsible sections *)", + "Bash(rm -rf \"D:\\\\Craft2Prints\\\\src\\\\app\\\\api\\\\designs\\\\[id]\\\\delete\" && echo \"Deleted unnecessary delete folder\")", + "Bash(git commit -m 'Add customer approval status messages and admin delete option *)" ] } } diff --git a/src/app/admin/designs/[id]/page.tsx b/src/app/admin/designs/[id]/page.tsx index e0cb900..1f072a1 100644 --- a/src/app/admin/designs/[id]/page.tsx +++ b/src/app/admin/designs/[id]/page.tsx @@ -1,6 +1,7 @@ 'use client'; import { useState, useEffect } from 'react'; +import { useRouter } from 'next/navigation'; import Link from 'next/link'; import DesignApprovalChat from '@/components/DesignApprovalChat'; import AdminDesignEditor from '@/components/AdminDesignEditor'; @@ -28,9 +29,11 @@ interface DesignApproval { } export default function DesignDetailPage({ params }: { params: { id: string } }) { + const router = useRouter(); const [design, setDesign] = useState(null); const [loading, setLoading] = useState(true); const [approving, setApproving] = useState(false); + const [deleting, setDeleting] = useState(false); const [editingDesign, setEditingDesign] = useState(false); useEffect(() => { @@ -56,6 +59,22 @@ export default function DesignDetailPage({ params }: { params: { id: string } }) } }; + const handleDelete = async () => { + if (!confirm('Are you sure you want to delete this design? This cannot be undone.')) return; + + setDeleting(true); + try { + const res = await fetch(`/api/designs/${params.id}`, { method: 'DELETE' }); + if (res.ok) { + router.push('/admin/designs'); + } else { + alert('Failed to delete design'); + } + } finally { + setDeleting(false); + } + }; + const handleEditorSave = (designJson: string, previewUrl: string) => { setDesign((prev) => prev @@ -202,6 +221,15 @@ export default function DesignDetailPage({ params }: { params: { id: string } }) )} +
+ +
{/* Chat */} diff --git a/src/app/api/designs/[id]/route.ts b/src/app/api/designs/[id]/route.ts index 4289b9c..c16b49f 100644 --- a/src/app/api/designs/[id]/route.ts +++ b/src/app/api/designs/[id]/route.ts @@ -1,5 +1,6 @@ import { NextResponse } from 'next/server'; import { prisma } from '@/lib/prisma'; +import { getCurrentAdmin } from '@/lib/auth'; export async function GET( req: Request, @@ -24,3 +25,33 @@ export async function GET( ); } } + +export async function DELETE( + req: Request, + { params }: { params: { id: string } } +) { + try { + const admin = await getCurrentAdmin(); + if (!admin) { + return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); + } + + // Delete associated messages first + await prisma.designApprovalMessage.deleteMany({ + where: { designApprovalId: params.id }, + }); + + // Delete the design approval + await prisma.designApproval.delete({ + where: { id: params.id }, + }); + + return NextResponse.json({ success: true }); + } catch (err) { + console.error('Error deleting design:', err); + return NextResponse.json( + { error: 'Failed to delete design' }, + { status: 500 } + ); + } +} diff --git a/src/components/DesignCanvas.tsx b/src/components/DesignCanvas.tsx index 0eac906..3632957 100644 --- a/src/components/DesignCanvas.tsx +++ b/src/components/DesignCanvas.tsx @@ -1125,6 +1125,22 @@ export default function DesignCanvas({ product }: { product: ProductDTO }) { + {approvalStatus === 'PENDING' && ( +

+ ⏳ Your design is pending admin approval. You'll receive an email when it's ready to add to your bag. +

+ )} + {approvalStatus === 'APPROVED' && ( +

+ ✓ Your design has been approved! You can now add it to your bag. +

+ )} + {approvalStatus === 'REJECTED' && ( +

+ Your design needs changes. Check your messages for feedback. +

+ )} +

Color