init
This commit is contained in:
23
src/routes/(user)/recycle/-hooks/useRemoveFile.ts
Normal file
23
src/routes/(user)/recycle/-hooks/useRemoveFile.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { removeFile } from "@/apis/file";
|
||||
import { toast } from "sonner";
|
||||
|
||||
export const useRemoveFile = (mutationOptions?: any) => {
|
||||
const { mutateAsync: removeMutateAsync, isPending: removeIsPending } =
|
||||
useMutation({
|
||||
mutationFn: removeFile,
|
||||
...(mutationOptions || {}),
|
||||
});
|
||||
|
||||
const remove = (id: number) => {
|
||||
toast.promise(removeMutateAsync(id), {
|
||||
loading: "删除中",
|
||||
success: "删除成功",
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
remove,
|
||||
removeIsPending,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user