import { useAjax } from "@/Hook/useAjax"
import { reSendGroupTaskApi } from "@/pages/weComTask/API/businessPlan/create"
import { App, Button } from "antd"
import React from "react"


interface Props {
    id: number
    corpUserId?: string
    onChange?: () => void
}
/**
 * 重新发送
 * @returns 
 */
const GroupReSend: React.FC<Props> = ({ onChange, ...props }) => {

    /*************************/
    const { message } = App.useApp()
    const reSendTask = useAjax((params) => reSendGroupTaskApi(params))
    /*************************/

    const sendHandle = () => {
        reSendTask.run(props).then(res => {
            if (res.data) {
                message.success('发送成功')
                onChange?.()
            }
        })
    }

    return <Button type="link" loading={reSendTask.loading} onClick={sendHandle} style={{ padding: 0 }}>重新发送</Button>
}

export default React.memo(GroupReSend)