diff --git a/src/components/Helpers/Inputs/InputCom/index.jsx b/src/components/Helpers/Inputs/InputCom/index.jsx index e34668c..6d601b8 100644 --- a/src/components/Helpers/Inputs/InputCom/index.jsx +++ b/src/components/Helpers/Inputs/InputCom/index.jsx @@ -92,7 +92,6 @@ export default function InputCom({ ref={inputRef} readOnly={disable} onBlur={blurHandler} - onMouseEnter={onMouseEnter} onMouseLeave={onMouseLeave} /> {iconName && ( diff --git a/src/components/MyWallet/AddRecipient.jsx b/src/components/MyWallet/AddRecipient.jsx index fb47d8d..b2e176a 100644 --- a/src/components/MyWallet/AddRecipient.jsx +++ b/src/components/MyWallet/AddRecipient.jsx @@ -21,7 +21,7 @@ const validationSchema = Yup.object().shape({ .max(25, 'Maximum 25 characters') .required('Lastname is required'), country: Yup.string() - .min(1, 'Minimum 3 characters') + .min(1, 'Minimum 1 characters') .max(25, 'Maximum 25 characters') .required('Country is required'), bank: Yup.string() diff --git a/src/components/MyWallet/TransferFund.jsx b/src/components/MyWallet/TransferFund.jsx index e38c05d..5212eac 100644 --- a/src/components/MyWallet/TransferFund.jsx +++ b/src/components/MyWallet/TransferFund.jsx @@ -6,25 +6,39 @@ import InputCom from '../Helpers/Inputs/InputCom' import usersService from '../../services/UsersService' +import {toast} from 'react-toastify' + +import {Formik, Form} from 'formik' +import * as Yup from 'yup' + +const validationSchema = Yup.object().shape({ + amount: Yup.number() + .typeError("you must specify a number") + .min(1, 'Amount must be greater than 0') + .required('Amount is required'), + recipient: Yup.string() + .min(3, 'Minimum 3 characters') + .max(50, 'Maximum 50 characters') + .required('Recipient is required'), + }) + + const initialValues = { + amount: '', + recipient: '', + comment: '', + } + function TransferFund({payment, wallet}) { const apiCall = new usersService() - let [newFee, setNewFee] = useState(false) - let [recepients, setRecipients] = useState({ // FOR COUPON HISTORY loading: true, data: [], error: false }) - let [sendMoneyFee, setSendMoneyFee] = useState({fee: 0, total: 0}) // HOLD THE VALUE FOR SEND MONEY FEE + let [sendMoneyFee, setSendMoneyFee] = useState({loading: false, fee: 0, total: 0}) // HOLD THE VALUE FOR SEND MONEY FEE - //STATE FOR CONTROLLED INPUTS - let [inputs, setInputs] = useState({ - amount: '0', - recipient: '', - comment: '' - }) //FUNCTION TO GET RECIPIENT LIST const getRecipients = ()=>{ @@ -40,159 +54,162 @@ function TransferFund({payment, wallet}) { } //FUNCTION TO GET SEND MONEY FEE - const getSendMoneyFee = ()=>{ - let {amount} = inputs + const getSendMoneyFee = ({target:{value}})=>{ + setSendMoneyFee({loading: true, fee: 0, total: 0}) + let amount = value if(Number(amount) <= 0 || amount=='' || isNaN(amount)){ - setSendMoneyFee({fee: 0, total: 0}) + setSendMoneyFee({loading: false, fee: 0, total: 0}) return } apiCall.getSendMoneyFee(Number(amount)).then((res)=>{ - setSendMoneyFee({fee: res.data.processing_fee, total: res.data.total_amount}) + setSendMoneyFee({loading: false, fee: res.data.processing_fee, total: res.data.total_amount}) }).catch((error)=>{ - setSendMoneyFee({fee: 0, total: 0}) + setSendMoneyFee({loading: false, fee: 0, total: 0}) }) } - // FUNCTION TO HANDLE INPUT CHANGE - const handleChange = ({target:{name, value}}) => { - setInputs(prev => ({...prev, [name]:value})) - } - //FUNCTION TO HANDLE SUBMIT - const handleSubmit = (e) => { - e.preventDefault(); + const handleSubmit = () => { + // setRequestStatus({message: '', loading: true, status: false}) + let reqData = {} - //valid inputs before submitting. Just for texting remove later. check amoutn to be number - - setInputs({ - amount: '0', - recipient: '', - comment: '' - }) + // MAKE API CALL + } useEffect(()=>{ getRecipients() - getSendMoneyFee() - },[newFee]) + },[]) return (
-
- {wallet.loading ? - - : - wallet.data.length ? -

- {wallet.data.map(item => { - if(item.description == 'Naira'){ - return `Withdraw from Naira Wallet : ${item.symbol}${(item.amount*1).toFixed(2)}` - } - })} -

- : - wallet.error ? -

Opps! An Error Occured

- : -

No Wallet Information Found!

- } -
- -
- {setNewFee(false)}} - onMouseLeave={()=>{setNewFee(true)}} - /> -
- -
- -
-
- -
-
- -
-
- -
-
-
- - Add New -
- -
-
+
-
- {/* */} - -