'use client';

import { Textarea } from '@admin/components/ui/textarea';
import { cn } from '@admin/utils/common';
import { Controller, useFormContext } from 'react-hook-form';

interface TextareaFieldProps {
    name: string;
    placeholder?: string;
    disabled?: boolean;
    className?: string;
    rows?: number;
}

export const TextareaField = ({ name, placeholder, disabled, className, rows }: TextareaFieldProps) => {
    const { control } = useFormContext();

    return (
        <Controller
            control={control}
            name={name}
            render={({ field }) => (
                <Textarea
                    {...field}
                    placeholder={placeholder}
                    disabled={disabled}
                    className={cn(className)}
                    rows={rows || 3}
                    value={field.value || ''}
                />
            )}
        />
    );
};
