import { useAjax } from "@/Hook/useAjax";
import { getAdcreativePreviewsQrcodeApi } from "@/services/launchAdq/global";
import { EyeOutlined } from "@ant-design/icons";
import { Button, Popover } from "antd";
import React, { useState } from "react";


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

    /*******************/
    const { accountId, adgroupId } = props
    const [open, setOpen] = useState(false);

    const getAdcreativePreviewsQrcode = useAjax((params) => getAdcreativePreviewsQrcodeApi(params))
    /*******************/
    console.log('adAccountId, adgroupId--->', accountId);

    const handleVisibleChange = (newOpen: boolean) => {
        setOpen(newOpen);
        if (newOpen && accountId && adgroupId) {
            getAdcreativePreviewsQrcode.run({ accountId, adgroupId }).then(res => {

            })
        }
    }

    return <>
        <Popover
            content={<>
                12312
            </>}
            trigger="click"
            placement="left"
            open={open}
            onOpenChange={handleVisibleChange}
        >
            <a style={{fontSize: 12, color: '#1890FF'}}><EyeOutlined />广告</a>
        </Popover>
    </>
}


export default React.memo(PreviewAd)