init
This commit is contained in:
23
src/routes/(user)/recycle/-hooks/useRecoverFile.ts
Normal file
23
src/routes/(user)/recycle/-hooks/useRecoverFile.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
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({
|
||||
mutationFn: recoverFile,
|
||||
...(mutationOptions || {}),
|
||||
});
|
||||
|
||||
const recover = (id: number) => {
|
||||
toast.promise(recoverMutateAsync(id), {
|
||||
loading: "恢复中",
|
||||
success: "恢复成功",
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
recover,
|
||||
recoverIsPending,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user