import { Package, Box, AlertTriangle, RotateCcw, Users, Wrench } from 'lucide-react'
import React from 'react'

import { StatCard } from '../components/StatCard'
import type { WarehouseStatsBlockProps } from '../types'

/**
 * Блок статистических карт дашборда склада
 * 
 * Отображает 6 основных метрик склада фулфилмента:
 * - Товары (products) 
 * - Готовые товары (goods)
 * - Брак (defects)
 * - Возвраты с ПВЗ (pvzReturns)
 * - Расходники фулфилмента (fulfillmentSupplies)
 * - Расходники селлера (sellerSupplies)
 */
export const WarehouseStatsBlock = React.memo<WarehouseStatsBlockProps>(({ 
  warehouseStats,
  warehouseStatsData,
  isStatsLoading, 
}) => {
  return (
    <div className="grid grid-cols-2 md:grid-cols-3 xl:grid-cols-6 gap-3">
      {/* Товары */}
      <StatCard
        title="Продукты"
        icon={Box}
        current={warehouseStats.products.current}
        change={warehouseStats.products.change}
        percentChange={warehouseStatsData?.fulfillmentWarehouseStats?.products?.percentChange}
        description="Готовые к отправке"
      />

      {/* Готовые товары */}
      <StatCard
        title="Товары"
        icon={Package}
        current={warehouseStats.goods.current}
        change={warehouseStats.goods.change}
        percentChange={warehouseStatsData?.fulfillmentWarehouseStats?.goods?.percentChange}
        description="На складе и в обработке"
      />

      {/* Брак */}
      <StatCard
        title="Брак"
        icon={AlertTriangle}
        current={warehouseStats.defects.current}
        change={warehouseStats.defects.change}
        percentChange={warehouseStatsData?.fulfillmentWarehouseStats?.defects?.percentChange}
        description="Требует утилизации"
      />

      {/* Возвраты с ПВЗ */}
      <StatCard
        title="Возвраты с ПВЗ"
        icon={RotateCcw}
        current={warehouseStats.pvzReturns.current}
        change={warehouseStats.pvzReturns.change}
        percentChange={warehouseStatsData?.fulfillmentWarehouseStats?.pvzReturns?.percentChange}
        description="К обработке"
      />

      {/* Расходники фулфилмента */}
      <StatCard
        title="Расходники фулфилмента"
        icon={Wrench}
        current={warehouseStats.fulfillmentSupplies.current}
        change={warehouseStats.fulfillmentSupplies.change}
        percentChange={warehouseStatsData?.fulfillmentWarehouseStats?.fulfillmentSupplies?.percentChange}
        description="Операционные материалы"
      />

      {/* Расходники селлера */}
      <StatCard
        title="Расходники селлеров"
        icon={Users}
        current={warehouseStats.sellerSupplies.current}
        change={warehouseStats.sellerSupplies.change}
        percentChange={warehouseStatsData?.fulfillmentWarehouseStats?.sellerSupplies?.percentChange}
        description="Материалы клиентов"
      />
    </div>
  )
})

WarehouseStatsBlock.displayName = 'WarehouseStatsBlock'