import { type FC } from 'react'
import Button from '@/components/Button'
import { useOpenTicket } from '../hooks/useTicketData'

type Props = {
    id: string,
    refetch: () => void
}

const OpenTicket: FC<Props> = ({ id, refetch }) => {

    const { mutate: openTicket, isPending } = useOpenTicket()

    const handleOpenTicket = () => {
        openTicket(id, {
            onSuccess: () => {
                refetch()
            }
        })
    }

    return (
        <div>
            <Button
                label={'باز کردن تیکت'}
                onClick={handleOpenTicket}
                className='px-4 h-8 text-xs'
                isLoading={isPending}
            />
        </div>
    )
}

export default OpenTicket