feat(api): fixed middleware, Added Google Drive support, refactored API to remove RoR controllers

This commit is contained in:
Logan Reeder
2025-06-14 13:19:42 -06:00
parent 05d32e2045
commit 55a7390f8a
97 changed files with 18695 additions and 1100 deletions

View File

@@ -0,0 +1,42 @@
import { useMutation } from "@tanstack/react-query";
import { clientEnv } from "@/lib/env/client-env";
import axios, { type AxiosError } from "axios";
import { toast } from "sonner";
interface DeleteFileParams {
id: string;
}
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,
};
}
export default useFileOperations;