mirror of
https://github.com/nimbusdotstorage/Nimbus
synced 2026-04-22 17:45:03 +02:00
prettier format header.tsx adding oxlint and updating packages wip: merging this all together fix: removed duplicate component declarations Somehow this got all messed up on the last merge fixed by downgrading drizzle-orm 2025-06-18. cloudflare:workers runtime import from hono/logger. REMOVED. https://github.com/honojs/hono/issues/4233#issuecomment-2985229943 chore: added dist to .gitignore. fixed GoogleDrive import
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
import { useMutation } from "@tanstack/react-query";
|
|
import type { DeleteFileParams } from "@/lib/types";
|
|
import { clientEnv } from "@/lib/env/client-env";
|
|
import axios, { type AxiosError } from "axios";
|
|
import { toast } from "sonner";
|
|
|
|
export function useFileOperations() {
|
|
const deleteFileMutation = useMutation({
|
|
mutationFn: async ({ id }: DeleteFileParams) => {
|
|
const response = await axios.delete(`${clientEnv.NEXT_PUBLIC_BACKEND_URL}/api/files`, {
|
|
params: { id },
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
withCredentials: true,
|
|
signal: new AbortController().signal,
|
|
});
|
|
return response.data;
|
|
},
|
|
onSuccess: () => {
|
|
toast.success("File deleted successfully");
|
|
},
|
|
onError: (error: AxiosError) => {
|
|
console.error("Error deleting file:", error);
|
|
const errorMessage = error.message || "Failed to delete file";
|
|
toast.error(errorMessage);
|
|
},
|
|
});
|
|
|
|
const handleDeleteFile = (id: string) => {
|
|
deleteFileMutation.mutate({ id });
|
|
};
|
|
|
|
return {
|
|
handleDeleteFile,
|
|
};
|
|
}
|