import React from "react";
import { TextField } from "@mui/material";
import PropTypes from "prop-types";

function TextAreaInput({ field, disabled, onChange, error, helperText }) {
  return (
    <TextField
      fullWidth
      multiline={field.Type === "textarea"}
      minRows={field.Type === "textarea" ? 3 : 1}
      label={field.Label}
      value={field.ProValue || ""}
      placeholder={field.Placeholder}
      disabled={disabled}
      error={error}
      variant="outlined"
      margin="normal"
      helperText={helperText}
      onChange={(e) => onChange(e.target.value)}
      id={`field-${field.Id}`}
    />
  );
}

export default TextAreaInput;

TextAreaInput.propTypes = {
  field: PropTypes.object.isRequired,
  disabled: PropTypes.bool,
  onChange: PropTypes.func.isRequired,
  error: PropTypes.bool,
  helperText: PropTypes.string,
};
