added more hooks

This commit is contained in:
subnub
2024-06-22 03:46:42 -04:00
parent ecca46c73e
commit 4cccd43677
11 changed files with 430 additions and 357 deletions
+35
View File
@@ -11,6 +11,8 @@ interface QueryKeyParams {
startAt?: boolean;
}
// GET
export const getFilesList = async ({
queryKey,
pageParam,
@@ -47,3 +49,36 @@ export const getQuickFilesList = async () => {
});
return response.data;
};
export const getFileThumbnail = async (thumbnailID: string) => {
const url = `http://localhost:5173/api/file-service/thumbnail/${thumbnailID}`;
const config = {
responseType: "arraybuffer",
};
const response = await axios.get(url, config);
const imgFile = new Blob([response.data]);
const imgUrl = URL.createObjectURL(imgFile);
return imgUrl;
};
// PATCH
export const renameFile = async (fileID: string, name: string) => {
const response = await axios.patch(`/file-service/rename`, {
id: fileID,
title: name,
});
return response.data;
};
// DELETE
export const deleteFile = async (fileID: string) => {
const response = await axios.delete(`/file-service/remove`, {
data: {
id: fileID,
},
});
return response.data;
};