import React from 'react'
import { Field, ErrorMessage } from 'formik'
import FormikControlErrorMessage from '../FormikControlErrorMessage'
import newId from '../../../utils/newId';

function FormikControlText(props) {
    const { label, name, ...rest } = props
    const htmlId = newId()
    return (
        <div className="mt-4 mb-2">
            <label htmlFor={htmlId} className="form-control block text-lg text-gray-800 py-1">
                <span className="text-gray-700 ml-1">{label}</span>
            </label>
            <Field
                as="textarea"
                label={label}
                title={label}
                id={htmlId}
                name={name}
                aria-describedby={name + 'Error'}
                {...rest}
                className="form-input mt-1 block w-full min-h-screen-10 max-h-screen-20 text-left tracking-widest"
            />
            <ErrorMessage component={FormikControlErrorMessage} name={name} label={label} id={name + 'Error'} />
        </div>
    )
}

export default FormikControlText
