From d738b8704f75efa02879b23a3d71ba5376ef09a9 Mon Sep 17 00:00:00 2001 From: Piotr Matlak Date: Thu, 14 Mar 2024 19:33:15 +0100 Subject: [PATCH 1/3] Update captcha by allowing to concatenate numbers --- src/components/Modals/Faucet/Faucet.tsx | 6 ++++-- src/components/Modals/Faucet/styles.ts | 3 +-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/Modals/Faucet/Faucet.tsx b/src/components/Modals/Faucet/Faucet.tsx index c23c56e..48f6452 100644 --- a/src/components/Modals/Faucet/Faucet.tsx +++ b/src/components/Modals/Faucet/Faucet.tsx @@ -39,7 +39,9 @@ export const Faucet: React.FC = ({ anchorEl, open, handleClose, onFaucet }, [numberOne, numberTwo]) const handleCaptcha = () => { - if (numberOne + numberTwo === Number(answer)) { + const trimmedAnswer = answer.replace(/\s/g, ''); + + if (numberOne + numberTwo === Number(answer) || trimmedAnswer === (numberOne.toString() + numberTwo.toString())) { onFaucet() handleClose() } else { @@ -75,7 +77,7 @@ export const Faucet: React.FC = ({ anchorEl, open, handleClose, onFaucet direction='row' justifyContent='space-between' wrap='nowrap'> - Add two numbers on screen + Please input the result of adding these two values: diff --git a/src/components/Modals/Faucet/styles.ts b/src/components/Modals/Faucet/styles.ts index 626e255..285473e 100644 --- a/src/components/Modals/Faucet/styles.ts +++ b/src/components/Modals/Faucet/styles.ts @@ -11,7 +11,7 @@ const useStyles = makeStyles(() => ({ }, title: { ...typography.body1, - margin: 10 + padding: '0 10px' }, name: { textTransform: 'capitalize', @@ -23,7 +23,6 @@ const useStyles = makeStyles(() => ({ boxShadow: 'none' }, lowerRow: { - height: 30, marginBlock: 10 }, input: { From c88cb76bd03fb4ded411ac3ed87e8d0a29dc580c Mon Sep 17 00:00:00 2001 From: Piotr Matlak Date: Thu, 14 Mar 2024 19:53:15 +0100 Subject: [PATCH 2/3] adjust prettier --- src/components/Modals/Faucet/Faucet.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/components/Modals/Faucet/Faucet.tsx b/src/components/Modals/Faucet/Faucet.tsx index 48f6452..2c36068 100644 --- a/src/components/Modals/Faucet/Faucet.tsx +++ b/src/components/Modals/Faucet/Faucet.tsx @@ -39,9 +39,12 @@ export const Faucet: React.FC = ({ anchorEl, open, handleClose, onFaucet }, [numberOne, numberTwo]) const handleCaptcha = () => { - const trimmedAnswer = answer.replace(/\s/g, ''); - - if (numberOne + numberTwo === Number(answer) || trimmedAnswer === (numberOne.toString() + numberTwo.toString())) { + const trimmedAnswer = answer.replace(/\s/g, '') + + if ( + numberOne + numberTwo === Number(answer) || + trimmedAnswer === numberOne.toString() + numberTwo.toString() + ) { onFaucet() handleClose() } else { @@ -77,7 +80,9 @@ export const Faucet: React.FC = ({ anchorEl, open, handleClose, onFaucet direction='row' justifyContent='space-between' wrap='nowrap'> - Please input the result of adding these two values: + + Please input the result of adding these two values: + From e525083eb53a39e3d576270be58dc8f3c6c4bcef Mon Sep 17 00:00:00 2001 From: Piotr Matlak Date: Fri, 15 Mar 2024 08:04:27 +0100 Subject: [PATCH 3/3] improve code readability --- src/components/Modals/Faucet/Faucet.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/Modals/Faucet/Faucet.tsx b/src/components/Modals/Faucet/Faucet.tsx index 2c36068..ecc3e45 100644 --- a/src/components/Modals/Faucet/Faucet.tsx +++ b/src/components/Modals/Faucet/Faucet.tsx @@ -41,10 +41,10 @@ export const Faucet: React.FC = ({ anchorEl, open, handleClose, onFaucet const handleCaptcha = () => { const trimmedAnswer = answer.replace(/\s/g, '') - if ( - numberOne + numberTwo === Number(answer) || - trimmedAnswer === numberOne.toString() + numberTwo.toString() - ) { + const sumMatchesAnswer = numberOne + numberTwo === Number(answer) + const concatenatedMatchesAnswer = trimmedAnswer === numberOne.toString() + numberTwo.toString() + + if (sumMatchesAnswer || concatenatedMatchesAnswer) { onFaucet() handleClose() } else {