import { Input, Modal, message } from "antd"
import React, { useState } from "react"

interface Props {
    title?: string
    visible?: boolean
    onClose?: () => void
    onChange?: (value: string) => void
}
/**
 * 批量添加文案
 * @returns 
 */
const AddTextS: React.FC<Props> = ({ title, visible, onClose, onChange }) => {

    /*****************************************/
    const [text, setText] = useState<string>()
    /*****************************************/

    const handleOk = () => {
        if (text) {
            onChange?.(text)
        } else
            message.error('请输入')
    }

    return <Modal
        title={<strong>批量添加{title || '文案'}</strong>}
        visible={visible}
        onCancel={onClose}
        onOk={handleOk}
        className={`modalResetCss`}
        width={650}
    >
        <Input.TextArea
            placeholder={`请输入${title || '文案'}，多个换行`}
            value={text}
            onChange={(e) => setText(e.target.value)}
            allowClear
            rows={10}
        />
    </Modal>
}

export default React.memo(AddTextS)