Compare commits

..

5 Commits

Author SHA1 Message Date
victorAnumudu 187ac61396 logged information removed 2023-07-23 07:18:56 +01:00
victorAnumudu 31297efb5b closes notification menu when see all notifications is clicked 2023-07-23 07:15:25 +01:00
ameye f8d6475ff8 Merge branch 'my_wallet_layout' of WrenchBoard/Users-Wrench into master 2023-07-22 23:21:04 +00:00
Ebube 22a45ac15e Added some fixes 2023-07-23 00:12:26 +01:00
ameye 0489be5e69 Merge branch 'notifications' of WrenchBoard/Users-Wrench into master 2023-07-22 22:44:03 +00:00
6 changed files with 141 additions and 22 deletions
@@ -4,12 +4,10 @@ import { toast } from "react-toastify";
import InputCom from "../../Helpers/Inputs/InputCom";
import ModalCom from "../../Helpers/ModalCom";
import LoadingSpinner from "../../Spinners/LoadingSpinner";
import usersService from "../../../services/UsersService";
function ConfirmNairaWithdraw({ payment, wallet, action, situation, state }) {
const apiURL = new usersService();
const navigate = useNavigate();
let [requestStatus, setRequestStatus] = useState({
@@ -25,19 +23,35 @@ function ConfirmNairaWithdraw({ payment, wallet, action, situation, state }) {
let reqData = {
amount: Number(state.amount * 100),
Fee: Number(state.fee),
recipient_uid: Number(state.details?.recipient_uid),
recipient_uid: state.details?.recipient_uid,
wallet_uid: wallet.wallet_uid,
};
apiURL
.sendMoney(reqData)
.then((res) => {
if (res.data.internal_return < 0) {
setRequestStatus({
message: "Could not perform transaction",
loading: false,
status: false,
});
return;
if (res.data?.status_message?.toLowerCase().includes("limit")) {
setRequestStatus({
message: "You have exceeded the transfer limit",
loading: false,
status: false,
});
} else {
setRequestStatus({
message: "Could not perform transaction",
loading: false,
status: false,
});
}
return setTimeout(
() =>
setRequestStatus({
message: "",
loading: false,
status: false,
}),
1500
);
}
setRequestStatus({
message: "transfer successful",
@@ -59,7 +73,7 @@ function ConfirmNairaWithdraw({ payment, wallet, action, situation, state }) {
});
};
console.log(state)
console.log(state);
return (
<ModalCom action={action} situation={situation} className="edit-popup">
@@ -1,6 +1,7 @@
import { Form, Formik } from "formik";
import React, { useEffect, useState } from "react";
import { useNavigate } from "react-router-dom";
import { checkAndSetError } from "../../../lib";
import usersService from "../../../services/UsersService";
import InputCom from "../../Helpers/Inputs/InputCom";
import ModalCom from "../../Helpers/ModalCom";
@@ -33,6 +34,7 @@ function NairaWithdraw({
const [tab, setTab] = useState("previous");
let [requestStatus, setRequestStatus] = useState(false);
const [errorMsgs, setErrorMsgs] = useState(initialValues);
const { isNotEmpty, textCount } = checkAndSetError();
let [sendMoneyFee, setSendMoneyFee] = useState({
loading: false,
@@ -210,12 +212,13 @@ function NairaWithdraw({
const stateData = {
amount: values.amount,
comment: values.comment,
wallet_uid: wallet.wallet_uid,
choice: "prev",
wallet_uid: wallet.wallet_uid,
...sendMoneyFee,
details: { ...recipientDetails[0] },
};
setTimeout(() => {
return setTimeout(() => {
setRequestStatus(false);
// navigate("confirm-withdraw-naira", { state: stateData });
action();
@@ -226,6 +229,71 @@ function NairaWithdraw({
if (tab === "new") {
const { accountNumber, accountType, bank, city, country, state } =
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) {
// If validation fails, handle the validation errors
@@ -301,12 +369,13 @@ function NairaWithdraw({
blurHandler={(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">
{errorMsgs.amount}
</p>
)}
)} */}
</div>
<div className="field w-full">
@@ -485,7 +554,7 @@ function NairaWithdraw({
</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"
name="newAccount.country"
value={props.values.newAccount?.country}
onChange={
props.handleChange || handleBankOptions
}
onChange={(e) => {
props.handleChange(e);
handleBankOptions(e);
}}
// onBlur={(e) => handleBankOptions(e)}
>
{allCountries.loading ? (
<option
-1
View File
@@ -35,7 +35,6 @@ export default function Notification() {
const indexOfLastItem = Number(indexOfFirstItem) + Number(process.env.REACT_APP_ITEM_PER_PAGE);
const currentNotifications = notificationData?.slice(indexOfFirstItem, indexOfLastItem);
console.log('TESTING', currentNotifications)
const filterHandler = (value) => {
setValue(value);
switch(value){
+7 -1
View File
@@ -1,5 +1,5 @@
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 bank2 from "../../assets/images/bank-2.png";
import bank3 from "../../assets/images/bank-3.png";
@@ -29,6 +29,7 @@ export default function Header({ logoutModalHandler, sidebarHandler }) {
const [myWalletList, setMyWalletList] = useState([]);
const api = useMemo(() => new usersService(), []);
const dispatch = useDispatch();
const navigate = useNavigate()
const { notifications } = useSelector((state) => state?.notifications); // NOTIFICATION STORE
@@ -317,9 +318,14 @@ export default function Header({ logoutModalHandler, sidebarHandler }) {
<Link
to="/notification"
className="text-purple text-sm font-medium"
onClick={handlerNotification}
>
See all Notification
</Link>
{/* <button className="text-purple text-sm font-medium" onClick={()=>{
handlerNotification()
navigate('/notification', {replace: true})
}}>See all Notification</button> */}
</div>
</div>
</div>
+21
View File
@@ -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
View File
@@ -1,5 +1,13 @@
import ClearCookies from "./ClearCookies";
import checkAndSetError from "./checkAndSetError";
import formattedDate from "./fomattedDate";
import getTimeAgo from "./getTimeAgo";
import localImgLoad from "./localImgLoad";
export {ClearCookies, getTimeAgo, localImgLoad}
export {
ClearCookies,
checkAndSetError,
formattedDate,
getTimeAgo,
localImgLoad,
};