'use client';

import React, { ChangeEvent } from 'react';
import BaseFormField, { getInputClasses } from './BaseFormField';

interface FormTextareaProps {
  label: string;
  name: string;
  value: string;
  onChange: (e: ChangeEvent<HTMLTextAreaElement>) => void;
  onBlur?: (e: ChangeEvent<HTMLTextAreaElement>) => void;
  error?: string;
  touched?: boolean;
  placeholder?: string;
  required?: boolean;
  disabled?: boolean;
  rows?: number;
  className?: string;
}

/**
 * Composant de textarea de formulaire réutilisable
 */
export default function FormTextarea({
  label,
  name,
  value,
  onChange,
  onBlur,
  error,
  touched,
  placeholder,
  required = false,
  disabled = false,
  rows = 4,
  className = '',
}: FormTextareaProps) {
  return (
    <BaseFormField
      label={label}
      name={name}
      required={required}
      error={error}
      touched={touched}
      className={className}
    >
      <textarea
        id={name}
        name={name}
        value={value}
        onChange={onChange}
        onBlur={onBlur}
        placeholder={placeholder}
        disabled={disabled}
        required={required}
        rows={rows}
        className={getInputClasses(!!touched && !!error)}
      />
    </BaseFormField>
  );
}
