/** * Priority 2 Alert Banner Component * * Displays Priority 2 alerts (cost trends, pricing changes, OSS recommendations) * in a prominent banner format for the main dashboard. */ import React from 'react'; import { Alert, AlertTitle, Box, Button, IconButton, Collapse, Stack, Chip, Typography, } from '@mui/material'; import { AlertTriangle, Info, XCircle, TrendingUp, DollarSign, X, Lightbulb, } from 'lucide-react'; import { motion, AnimatePresence } from 'framer-motion'; import { Priority2Alert } from '../../hooks/usePriority2Alerts'; interface Priority2AlertBannerProps { alerts: Priority2Alert[]; onDismiss: (alertId: string) => void; maxAlerts?: number; } const Priority2AlertBanner: React.FC = ({ alerts, onDismiss, maxAlerts = 3 }) => { const [expanded, setExpanded] = React.useState(true); const [dismissedIds, setDismissedIds] = React.useState>(new Set()); // Filter out dismissed alerts const visibleAlerts = alerts.filter(alert => !dismissedIds.has(alert.id)); const displayAlerts = visibleAlerts.slice(0, maxAlerts); const remainingCount = visibleAlerts.length - maxAlerts; const getSeverityIcon = (severity: string, type: string) => { if (type === 'cost_trend') return ; if (type === 'oss_recommendation') return ; if (type === 'pricing_change') return ; switch (severity) { case 'error': return ; case 'warning': return ; default: return ; } }; const getSeverityColor = (severity: string) => { switch (severity) { case 'error': return 'error'; case 'warning': return 'warning'; default: return 'info'; } }; const handleDismiss = (alertId: string) => { setDismissedIds(prev => new Set([...prev, alertId])); onDismiss(alertId); }; if (displayAlerts.length === 0) { return null; } return ( {displayAlerts.map((alert, index) => ( {alert.action && ( )} {alert.dismissible && ( handleDismiss(alert.id)} sx={{ ml: 1 }} > )} } sx={{ mb: 2, '& .MuiAlert-icon': { alignItems: 'center' } }} > {alert.title} {alert.message} {alert.type && ( )} ))} {remainingCount > 0 && ( {remainingCount} more alert{remainingCount > 1 ? 's' : ''} available View all alerts in the{' '} )} ); }; export default Priority2AlertBanner;