24 lines
582 B
TypeScript
24 lines
582 B
TypeScript
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 } =
|
|
useMutation<any, Error, number>({
|
|
mutationFn: recoverFile,
|
|
...(mutationOptions || {}),
|
|
});
|
|
|
|
const recover = (id: number) => {
|
|
toast.promise(recoverMutateAsync(id), {
|
|
loading: "恢复中",
|
|
success: "恢复成功",
|
|
});
|
|
};
|
|
|
|
return {
|
|
recover,
|
|
recoverIsPending,
|
|
};
|
|
};
|