create category
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import * as api from "../service/UploaderService";
|
||||
|
||||
export const useSingleUpload = () => {
|
||||
return useMutation({
|
||||
mutationFn: api.singleUpload,
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
import axios from "@/config/axios";
|
||||
import type { SingleUploadResponseType } from "../types/Types";
|
||||
|
||||
export const singleUpload = async (file: File) => {
|
||||
const formData = new FormData();
|
||||
formData.append("file", file);
|
||||
const { data } = await axios.post<SingleUploadResponseType>(
|
||||
"/admin/single-file",
|
||||
formData,
|
||||
);
|
||||
return data;
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
import type { BaseResponse } from "@/shared/types/Types";
|
||||
|
||||
export type SingleUploadType = {
|
||||
url: string;
|
||||
file: {
|
||||
url: string;
|
||||
key: string;
|
||||
bucket: string;
|
||||
};
|
||||
};
|
||||
|
||||
export type SingleUploadResponseType = BaseResponse<SingleUploadType>;
|
||||
Reference in New Issue
Block a user