Feature: Add admin notification system
- Create AdminNotifications server component to fetch notification counts - Add AdminNotificationsBadge client component to display notifications - Show badge with total count next to Admin menu in header - Display breakdown tooltip: pending orders, design approvals, photo requests - Graceful error handling with fallback to zero notifications - Integrate into Header component for all pages Also recreate missing AddressFormSection and OlderOrders components from previous work that weren't being tracked. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Haiku 4.5
parent
08038dffb1
commit
fa202db4a7
@@ -0,0 +1,36 @@
|
||||
import { prisma } from '@/lib/prisma';
|
||||
import AdminNotificationsBadge from './AdminNotificationsBadge';
|
||||
|
||||
export default async function AdminNotifications() {
|
||||
try {
|
||||
const [
|
||||
pendingOrders,
|
||||
designApprovalsInReview,
|
||||
photoRequests,
|
||||
] = await Promise.all([
|
||||
prisma.order.count({
|
||||
where: { status: 'PENDING' },
|
||||
}),
|
||||
prisma.designApproval.count({
|
||||
where: { status: 'IN_REVIEW' },
|
||||
}),
|
||||
prisma.customRequest.count({
|
||||
where: { status: 'PENDING' },
|
||||
}),
|
||||
]);
|
||||
|
||||
const totalNotifications = pendingOrders + designApprovalsInReview + photoRequests;
|
||||
|
||||
return (
|
||||
<AdminNotificationsBadge
|
||||
total={totalNotifications}
|
||||
pendingOrders={pendingOrders}
|
||||
designApprovals={designApprovalsInReview}
|
||||
photoRequests={photoRequests}
|
||||
/>
|
||||
);
|
||||
} catch (err) {
|
||||
console.error('Error fetching admin notifications:', err);
|
||||
return <AdminNotificationsBadge total={0} pendingOrders={0} designApprovals={0} photoRequests={0} />;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user