import { useTranslation } from 'react-i18next';
import { Icon } from '../../Atoms/Icon/Icon';

export const DatePicker = ({
  label,
  value,
  error,
  helperText,
  disabled = false,
  required = false,
  className = '',
  ...props
}) => {
  const { t } = useTranslation();

  const inputClasses = `
    w-full px-3 py-2 pl-10 border rounded-lg
    focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent
    disabled:bg-gray-100 disabled:cursor-not-allowed
    ${error ? 'border-red-500' : 'border-gray-300'}
    ${className}
  `;

  return (
    <div className="w-full">
      {label && (
        <label className="block text-sm font-medium text-gray-700 mb-1">
          {label}
          {required && <span className="text-red-500 ml-1">*</span>}
        </label>
      )}
      <div className="relative">
        <div className="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
          <Icon name="CalendarIcon" className="h-5 w-5 text-gray-400" />
        </div>
        <input
          type="date"
          value={value}
          disabled={disabled}
          className={inputClasses}
          {...props}
        />
      </div>
      {error && (
        <p className="mt-1 text-sm text-red-600">{error}</p>
      )}
      {helperText && !error && (
        <p className="mt-1 text-sm text-gray-500">{helperText}</p>
      )}
    </div>
  );
};

export default DatePicker;

