import React from 'react';
import CheckBox from '@/components/CheckBox';

const CheckBoxList = ({
  items,
  formData,
  handleChange,
  fieldName,
  label,
  icon: Icon,
  className,
  itemLabelFunc = (item) => item.name,
  labelAttenuated = () => false,
  horizontal = false // Ajouter l'option horizontal
}) => {
  return (
    <div className={`mb-4 w-full ${className}`}>
      <label className="block text-sm font-medium text-gray-700 flex items-center">
        {Icon && <Icon className="w-5 h-5 mr-2" />}
        {label}
      </label>
      <div className={`mt-2 grid ${horizontal ? 'grid-cols-6 gap-2' : 'grid-cols-1 gap-4'}`}>
        {items.map(item => (
          <CheckBox
            key={item.id}
            item={item}
            formData={formData}
            handleChange={handleChange}
            fieldName={fieldName}
            itemLabelFunc={itemLabelFunc}
            labelAttenuated={labelAttenuated}
            horizontal={horizontal}
          />
        ))}
      </div>
    </div>
  );
};

export default CheckBoxList;
