From d3a19d0a311c1f4c59fa8ed1bfa10d6d39e2253f Mon Sep 17 00:00:00 2001 From: Ebube Date: Fri, 12 May 2023 19:06:53 +0100 Subject: [PATCH] changed layout --- src/components/AuthPages/Login/index.jsx | 2 +- .../Helpers/Inputs/InputCom/index.jsx | 147 +++++----------- src/components/MyWallet/TransferFund.jsx | 164 +++++++++--------- src/index.css | 12 ++ 4 files changed, 140 insertions(+), 185 deletions(-) diff --git a/src/components/AuthPages/Login/index.jsx b/src/components/AuthPages/Login/index.jsx index 1cd1e92..478ec8e 100644 --- a/src/components/AuthPages/Login/index.jsx +++ b/src/components/AuthPages/Login/index.jsx @@ -8,7 +8,7 @@ import usersService from "../../../services/UsersService"; import InputCom from "../../Helpers/Inputs/InputCom"; import AuthLayout from "../AuthLayout"; //import { GoogleOAuthProvider } from '@react-oauth/google'; -import { googleLogout, useGoogleLogin } from '@react-oauth/google'; +// import { googleLogout, useGoogleLogin } from '@react-oauth/google'; import { useDispatch } from "react-redux"; import { updateUserDetails } from "../../../store/UserDetails"; diff --git a/src/components/Helpers/Inputs/InputCom/index.jsx b/src/components/Helpers/Inputs/InputCom/index.jsx index 2fee6cf..4cabcd9 100644 --- a/src/components/Helpers/Inputs/InputCom/index.jsx +++ b/src/components/Helpers/Inputs/InputCom/index.jsx @@ -20,119 +20,28 @@ export default function InputCom({ disable, blurHandler, spanTag, - inputBg + inputBg, + direction }) { const inputRef = useRef(null); // Entry Validation // for Min Length: const minLengthValidation = () => { - if (inputRef && inputRef?.current && inputRef?.current?.name === "email") { - return 7; - } else if ( - inputRef && - inputRef?.current && - inputRef?.current?.name === "first_name" - ) { - return 3; - } else if ( - inputRef && - inputRef?.current && - inputRef?.current?.name === "last_name" - ) { - return 3; - } else if ( - inputRef && - inputRef?.current && - inputRef?.current?.name === "address" - ) { - return 5; - } else if ( - inputRef && - inputRef?.current && - inputRef?.current?.name === "password" - ) { - return 8; - } else if ( - inputRef && - inputRef?.current && - inputRef?.current?.name === "state" - ) { - return 3; - } else if ( - inputRef && - inputRef?.current && - inputRef?.current?.name === "province" - ) { - return 3; - } else if ( - inputRef && - inputRef?.current && - inputRef?.current?.name === "city" - ) { - return 3; - } else if ( - inputRef && - inputRef?.current && - inputRef?.current?.name === "amount" - ) { - return 1; - } + const inputConfig = inputConfigs[inputRef?.current?.name]?.minLength; + return inputConfig || 0; }; // for MaxLength const maxLengthValidation = () => { - if (inputRef && inputRef?.current && inputRef?.current?.name === "email") { - return 35; - } else if ( - inputRef && - inputRef?.current && - inputRef?.current?.name === "first_name" - ) { - return 25; - } else if ( - inputRef && - inputRef?.current && - inputRef?.current?.name === "last_name" - ) { - return 25; - } else if ( - inputRef && - inputRef?.current && - inputRef?.current?.name === "address" - ) { - return 49; - } else if ( - inputRef && - inputRef?.current && - inputRef?.current?.name === "password" - ) { - return 15; - } else if ( - inputRef && - inputRef?.current && - inputRef?.current?.name === "state" - ) { - return 25; - } else if ( - inputRef && - inputRef?.current && - inputRef?.current?.name === "province" - ) { - return 25; - } else if ( - inputRef && - inputRef?.current && - inputRef?.current?.name === "city" - ) { - return 25; - } else if ( - inputRef && - inputRef?.current && - inputRef?.current?.name === "amount" - ) { - return 9; - } + const inputConfig = inputConfigs[inputRef?.current?.name]?.maxLength; + return inputConfig || 30; }; + + // for Patterns + const inputPatterns = () => { + const inputConfig = inputConfigs[inputRef?.current?.name]?.pattern; + return inputConfig || "" + } return (
@@ -140,9 +49,13 @@ export default function InputCom({ )} {forgotPassword && ( @@ -161,15 +74,19 @@ export default function InputCom({ placeholder={placeholder} value={value} onChange={inputHandler} - className={`input-field placeholder:text-base text-bese px-12 text-dark-gray w-full h-full ${inputBg ? inputBg: 'bg-[#FAFAFA]'} dark:bg-[#11131F] focus:ring-0 focus:outline-none ${fieldClass}`} + className={`input-field placeholder:text-base text-dark-gray w-full h-full ${ + inputBg ? inputBg : "bg-[#FAFAFA]" + } dark:bg-[#11131F] focus:ring-0 focus:outline-none ${fieldClass}`} type={type} id={name} name={name} minLength={minLengthValidation()} maxLength={maxLengthValidation()} + pattern={() => inputPatterns} ref={inputRef} readOnly={disable} onBlur={blurHandler} + dir={direction} /> {iconName && (
@@ -188,3 +105,21 @@ export default function InputCom({
); } + +const inputConfigs = { + email: { minLength: 7, maxLength: 30 }, + first_name: { minLength: 3, maxLength: 25, pattern: "[a-zA-Z]+" }, + last_name: { minLength: 3, maxLength: 25, pattern: "[a-zA-Z]+" }, + address: { minLength: 5, maxLength: 49, pattern: "[a-zA-Z0-9]+" }, + password: { minLength: 8, maxLength: 15, pattern: ".{8,}" }, + state: { minLength: 3, maxLength: 25, pattern: "[a-zA-Z]+" }, + province: { minLength: 3, maxLength: 25, pattern: "[a-zA-Z]+" }, + city: { minLength: 3, maxLength: 25, pattern: "[a-zA-Z]+" }, + amount: { minLength: 1, maxLength: 9, pattern: "[0-9]+" }, +}; + +/* Numbers Only: strictly numbers +Alphabets Only: strictly alphabets +Alphanumeric: mix +Password: a minimum of 8 characters +*/ diff --git a/src/components/MyWallet/TransferFund.jsx b/src/components/MyWallet/TransferFund.jsx index 2d5f67c..891987d 100644 --- a/src/components/MyWallet/TransferFund.jsx +++ b/src/components/MyWallet/TransferFund.jsx @@ -136,21 +136,25 @@ function TransferFund({ payment, wallet }) { ) : wallet.error ? (

- Opps! An Error Occured + Opps! An Error Occurred

) : (

No Wallet Information Found!

)} -
-
+
+
{ @@ -160,7 +164,7 @@ function TransferFund({ payment, wallet }) { // onMouseLeave={(e)=>{getSendMoneyFee(e)}} /> {props.errors.amount && props.touched.amount && ( -

+

{props.errors.amount}

)} @@ -168,25 +172,31 @@ function TransferFund({ payment, wallet }) {
-
-
-
+
-
-
- - + +
+ - {recipients.loading ? ( - - ) : recipients.data.length ? ( - <> + {recipients.loading ? ( - {recipients.data.map((item, index) => ( + ) : recipients.data.length ? ( + <> - ))} - - ) : recipients.error ? ( - - ) : ( - - )} - + {recipients.data.map((item, index) => ( + + ))} + + ) : recipients.error ? ( + + ) : ( + + )} + +
+ {props.errors.recipientID && + props.touched.recipientID && ( +

+ {props.errors.recipientID} +

+ )} + + Add New + +
+
- {props.errors.recipientID && props.touched.recipientID && ( -

- {props.errors.recipientID} -

- )}
-
- {/* */} -