Add customer approval status messages and admin delete option
Customer-facing changes: - Show approval status message when design is submitted - Display pending approval notification with email confirmation - Show approved confirmation when design is ready - Show rejection message for designs needing changes Admin-facing changes: - Add delete button to design approval detail page - Confirmation dialog before deletion - Proper cleanup of design and associated messages - Redirect to designs list after deletion Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Haiku 4.5
parent
95c1255811
commit
4d124b1550
@@ -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 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user