import { useMutation } from "@tanstack/react-query";
import { useDealsContext } from "@/app/deals/contexts/DealsContext";
import { SwitchDealTagRequest } from "@/lib/client";
import { switchDealTagMutation } from "@/lib/client/@tanstack/react-query.gen";

const useDealTags = () => {
    const { refetchDeals } = useDealsContext();

    const switchTagMutation = useMutation({
        ...switchDealTagMutation(),
        onSettled: refetchDeals,
    });

    const switchTag = (data: SwitchDealTagRequest) => {
        switchTagMutation.mutate({
            body: data,
        });
    };

    return {
        switchTag,
    };
};

export default useDealTags;
