16 lines
688 B
TypeScript
16 lines
688 B
TypeScript
import { useMutation, useQueryClient } from "@tanstack/react-query"
|
|
import { pricePlanDetailRepository, RatePlanPayload } from "../data/repository"
|
|
import { toast } from "sonner"
|
|
|
|
export const useCreateRatePlan = (onSuccessCallback: () => void) => {
|
|
const queryClient = useQueryClient()
|
|
return useMutation({
|
|
mutationFn: (payload: RatePlanPayload) => pricePlanDetailRepository.createRatePlan(payload),
|
|
onSuccess: () => {
|
|
toast.success("Price plan created successfully")
|
|
queryClient.invalidateQueries({ queryKey: ["priceplan"] })
|
|
onSuccessCallback()
|
|
},
|
|
onError: (error: any) => toast.error(error.message),
|
|
})
|
|
} |