From 757dab3e81fe18b680b5a00fbc0b637d6e772b03 Mon Sep 17 00:00:00 2001 From: DrMint Date: Wed, 23 Mar 2022 17:23:48 +0100 Subject: [PATCH] Improved how the captcha works --- src/pages/about-us/contact.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/pages/about-us/contact.tsx b/src/pages/about-us/contact.tsx index 071f133..0dfdf31 100644 --- a/src/pages/about-us/contact.tsx +++ b/src/pages/about-us/contact.tsx @@ -30,8 +30,8 @@ export default function AboutUs(props: ContactProps): JSX.Element { "stale" ); - const random1 = randomInt(0, 10); - const random2 = randomInt(0, 10); + const [randomNumber1, setRandomNumber1] = useState(randomInt(0, 10)); + const [randomNumber2, setRandomNumber2] = useState(randomInt(0, 10)); const subPanel = ( @@ -91,7 +91,7 @@ export default function AboutUs(props: ContactProps): JSX.Element { setFormState("ongoing"); if ( - parseInt(fields.verif.value) == random1 + random2 && + parseInt(fields.verif.value) == randomNumber1 + randomNumber2 && formState !== "completed" ) { const content: RequestMailProps = { @@ -130,6 +130,8 @@ export default function AboutUs(props: ContactProps): JSX.Element { } else { setFormResponse(langui.response_invalid_code); setFormState("stale"); + setRandomNumber1(randomInt(0, 10)); + setRandomNumber2(randomInt(0, 10)); } router.replace("#send-response"); @@ -180,7 +182,7 @@ export default function AboutUs(props: ContactProps): JSX.Element { + >{`${randomNumber1} + ${randomNumber2} =`}