import { useMutation, useQueryClient } from "@tanstack/react-query" import { toast } from "sonner" import { pricePlanRepository } from "../data/repository" export const useDeletePricePlanMutation = () => { const queryClient = useQueryClient() return useMutation({ mutationFn: (id: string) => pricePlanRepository.deletePricePlan(id), onSuccess: () => { toast.success("Record has been successfully deleted") queryClient.invalidateQueries({ queryKey: ["priceplan"] }) }, onError: (error: any) => toast.error(error.message), }) } export const useCreatePricePlanMutation = (onSuccessCallback: () => void) => { const queryClient = useQueryClient() return useMutation({ mutationFn: (payload: any) => pricePlanRepository.createPricePlan(payload), onSuccess: () => { toast.success("Price plan created successfully") queryClient.invalidateQueries({ queryKey: ["priceplan"] }) onSuccessCallback() }, onError: (error: any) => toast.error(error.message), }) }