import { Drawer, Input } from 'antd';
import { useState } from 'react';

/** 拷贝权限代码 */
const CopyPermissionCodeDrawer: React.FC<{ code: string; onClose: () => void }> = ({
    code,
    onClose,
}) => {
    const [visible, setVisible] = useState<boolean>(true);
    const handleClose = () => {
        setVisible(false);
        setTimeout(onClose, 300);
    };

    return (
        <Drawer title="拷贝权限代码" open={visible} onClose={handleClose} width="80%">
            <div style={{ height: 40, lineHeight: 1 }}>
                使用方法：从下面文本框中全量复制，然后替换 /common/constant.ts 文件中
                PERMISSIONS常量中，并格式化代码。
            </div>
            <Input.TextArea value={code} style={{ height: 'calc(100% - 40px)' }} />
        </Drawer>
    );
};

export default CopyPermissionCodeDrawer;
