import { Box, Typography, Skeleton } from '@mui/material' import { AlertOctagon, Calendar, CalendarDays, Eye } from 'lucide-react' import { useShallow } from 'zustand/react/shallow' import { useReminderInsights } from '../../hooks/useReminders' import { useReminderStore } from '../../stores/reminderStore' import type { FilterHorizon } from '../../stores/reminderStore' import { ReminderType } from '../../domain/reminder' interface KpiCardProps { icon: React.ReactNode label: string value: number | string color: string active: boolean onClick: () => void } function KpiCard({ icon, label, value, color, active, onClick }: KpiCardProps) { return ( {icon} {value} {label} ) } export function ReminderKpiBar() { const { data, isLoading } = useReminderInsights() const { filterHorizon, setFilterHorizon, filterType, setFilterType } = useReminderStore( useShallow(s => ({ filterHorizon: s.filterHorizon, setFilterHorizon: s.setFilterHorizon, filterType: s.filterType, setFilterType: s.setFilterType, })) ) function toggleHorizon(h: FilterHorizon) { if (filterHorizon === h) { setFilterHorizon('ALL') } else { setFilterHorizon(h) setFilterType('ALL') // clear type filter so count matches } } function togglePreMarket() { if (filterType === ReminderType.SCHATTENMARKT_RELEASE) { setFilterType('ALL') } else { setFilterType(ReminderType.SCHATTENMARKT_RELEASE) setFilterHorizon('ALL') // clear horizon filter so count matches } } if (isLoading) { return ( {[1, 2, 3, 4].map(i => ( ))} ) } const ins = data ?? { overdueCount: 0, dueThisWeek: 0, dueThisMonth: 0, schattenmarktReadyCount: 0 } return ( } label="Überfällig" value={ins.overdueCount} color="#dc2626" active={filterHorizon === 'OVERDUE'} onClick={() => toggleHorizon('OVERDUE')} /> } label="Diese Woche" value={ins.dueThisWeek} color="#ea580c" active={filterHorizon === 'THIS_WEEK'} onClick={() => toggleHorizon('THIS_WEEK')} /> } label="Dieser Monat" value={ins.dueThisMonth} color="#0369a1" active={filterHorizon === 'THIS_MONTH'} onClick={() => toggleHorizon('THIS_MONTH')} /> } label="Pre-Market Risiko" value={ins.schattenmarktReadyCount} color="#be185d" active={filterType === ReminderType.SCHATTENMARKT_RELEASE} onClick={togglePreMarket} /> ) }