import { useAjax } from "@/Hook/useAjax";
import { getAdcreativeTemplatePreviewsApi } from "@/services/launchAdq/global";
import { Button } from "antd";
import React from "react";


interface Props {
    accountId: number,
    adgroupId: number
}
/**
 * 广告预览二维码
 * @returns 
 */
const PreviewOrigin: React.FC<Props> = (props) => {

    /*******************/
    const { accountId, adgroupId } = props

    const getAdcreativeTemplatePreviews = useAjax((params) => getAdcreativeTemplatePreviewsApi(params))
    /*******************/

    const handleVisibleChange = () => {
        getAdcreativeTemplatePreviews.run({ accountId, adgroupId }).then(res => {
            window.open(res)
        })
    }
    return <Button style={{ fontSize: 12, color: '#1890FF', padding: 0, lineHeight: 'normal', height: 'auto' }} loading={getAdcreativeTemplatePreviews.loading} type='link' onClick={() => handleVisibleChange()}>创意预览</Button>
}


export default React.memo(PreviewOrigin)