'use client';

import {Grid} from '@astryxdesign/core/Grid';
import {MetricCard} from '@/shared/components/patterns/MetricCard';
import {ICONS} from '@/shared/utils/icons';
import {formatCount, formatInrCompact, formatPct} from '@/shared/utils/format';

export function CommerceKpiRow() {
  const kpiList = [
    {
      label: 'Total Revenue',
      value: 340000,
      format: formatInrCompact,
      icon: ICONS.revenue,
      deltaPct: 14.2,
    },
    {
      label: 'Total Orders',
      value: 1284,
      format: formatCount,
      icon: ICONS.purchases,
      deltaPct: 8.5,
    },
    {
      label: 'Avg Order Value',
      value: 1420,
      format: formatInrCompact,
      icon: ICONS.purchases,
      deltaPct: 5.1,
    },
    {
      label: 'Net Sales',
      value: 318000,
      format: formatInrCompact,
      icon: ICONS.revenue,
      deltaPct: 13.9,
    },
    {
      label: 'Refunds',
      value: 22000,
      format: formatInrCompact,
      icon: ICONS.alert,
      deltaPct: -2.4,
      isRiseGood: false,
    },
    {
      label: 'Conversion',
      value: 23.8,
      format: (v: number) => formatPct(v, 1),
      icon: ICONS.conversion,
      deltaPct: 1.4,
    },
  ];

  return (
    <Grid columns={{minWidth: 220, max: 6, repeat: 'fit'}} gap={4}>
      {kpiList.map((kpi) => (
        <MetricCard
          key={kpi.label}
          label={kpi.label}
          value={kpi.value}
          format={kpi.format}
          icon={kpi.icon}
          deltaPct={kpi.deltaPct}
          isRiseGood={kpi.isRiseGood}
        />
      ))}
    </Grid>
  );
}
