"use client";
import { useMutation, useQueryClient } from "@tanstack/react-query";
function useMediaUpload() {
  const queryClient = useQueryClient();
  return useMutation({
    mutationFn: async (files) => {
      if (!files || files.length === 0) {
        throw new Error("No files provided");
      }
      const formData = new FormData();
      files.forEach((file) => formData.append("files", file));
      const res = await fetch("/api/v1/media/upload", {
        method: "POST",
        body: formData
      });
      if (!res.ok) {
        const errorData = await res.json().catch(() => ({
          error: `Upload failed with status ${res.status}`
        }));
        throw new Error(errorData.error || "Upload failed");
      }
      const json = await res.json();
      return json.data;
    },
    onSuccess: () => {
      queryClient.invalidateQueries({ queryKey: ["media", "list"] });
    }
  });
}
function useUploadProgress() {
  return null;
}
export {
  useMediaUpload,
  useUploadProgress
};
