mirror of
https://gitlab.massbug.com/massbug/judge4c.git
synced 2025-07-04 15:32:09 +00:00
22 lines
618 B
TypeScript
22 lines
618 B
TypeScript
import { client } from "@/lib/rpc";
|
|
import { InferResponseType } from "hono";
|
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
|
|
type ResponseType = InferResponseType<(typeof client.api.auth.logout)["$post"]>;
|
|
|
|
export const useLogout = () => {
|
|
const queryClient = useQueryClient();
|
|
|
|
const mutation = useMutation<ResponseType, Error>({
|
|
mutationFn: async () => {
|
|
const response = await client.api.auth.logout["$post"]();
|
|
return await response.json();
|
|
},
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({ queryKey: ["current"] });
|
|
},
|
|
});
|
|
|
|
return mutation;
|
|
};
|