'use client';

import { useMutation } from "@tanstack/react-query";
import { api } from "@/lib/auth/api-client";

export function useApiMutation<T>(
  url: string,
  method: "post" | "put" | "patch" | "delete" = "post"
) {
  return useMutation<T, any, any>({
    mutationFn: async (payload) => {
      const res = await api[method](url, payload);
      return res.data;
    },
  });
}
