judge4c_backup_new/src/features/auth/api/use-login.ts

21 lines
605 B
TypeScript
Raw Normal View History

import { client } from "@/lib/rpc";
import { useMutation } from "@tanstack/react-query";
import { InferRequestType, InferResponseType } from "hono";
type ResponseType = InferResponseType<(typeof client.api.auth.login)["$post"]>;
type RequestType = InferRequestType<(typeof client.api.auth.login)["$post"]>;
export const useLogin = () => {
const mutation = useMutation<ResponseType, Error, RequestType>({
mutationFn: async ({ json }) => {
const response = await client.api.auth.login["$post"]({
json,
});
return await response.json();
},
});
return mutation;
};