import { useAjax } from "@/Hook/useAjax"
import { openV3Api } from "@/services/launchAdq/adq"
import { LoadingOutlined } from "@ant-design/icons"
import { Button, Tooltip, message } from "antd"
import React from "react"


interface Props {
    accountId: any
    onChange?: () => void
}
const OpenV3: React.FC<Props> = ({ accountId, onChange }) => {

    /*************************************/
    const openV3a = useAjax((params) => openV3Api(params), { formatResult: true })
    /*************************************/
    // 
    const openV3 = () => {
        openV3a.run(accountId).then(res => {
            if (res?.data) {
                message.success('开启成功')
                onChange?.()
            }
        })
    }

    return <Tooltip title="开启3.0">
        <Button size="small" style={{ color: "#0eb83a" }} onClick={openV3}>{openV3a.loading ? <LoadingOutlined /> : <span>3.0</span>}</Button>
    </Tooltip>
}

export default React.memo(OpenV3)