✨ add - new pages et corrections
This commit is contained in:
1 parent
374d35b449
commit
50d64b513b
1 file changed
+29
-37
+29
-37
@@ -23,6 +23,7 @@ import Link from "next/link";
|
|||||||
import { SiGnuprivacyguard } from 'react-icons/si'
|
import { SiGnuprivacyguard } from 'react-icons/si'
|
||||||
import { toast } from "react-toastify";
|
import { toast } from "react-toastify";
|
||||||
import { Token } from "nodemailer/lib/xoauth2";
|
import { Token } from "nodemailer/lib/xoauth2";
|
||||||
|
import { isGeneratorFunction } from "util/types";
|
||||||
|
|
||||||
export async function getServerSideProps(context) {
|
export async function getServerSideProps(context) {
|
||||||
const csrfToken = await getCsrfToken(context)
|
const csrfToken = await getCsrfToken(context)
|
||||||
@@ -40,19 +41,17 @@ type Props = {
|
|||||||
csrfToken: Token
|
csrfToken: Token
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const MainPage = ({ csrfToken }: Props) => {
|
const MainPage = ({ csrfToken }: Props) => {
|
||||||
const { data: session } = useSession();
|
const { data: session } = useSession();
|
||||||
|
|
||||||
const validationSchema = Yup.object().shape({
|
const validationSchema = Yup.object().shape({
|
||||||
email: Yup.string().email(
|
// email: Yup.string().email(
|
||||||
"Veuillez rentrer une adresse mail valide"
|
// "Veuillez rentrer une adresse mail valide"
|
||||||
),
|
// ),
|
||||||
acceptTerms: Yup.bool().oneOf(
|
// acceptTerms: Yup.bool().oneOf(
|
||||||
[true],
|
// [true],
|
||||||
"Vous devez accepter les conditions obligatoire"
|
// "Vous devez accepter les conditions obligatoire"
|
||||||
)
|
// )
|
||||||
})
|
})
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@@ -67,40 +66,34 @@ const MainPage = ({ csrfToken }: Props) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
const term = watch("acceptTerms")
|
const acceptTermCheckBox = watch("acceptTerms")
|
||||||
|
|
||||||
|
|
||||||
const connexionWithGoogle = async () => {
|
const connexionWithGoogle = async () => {
|
||||||
clearErrors("acceptTerms")
|
if (onCheckTerms()) {
|
||||||
if (term) {
|
signIn("google")
|
||||||
signIn("google");
|
}
|
||||||
} else {
|
await trigger("acceptTerms");
|
||||||
toast.error('Vous devez accepter les conditions obligatoire', {
|
|
||||||
position: "top-center",
|
|
||||||
autoClose: 5000,
|
|
||||||
hideProgressBar: false,
|
|
||||||
closeOnClick: true,
|
|
||||||
pauseOnHover: true,
|
|
||||||
draggable: true,
|
|
||||||
progress: undefined,
|
|
||||||
theme: "light",
|
|
||||||
});
|
|
||||||
//relance une vérification de la checkbox
|
|
||||||
// await trigger("acceptTerms");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
const onMailSubmit = async (data: LoginSubmitForm) => {
|
||||||
|
if (onCheckTerms()) {
|
||||||
const onSubmit = async (data: LoginSubmitForm) => {
|
|
||||||
if (term && !errors.email?.message) {
|
|
||||||
console.log("email", data.email);
|
|
||||||
|
|
||||||
signIn("email", { email: data.email, callbackUrl: `${window.location.origin}/create` })
|
signIn("email", { email: data.email, callbackUrl: `${window.location.origin}/create` })
|
||||||
|
}
|
||||||
|
await trigger("acceptTerms");
|
||||||
|
await trigger("email");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const onCheckTerms = (): any => {
|
||||||
|
if (acceptTermCheckBox) {
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
toast.error('Vous devez accepter les conditions obligatoire', {
|
toast.error('Vous devez accepter les conditions obligatoires', {
|
||||||
position: "top-center",
|
position: "top-center",
|
||||||
autoClose: 5000,
|
autoClose: 2000,
|
||||||
hideProgressBar: false,
|
hideProgressBar: false,
|
||||||
closeOnClick: true,
|
closeOnClick: true,
|
||||||
pauseOnHover: true,
|
pauseOnHover: true,
|
||||||
@@ -139,8 +132,9 @@ const MainPage = ({ csrfToken }: Props) => {
|
|||||||
</Head>
|
</Head>
|
||||||
<div className={`${style['bloc-content']} col-12 col-lg-6`}>
|
<div className={`${style['bloc-content']} col-12 col-lg-6`}>
|
||||||
<h1 className="fw-light">Connexion</h1>
|
<h1 className="fw-light">Connexion</h1>
|
||||||
|
|
||||||
<SiGnuprivacyguard size={50} />
|
<SiGnuprivacyguard size={50} />
|
||||||
<form onSubmit={handleSubmit(onSubmit)}>
|
<form onSubmit={handleSubmit(onMailSubmit)}>
|
||||||
<div className="form-group mx-auto my-3 w-100">
|
<div className="form-group mx-auto my-3 w-100">
|
||||||
<input
|
<input
|
||||||
type="email" id="email" name="email"
|
type="email" id="email" name="email"
|
||||||
@@ -153,7 +147,6 @@ const MainPage = ({ csrfToken }: Props) => {
|
|||||||
Se connecter avec mon email
|
Se connecter avec mon email
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div className="invalid-feedback alert alert-danger">{errors.email?.message}</div>
|
|
||||||
</div>
|
</div>
|
||||||
<hr />
|
<hr />
|
||||||
<div className="d-grid">
|
<div className="d-grid">
|
||||||
@@ -175,7 +168,6 @@ const MainPage = ({ csrfToken }: Props) => {
|
|||||||
{...register("acceptTerms")}
|
{...register("acceptTerms")}
|
||||||
name="acceptTerms"
|
name="acceptTerms"
|
||||||
/>
|
/>
|
||||||
{/* <div className="invalid-feedback alert alert-danger">{errors.acceptTerms?.message}</div> */}
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div >
|
</div >
|
||||||
|
|||||||
Reference in new issue
Block a user