import React, { useMemo } from 'react'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from './ui/card'; import { Badge } from './ui/badge'; import { Button } from './ui/button'; import { Progress } from './ui/progress'; import { Avatar, AvatarFallback, AvatarImage } from './ui/avatar'; import { FileText, Clock, AlertTriangle, TrendingUp, CheckCircle, Users, Zap, Shield, ArrowRight, Bell, Star, Activity, Calendar, Target, Flame, Settings } from 'lucide-react'; interface DashboardProps { onNavigate?: (page: string) => void; onNewRequest?: () => void; } // Static data to prevent re-creation on each render const STATS_DATA = [ { title: 'Open Requests', value: '24', description: '+3 from last week', icon: FileText, trend: 'up', color: 'text-emerald-600', bgColor: 'bg-emerald-50', change: '+12.5%' }, { title: 'Avg. SLA Compliance', value: '87%', description: '+5% from last month', icon: Target, trend: 'up', color: 'text-blue-600', bgColor: 'bg-blue-50', change: '+5.8%' }, { title: 'High Priority Alerts', value: '5', description: 'Requires immediate attention', icon: Flame, trend: 'neutral', color: 'text-red-600', bgColor: 'bg-red-50', change: '-2' }, { title: 'Approved This Month', value: '142', description: '+12% from last month', icon: CheckCircle, trend: 'up', color: 'text-green-600', bgColor: 'bg-green-50', change: '+18.2%' } ]; const RECENT_ACTIVITY = [ { id: 'RE-REQ-024', title: 'Marketing Campaign Approval', user: 'Sarah Chen', action: 'approved', time: '2 minutes ago', avatar: 'SC', priority: 'high' }, { id: 'RE-REQ-023', title: 'Budget Allocation Request', user: 'Mike Johnson', action: 'commented', time: '15 minutes ago', avatar: 'MJ', priority: 'medium' }, { id: 'RE-REQ-022', title: 'Vendor Contract Review', user: 'David Kumar', action: 'submitted', time: '1 hour ago', avatar: 'DK', priority: 'low' }, { id: 'RE-REQ-021', title: 'IT Equipment Purchase', user: 'Lisa Wong', action: 'escalated', time: '2 hours ago', avatar: 'LW', priority: 'high' }, { id: 'RE-REQ-020', title: 'Office Space Lease', user: 'John Doe', action: 'rejected', time: '3 hours ago', avatar: 'JD', priority: 'medium' } ]; const HIGH_PRIORITY_REQUESTS = [ { id: 'RE-REQ-001', title: 'Emergency Equipment Purchase', sla: '2 hours left', progress: 85 }, { id: 'RE-REQ-005', title: 'Critical Vendor Agreement', sla: '4 hours left', progress: 60 }, { id: 'RE-REQ-012', title: 'Urgent Marketing Approval', sla: '6 hours left', progress: 40 } ]; // Utility functions outside component const getActionColor = (action: string) => { switch (action) { case 'approved': return 'text-emerald-700 bg-emerald-100 border-emerald-200'; case 'rejected': return 'text-red-700 bg-red-100 border-red-200'; case 'commented': return 'text-blue-700 bg-blue-100 border-blue-200'; case 'escalated': return 'text-orange-700 bg-orange-100 border-orange-200'; case 'submitted': return 'text-purple-700 bg-purple-100 border-purple-200'; default: return 'text-gray-700 bg-gray-100 border-gray-200'; } }; const getPriorityColor = (priority: string) => { switch (priority) { case 'high': return 'bg-red-100 text-red-800 border-red-200'; case 'medium': return 'bg-orange-100 text-orange-800 border-orange-200'; case 'low': return 'bg-green-100 text-green-800 border-green-200'; default: return 'bg-gray-100 text-gray-800 border-gray-200'; } }; export function Dashboard({ onNavigate, onNewRequest }: DashboardProps) { // Memoize quick actions to prevent recreation on each render const quickActions = useMemo(() => [ { label: 'New Request', icon: FileText, action: () => onNewRequest?.(), color: 'bg-emerald-600 hover:bg-emerald-700' }, { label: 'View Pending', icon: Clock, action: () => onNavigate?.('open-requests'), color: 'bg-blue-600 hover:bg-blue-700' }, { label: 'Reports', icon: Activity, action: () => {}, color: 'bg-purple-600 hover:bg-purple-700' }, { label: 'Settings', icon: Settings, action: () => {}, color: 'bg-slate-600 hover:bg-slate-700' } ], [onNavigate, onNewRequest]); return (
{/* Hero Section with Clear Background */}

Welcome to Royal Enfield Portal

Rev up your workflow with streamlined approvals

{quickActions.map((action, index) => ( ))}
{/* Decorative Elements */}
{/* Stats Cards with Better Contrast */}
{STATS_DATA.map((stat, index) => ( {stat.title}
{stat.value}
{stat.trend === 'up' && (
{stat.change}
)}

{stat.description}

))}
{/* High Priority Alerts */}
Critical Alerts Urgent attention required
{HIGH_PRIORITY_REQUESTS.length}
{HIGH_PRIORITY_REQUESTS.map((request) => (

{request.id}

{request.title}

{request.sla}
Progress {request.progress}%
))}
{/* Recent Activity */}
Recent Activity Latest updates across all requests
{RECENT_ACTIVITY.map((activity) => (
{activity.avatar}
{activity.action === 'approved' && } {activity.action === 'rejected' && } {activity.action === 'commented' && } {activity.action === 'escalated' && } {activity.action === 'submitted' && }
{activity.id} {activity.action} {activity.priority}

{activity.title}

by {activity.user} • {activity.time}

))}
); }