mirror of
https://gitlab.massbug.com/massbug/judge4c.git
synced 2025-07-04 20:51:19 +00:00
21 lines
605 B
TypeScript
21 lines
605 B
TypeScript
|
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;
|
||
|
};
|