import React from 'react';
import GrainIcon from './GrainIcon';
import OilIcon from './OilIcon';
import SeedIcon from './SeedIcon';
import FruitIcon from './FruitIcon';
import LivestockIcon from './LivestockIcon';
import AquacultureIcon from './AquacultureIcon';
import FreshFoodIcon from './FreshFoodIcon';
import SaltIcon from './SaltIcon';
import { useSupplyChain } from '../../context/SupplyChainContext';

// 定义产业类型
export type IndustryType = "粮食" | "油脂" | "种业" | "果蔬" | "畜牧" | "水产" | "鲜食" | "泛盐";

// 图标组件接口
interface IndustryIconProps {
  className?: string;
  industry: IndustryType;
  isActive?: boolean;
}


// 统一的产业图标组件
const IndustryIcon: React.FC<IndustryIconProps> = ({
  className = "",
  industry,
  isActive = true
}) => {
  const { themeColor } = useSupplyChain();
  const themeColorClass = `text-[${themeColor}]`;
  const iconColor = isActive ? themeColorClass : "text-white opacity-50";

  // 根据产业类型渲染对应的图标组件
  const renderIcon = () => {
    switch (industry) {
      case "粮食":
        return <GrainIcon className={iconColor} />;
      case "油脂":
        return <OilIcon className={iconColor} />;
      case "种业":
        return <SeedIcon className={iconColor} />;
      case "果蔬":
        return <FruitIcon className={iconColor} />;
      case "畜牧":
        return <LivestockIcon className={iconColor} />;
      case "水产":
        return <AquacultureIcon className={iconColor} />;
      case "鲜食":
        return <FreshFoodIcon className={iconColor} />;
      case "泛盐":
        return <SaltIcon className={iconColor} />;
      default:
        return null;
    }
  };

  return (
    <div className={`overflow-clip relative shrink-0 size-[50px] ${className}`}>
      {renderIcon()}
    </div>
  );
};

export default IndustryIcon;