@props(['stats' => []]) @php $stats = is_array($stats) ? $stats : []; @endphp
@forelse($stats as $stat) @php $label = $stat['label'] ?? ''; $value = $stat['value'] ?? ''; $trend = $stat['trend'] ?? null; $trendLabel = $stat['trend_label'] ?? ''; $icon = $stat['icon'] ?? ''; $color = $stat['color'] ?? 'primary'; $format = $stat['format'] ?? 'raw'; $colorMap = [ 'primary' => 'bg-primary-50 dark:bg-primary-900/20 text-primary-600 dark:text-primary-400', 'success' => 'bg-green-50 dark:bg-green-900/20 text-green-600 dark:text-green-400', 'warning' => 'bg-amber-50 dark:bg-amber-900/20 text-amber-600 dark:text-amber-400', 'danger' => 'bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400', ]; $iconBg = $colorMap[$color] ?? $colorMap['primary']; $displayValue = $value; if ($format === 'currency') { $displayValue = 'GHS ' . number_format((float) $value, 2); } elseif ($format === 'percentage') { $displayValue = number_format((float) $value, 1) . '%'; } @endphp

{{ $label }}

{{ $displayValue }}

@if($trend !== null)
@if($trend > 0) +{{ $trend }}% @elseif($trend < 0) {{ $trend }}% @endif @if($trendLabel) {{ $trendLabel }} @endif
@endif
@if($icon)
{{ $icon }}
@endif
@empty {{-- Render nothing if no stats provided --}} @endforelse