import React from 'react'; import { AlertCircle, Clock, FileWarning, Wallet, CheckCircle, AlertTriangle, ChevronRight } from 'lucide-react'; import { SpotlightCard } from '../SpotlightCard'; import { useMockStore } from '../../data/mockStore'; const UrgentItemsPanel = ({ onActionClick, ownerId }) => { const { documents, vendors, projects } = useMockStore(); // Filter projects by owner when provided const ownerProjects = ownerId ? projects.filter(p => p.ownerId === ownerId) : projects; // Logic to find urgent items const expiringDocs = documents.filter(d => { if (!d.expirationDate) return false; const expDate = new Date(d.expirationDate); const today = new Date(); const diffTime = Math.abs(expDate - today); const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)); return diffDays <= 30 && d.status !== 'expired'; }); const nonCompliantVendors = vendors.filter(v => v.compliance.w9.status !== 'approved' || v.compliance.coi.status === 'expired' ); const pendingInvoices = ownerProjects.flatMap(p => (p.invoices || []).filter(i => i.status === 'pending') ); const urgentItems = [ { id: 'docs', title: 'Expiring Documents', count: expiringDocs.length, icon: Clock, color: 'text-amber-400', bg: 'bg-amber-400/10', border: 'border-amber-400/20', message: `${expiringDocs.length} compliance documents expiring soon.`, }, { id: 'vendors', title: 'Non-Compliant Vendors', count: nonCompliantVendors.length, icon: FileWarning, color: 'text-red-400', bg: 'bg-red-400/10', border: 'border-red-400/20', message: `${nonCompliantVendors.length} vendors missing critical paperwork.`, }, { id: 'invoices', title: 'Pending Invoices', count: pendingInvoices.length, icon: Wallet, color: 'text-blue-400', bg: 'bg-blue-400/10', border: 'border-blue-400/20', message: `${pendingInvoices.length} invoices awaiting approval.`, } ]; if (urgentItems.every(item => item.count === 0)) { return ( All Caught Up! No urgent items requiring attention right now. ); } return ( Action Center Items requiring your immediate attention {urgentItems.reduce((acc, item) => acc + item.count, 0)} Pending {urgentItems.map((item) => ( item.count > 0 && ( {item.title} {item.count} {item.message} onActionClick && onActionClick(item.id)} className="whitespace-nowrap px-4 py-2 text-xs font-bold uppercase tracking-wider rounded-lg bg-white dark:bg-white/5 text-zinc-700 dark:text-zinc-300 border border-zinc-200 dark:border-white/10 hover:bg-zinc-50 dark:hover:bg-white/10 hover:text-amber-600 dark:hover:text-amber-400 hover:border-amber-200 dark:hover:border-amber-500/30 transition-all shadow-sm" > Review Items ) ))} {/* Footer Action */} onActionClick && onActionClick('all')} className="w-full py-2.5 rounded-xl text-xs font-bold uppercase tracking-widest text-zinc-500 hover:text-zinc-900 dark:text-zinc-400 dark:hover:text-white transition-colors flex items-center justify-center gap-2 hover:bg-zinc-100 dark:hover:bg-white/5" > View All Compliance Tasks ); }; export default UrgentItemsPanel;
No urgent items requiring attention right now.
Items requiring your immediate attention
{item.message}