import Alert from '@/components/Alert'; import Card from '@/components/Card'; import { formatNumber } from '@/lib/helper'; import { DashboardStatisticsData } from '@/types/api/dashboard/dashboard'; import { Icon } from '@iconify/react'; interface DashboardStatsProps { data: DashboardStatisticsData[]; } // Konfigurasi untuk setiap kartu const CARD_CONFIG = [ { key: 'HPP Global', icon: 'heroicons:banknotes', alertColor: 'warning' as const, suffix: ' /Kg', prefix: 'RP ', }, { key: 'Avg. Selling Price', icon: 'heroicons:document-currency-dollar', alertColor: 'success' as const, suffix: ' /Kg Telur', prefix: '', }, { key: 'FCR', icon: 'heroicons:clipboard-document-list', alertColor: 'info' as const, suffix: '', prefix: '', }, { key: 'Mortality', icon: 'heroicons:exclamation-triangle', alertColor: 'error' as const, suffix: ' %', prefix: '', }, ]; const DashboardStats = ({ data }: DashboardStatsProps) => { // Helper to get trend icon and color const getTrendDisplay = (percent: number) => { const isPositive = percent >= 0; return { icon: isPositive ? 'heroicons:arrow-trending-up' : 'heroicons:arrow-trending-down', color: isPositive ? 'text-[#008000]' : 'text-[#FF3A3A]', value: Math.abs(percent), }; }; // Helper to format value const formatValue = (value: number, prefix: string, suffix: string) => { return ( <> {prefix} {formatNumber(value)} {suffix && ( {suffix} )} > ); }; return (
********
{formatValue(cardData.value, config.prefix, config.suffix)}