import React from "react"; import Head from "next/head"; import { signIn } from "next-auth/react"; import { useForm } from "react-hook-form"; import { AiOutlineGoogle } from 'react-icons/ai' import style from '../styles/Connexion.module.css'; import { SiGnuprivacyguard } from 'react-icons/si' import { toast } from "react-toastify"; import Script from "next/script"; type LoginSubmitForm = { email: string, acceptTerms: boolean }; const Connexion = () => { const { register, handleSubmit, watch, trigger, formState: { errors } } = useForm(); const acceptTermCheckBox = watch("acceptTerms") const connexionWithGoogle = async () => { if (onCheckTerms()) { signIn("google", { callbackUrl: `${window.location.origin}/mon-compte` }) } await trigger("acceptTerms"); } const onMailSubmit = async (data: LoginSubmitForm) => { if (onCheckTerms()) { signIn("email", { email: data.email, callbackUrl: `${window.location.origin}/mon-compte` }) } await trigger("acceptTerms"); await trigger("email"); } const onCheckTerms = () => { if (acceptTermCheckBox) { return true; } else { toast.error('Vous devez accepter les conditions obligatoires', { position: "top-center", autoClose: 2000, hideProgressBar: false, closeOnClick: true, pauseOnHover: true, draggable: true, progress: undefined, theme: "light", }); return false } } return ( <> Connexion

Connexion


) }; export default Connexion;