import axios from "../../../config/axios";
import type { UploadMultipleResponse } from "../types/Types";

export const uploadSingle = async (params: File) => {
  const formData = new FormData();
  formData.append("file", params);
  const { data } = await axios.post(`/admin/medias/upload/single`, formData);
  return data;
};

export const uploadMultiple = async (
  params: File[]
): Promise<UploadMultipleResponse> => {
  const formData = new FormData();
  params.forEach((file) => {
    formData.append("file", file);
  });
  const { data } = await axios.post<UploadMultipleResponse>(
    `/admin/medias/upload/multiple`,
    formData
  );
  return data;
};
