import React from 'react'
import styles from './ModalTextarea.module.css'

interface Props {
  label: string
  value: string
  onChange: (value: string) => void
  placeholder?: string
  maxLength?: number
  showCounter?: boolean
  rows?: number
  required?: boolean
  className?: string
}

const ModalTextarea: React.FC<Props> = ({
  label,
  value,
  onChange,
  placeholder,
  maxLength,
  showCounter = false,
  rows = 3,
  required = false,
  className = ''
}) => {
  return (
    <div className={`${styles.container} ${className}`}>
      <label className={styles.label}>{label}</label>
      <textarea
        value={value}
        onChange={(e) => onChange(e.target.value)}
        placeholder={placeholder}
        maxLength={maxLength}
        rows={rows}
        required={required}
        className={styles.textarea}
      />
      {showCounter && maxLength && (
        <div className={styles.counter}>
          {value.length}/{maxLength}
        </div>
      )}
    </div>
  )
}

export default ModalTextarea
