2025-04-09 12:59:33 +07:00
|
|
|
import { useForm } from 'react-hook-form';
|
|
|
|
|
import {
|
|
|
|
|
authLoginSchema,
|
|
|
|
|
TLoginRequest,
|
|
|
|
|
} from '@imphnen-frontend-service/service';
|
|
|
|
|
import { zodResolver } from '@hookform/resolvers/zod';
|
2025-05-23 00:28:29 +07:00
|
|
|
import { useSession } from '@imphnen-frontend-service/utils';
|
2025-04-09 12:59:33 +07:00
|
|
|
|
|
|
|
|
export const useLogin = () => {
|
|
|
|
|
const form = useForm<TLoginRequest>({
|
|
|
|
|
resolver: zodResolver(authLoginSchema),
|
|
|
|
|
mode: 'all',
|
|
|
|
|
});
|
|
|
|
|
|
2025-05-26 17:05:02 +07:00
|
|
|
const { signIn, isLoading } = useSession();
|
2025-05-23 00:28:29 +07:00
|
|
|
|
|
|
|
|
const onSubmit = form.handleSubmit((data) => signIn(data));
|
2025-04-09 12:59:33 +07:00
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
form,
|
|
|
|
|
onSubmit,
|
2025-05-26 17:05:02 +07:00
|
|
|
isLoading
|
2025-04-09 12:59:33 +07:00
|
|
|
};
|
|
|
|
|
};
|