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:
Andymick
2026-07-18 16:48:35 +01:00
co-authored by Claude Haiku 4.5
parent 95c1255811
commit 4d124b1550
4 changed files with 80 additions and 1 deletions
+28
View File
@@ -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<DesignApproval | null>(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 } })
</button>
</div>
)}
<div className="mt-4 pt-4 border-t border-line">
<button
onClick={handleDelete}
disabled={deleting}
className="w-full bg-red-600 px-4 py-2 text-sm font-medium text-paper hover:bg-red-700 disabled:opacity-60"
>
{deleting ? 'Deleting…' : 'Delete Design'}
</button>
</div>
</div>
{/* Chat */}