Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 187ac61396 | |||
| 31297efb5b | |||
| f8d6475ff8 | |||
| 22a45ac15e | |||
| 0489be5e69 |
@@ -4,12 +4,10 @@ import { toast } from "react-toastify";
|
|||||||
import InputCom from "../../Helpers/Inputs/InputCom";
|
import InputCom from "../../Helpers/Inputs/InputCom";
|
||||||
import ModalCom from "../../Helpers/ModalCom";
|
import ModalCom from "../../Helpers/ModalCom";
|
||||||
import LoadingSpinner from "../../Spinners/LoadingSpinner";
|
import LoadingSpinner from "../../Spinners/LoadingSpinner";
|
||||||
|
|
||||||
import usersService from "../../../services/UsersService";
|
import usersService from "../../../services/UsersService";
|
||||||
|
|
||||||
function ConfirmNairaWithdraw({ payment, wallet, action, situation, state }) {
|
function ConfirmNairaWithdraw({ payment, wallet, action, situation, state }) {
|
||||||
const apiURL = new usersService();
|
const apiURL = new usersService();
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
let [requestStatus, setRequestStatus] = useState({
|
let [requestStatus, setRequestStatus] = useState({
|
||||||
@@ -25,19 +23,35 @@ function ConfirmNairaWithdraw({ payment, wallet, action, situation, state }) {
|
|||||||
let reqData = {
|
let reqData = {
|
||||||
amount: Number(state.amount * 100),
|
amount: Number(state.amount * 100),
|
||||||
Fee: Number(state.fee),
|
Fee: Number(state.fee),
|
||||||
recipient_uid: Number(state.details?.recipient_uid),
|
recipient_uid: state.details?.recipient_uid,
|
||||||
wallet_uid: wallet.wallet_uid,
|
wallet_uid: wallet.wallet_uid,
|
||||||
};
|
};
|
||||||
apiURL
|
apiURL
|
||||||
.sendMoney(reqData)
|
.sendMoney(reqData)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.data.internal_return < 0) {
|
if (res.data.internal_return < 0) {
|
||||||
setRequestStatus({
|
if (res.data?.status_message?.toLowerCase().includes("limit")) {
|
||||||
message: "Could not perform transaction",
|
setRequestStatus({
|
||||||
loading: false,
|
message: "You have exceeded the transfer limit",
|
||||||
status: false,
|
loading: false,
|
||||||
});
|
status: false,
|
||||||
return;
|
});
|
||||||
|
} else {
|
||||||
|
setRequestStatus({
|
||||||
|
message: "Could not perform transaction",
|
||||||
|
loading: false,
|
||||||
|
status: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return setTimeout(
|
||||||
|
() =>
|
||||||
|
setRequestStatus({
|
||||||
|
message: "",
|
||||||
|
loading: false,
|
||||||
|
status: false,
|
||||||
|
}),
|
||||||
|
1500
|
||||||
|
);
|
||||||
}
|
}
|
||||||
setRequestStatus({
|
setRequestStatus({
|
||||||
message: "transfer successful",
|
message: "transfer successful",
|
||||||
@@ -59,7 +73,7 @@ function ConfirmNairaWithdraw({ payment, wallet, action, situation, state }) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log(state)
|
console.log(state);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalCom action={action} situation={situation} className="edit-popup">
|
<ModalCom action={action} situation={situation} className="edit-popup">
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Form, Formik } from "formik";
|
import { Form, Formik } from "formik";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
|
import { checkAndSetError } from "../../../lib";
|
||||||
import usersService from "../../../services/UsersService";
|
import usersService from "../../../services/UsersService";
|
||||||
import InputCom from "../../Helpers/Inputs/InputCom";
|
import InputCom from "../../Helpers/Inputs/InputCom";
|
||||||
import ModalCom from "../../Helpers/ModalCom";
|
import ModalCom from "../../Helpers/ModalCom";
|
||||||
@@ -33,6 +34,7 @@ function NairaWithdraw({
|
|||||||
const [tab, setTab] = useState("previous");
|
const [tab, setTab] = useState("previous");
|
||||||
let [requestStatus, setRequestStatus] = useState(false);
|
let [requestStatus, setRequestStatus] = useState(false);
|
||||||
const [errorMsgs, setErrorMsgs] = useState(initialValues);
|
const [errorMsgs, setErrorMsgs] = useState(initialValues);
|
||||||
|
const { isNotEmpty, textCount } = checkAndSetError();
|
||||||
|
|
||||||
let [sendMoneyFee, setSendMoneyFee] = useState({
|
let [sendMoneyFee, setSendMoneyFee] = useState({
|
||||||
loading: false,
|
loading: false,
|
||||||
@@ -210,12 +212,13 @@ function NairaWithdraw({
|
|||||||
const stateData = {
|
const stateData = {
|
||||||
amount: values.amount,
|
amount: values.amount,
|
||||||
comment: values.comment,
|
comment: values.comment,
|
||||||
wallet_uid: wallet.wallet_uid,
|
choice: "prev",
|
||||||
|
wallet_uid: wallet.wallet_uid,
|
||||||
...sendMoneyFee,
|
...sendMoneyFee,
|
||||||
details: { ...recipientDetails[0] },
|
details: { ...recipientDetails[0] },
|
||||||
};
|
};
|
||||||
|
|
||||||
setTimeout(() => {
|
return setTimeout(() => {
|
||||||
setRequestStatus(false);
|
setRequestStatus(false);
|
||||||
// navigate("confirm-withdraw-naira", { state: stateData });
|
// navigate("confirm-withdraw-naira", { state: stateData });
|
||||||
action();
|
action();
|
||||||
@@ -226,6 +229,71 @@ function NairaWithdraw({
|
|||||||
if (tab === "new") {
|
if (tab === "new") {
|
||||||
const { accountNumber, accountType, bank, city, country, state } =
|
const { accountNumber, accountType, bank, city, country, state } =
|
||||||
values?.newAccount;
|
values?.newAccount;
|
||||||
|
|
||||||
|
const isAccountNumberValid = isNotEmpty(
|
||||||
|
"accountNumber",
|
||||||
|
accountNumber,
|
||||||
|
setErrorMsgs,
|
||||||
|
"Please enter the account number"
|
||||||
|
);
|
||||||
|
const isAccountTypeValid = isNotEmpty(
|
||||||
|
"accountType",
|
||||||
|
accountType,
|
||||||
|
setErrorMsgs,
|
||||||
|
"Please select an account type"
|
||||||
|
);
|
||||||
|
const isBankValid = isNotEmpty(
|
||||||
|
"bank",
|
||||||
|
bank,
|
||||||
|
setErrorMsgs,
|
||||||
|
"Please enter the bank name"
|
||||||
|
);
|
||||||
|
const isCityValid = isNotEmpty(
|
||||||
|
"city",
|
||||||
|
city,
|
||||||
|
setErrorMsgs,
|
||||||
|
"Please enter the city"
|
||||||
|
);
|
||||||
|
const isCountryValid = isNotEmpty(
|
||||||
|
"country",
|
||||||
|
country,
|
||||||
|
setErrorMsgs,
|
||||||
|
"Please enter the country"
|
||||||
|
);
|
||||||
|
const isStateValid = isNotEmpty(
|
||||||
|
"state",
|
||||||
|
state,
|
||||||
|
setErrorMsgs,
|
||||||
|
"Please enter the state"
|
||||||
|
);
|
||||||
|
|
||||||
|
if (
|
||||||
|
!isAccountNumberValid ||
|
||||||
|
!isAccountTypeValid ||
|
||||||
|
!isBankValid ||
|
||||||
|
!isCityValid ||
|
||||||
|
!isCountryValid ||
|
||||||
|
!isStateValid
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setRequestStatus(true);
|
||||||
|
|
||||||
|
const stateData = {
|
||||||
|
amount: values.amount,
|
||||||
|
comment: values.comment,
|
||||||
|
choice: "new",
|
||||||
|
wallet_uid: wallet.wallet_uid,
|
||||||
|
...sendMoneyFee,
|
||||||
|
...values?.newAccount,
|
||||||
|
};
|
||||||
|
|
||||||
|
return setTimeout(() => {
|
||||||
|
setRequestStatus(false);
|
||||||
|
action();
|
||||||
|
setShowConfirmNairaWithdraw({ show: true, state: stateData });
|
||||||
|
}, 1000);
|
||||||
}
|
}
|
||||||
} catch (errors) {
|
} catch (errors) {
|
||||||
// If validation fails, handle the validation errors
|
// If validation fails, handle the validation errors
|
||||||
@@ -301,12 +369,13 @@ function NairaWithdraw({
|
|||||||
blurHandler={(e) => {
|
blurHandler={(e) => {
|
||||||
getSendMoneyFee(e);
|
getSendMoneyFee(e);
|
||||||
}}
|
}}
|
||||||
|
error={errorMsgs.amount && errorMsgs.amount}
|
||||||
/>
|
/>
|
||||||
{errorMsgs?.amount && (
|
{/* {errorMsgs?.amount && (
|
||||||
<p className="sm:text-sm text-[12px] text-red-500 sm:text-left text-right sm:translate-y-0 translate-y-1">
|
<p className="sm:text-sm text-[12px] text-red-500 sm:text-left text-right sm:translate-y-0 translate-y-1">
|
||||||
{errorMsgs.amount}
|
|
||||||
</p>
|
</p>
|
||||||
)}
|
)} */}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="field w-full">
|
<div className="field w-full">
|
||||||
@@ -485,7 +554,7 @@ function NairaWithdraw({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="h-[7.6rem]"></div>
|
<div className="h-[7.8rem]"></div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@@ -506,9 +575,11 @@ function NairaWithdraw({
|
|||||||
className="w-full text-base p-2 text-dark-gray dark:text-white border border-slate-300 outline-0 flex-[0.6] rounded-full h-[42px] overflow-hidden relative font-medium leading-6 bg-clip-padding"
|
className="w-full text-base p-2 text-dark-gray dark:text-white border border-slate-300 outline-0 flex-[0.6] rounded-full h-[42px] overflow-hidden relative font-medium leading-6 bg-clip-padding"
|
||||||
name="newAccount.country"
|
name="newAccount.country"
|
||||||
value={props.values.newAccount?.country}
|
value={props.values.newAccount?.country}
|
||||||
onChange={
|
onChange={(e) => {
|
||||||
props.handleChange || handleBankOptions
|
props.handleChange(e);
|
||||||
}
|
handleBankOptions(e);
|
||||||
|
}}
|
||||||
|
// onBlur={(e) => handleBankOptions(e)}
|
||||||
>
|
>
|
||||||
{allCountries.loading ? (
|
{allCountries.loading ? (
|
||||||
<option
|
<option
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ export default function Notification() {
|
|||||||
const indexOfLastItem = Number(indexOfFirstItem) + Number(process.env.REACT_APP_ITEM_PER_PAGE);
|
const indexOfLastItem = Number(indexOfFirstItem) + Number(process.env.REACT_APP_ITEM_PER_PAGE);
|
||||||
const currentNotifications = notificationData?.slice(indexOfFirstItem, indexOfLastItem);
|
const currentNotifications = notificationData?.slice(indexOfFirstItem, indexOfLastItem);
|
||||||
|
|
||||||
console.log('TESTING', currentNotifications)
|
|
||||||
const filterHandler = (value) => {
|
const filterHandler = (value) => {
|
||||||
setValue(value);
|
setValue(value);
|
||||||
switch(value){
|
switch(value){
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React, { useContext, useEffect, useMemo, useState } from "react";
|
import React, { useContext, useEffect, useMemo, useState } from "react";
|
||||||
import { Link, useLocation } from "react-router-dom";
|
import { Link, useLocation, useNavigate } from "react-router-dom";
|
||||||
import bank1 from "../../assets/images/bank-1.png";
|
import bank1 from "../../assets/images/bank-1.png";
|
||||||
import bank2 from "../../assets/images/bank-2.png";
|
import bank2 from "../../assets/images/bank-2.png";
|
||||||
import bank3 from "../../assets/images/bank-3.png";
|
import bank3 from "../../assets/images/bank-3.png";
|
||||||
@@ -29,6 +29,7 @@ export default function Header({ logoutModalHandler, sidebarHandler }) {
|
|||||||
const [myWalletList, setMyWalletList] = useState([]);
|
const [myWalletList, setMyWalletList] = useState([]);
|
||||||
const api = useMemo(() => new usersService(), []);
|
const api = useMemo(() => new usersService(), []);
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
const navigate = useNavigate()
|
||||||
|
|
||||||
const { notifications } = useSelector((state) => state?.notifications); // NOTIFICATION STORE
|
const { notifications } = useSelector((state) => state?.notifications); // NOTIFICATION STORE
|
||||||
|
|
||||||
@@ -317,9 +318,14 @@ export default function Header({ logoutModalHandler, sidebarHandler }) {
|
|||||||
<Link
|
<Link
|
||||||
to="/notification"
|
to="/notification"
|
||||||
className="text-purple text-sm font-medium"
|
className="text-purple text-sm font-medium"
|
||||||
|
onClick={handlerNotification}
|
||||||
>
|
>
|
||||||
See all Notification
|
See all Notification
|
||||||
</Link>
|
</Link>
|
||||||
|
{/* <button className="text-purple text-sm font-medium" onClick={()=>{
|
||||||
|
handlerNotification()
|
||||||
|
navigate('/notification', {replace: true})
|
||||||
|
}}>See all Notification</button> */}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
const checkAndSetError = (field, value, setErrorFunc, errorMessage) => {
|
||||||
|
const isNotEmpty = () => {
|
||||||
|
if (!value) {
|
||||||
|
setErrorFunc({ [field]: errorMessage });
|
||||||
|
setTimeout(() => setErrorFunc({ [field]: "" }), 1000);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const textCount = () => {
|
||||||
|
if (!value) {
|
||||||
|
setErrorFunc({ [field]: errorMessage });
|
||||||
|
setTimeout(() => setErrorFunc({ [field]: "" }), 1000);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return { isNotEmpty, textCount };
|
||||||
|
};
|
||||||
|
|
||||||
|
export default checkAndSetError;
|
||||||
+9
-1
@@ -1,5 +1,13 @@
|
|||||||
import ClearCookies from "./ClearCookies";
|
import ClearCookies from "./ClearCookies";
|
||||||
|
import checkAndSetError from "./checkAndSetError";
|
||||||
|
import formattedDate from "./fomattedDate";
|
||||||
import getTimeAgo from "./getTimeAgo";
|
import getTimeAgo from "./getTimeAgo";
|
||||||
import localImgLoad from "./localImgLoad";
|
import localImgLoad from "./localImgLoad";
|
||||||
|
|
||||||
export {ClearCookies, getTimeAgo, localImgLoad}
|
export {
|
||||||
|
ClearCookies,
|
||||||
|
checkAndSetError,
|
||||||
|
formattedDate,
|
||||||
|
getTimeAgo,
|
||||||
|
localImgLoad,
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user