Files
senmesh-zc/src/routes/(user)/recycle/-hooks/useRecoverFile.ts

24 lines
582 B
TypeScript
Raw Normal View History

2026-02-05 18:12:49 +08:00
import { useMutation } from "@tanstack/react-query";
import { recoverFile } from "@/apis/file";
import { toast } from "sonner";
export const useRecoverFile = (mutationOptions?: any) => {
const { mutateAsync: recoverMutateAsync, isPending: recoverIsPending } =
2026-02-06 10:10:26 +08:00
useMutation<any, Error, number>({
2026-02-05 18:12:49 +08:00
mutationFn: recoverFile,
...(mutationOptions || {}),
});
const recover = (id: number) => {
toast.promise(recoverMutateAsync(id), {
loading: "恢复中",
success: "恢复成功",
});
};
return {
recover,
recoverIsPending,
};
};