Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d5e66618aa | |||
| 2e89f07ee2 | |||
| 9db7f5c985 | |||
| d56363276b | |||
| 5a9b49559b | |||
| fbc8228977 | |||
| a1140f7006 | |||
| f3561ff0fb | |||
| 42b792ab9d | |||
| 1e3a166172 | |||
| e1c6cb357e | |||
| 1aa64fba1f | |||
| 4f0a6f67c3 |
@@ -74,3 +74,9 @@ REACT_APP_LINKEDIN_SOCIAL_LOGIN=0
|
|||||||
|
|
||||||
#apigate.lotus.g1.wrenchboard.com:76.209.103.227
|
#apigate.lotus.g1.wrenchboard.com:76.209.103.227
|
||||||
#apigate.orion.g1.wrenchboard.com:76.209.103.227
|
#apigate.orion.g1.wrenchboard.com:76.209.103.227
|
||||||
|
|
||||||
|
|
||||||
|
REACT_APP_MAX_CREDIT_CARDS=4
|
||||||
|
REACT_APP_MAX_CREDIT_BANK_ACCOUNT=4
|
||||||
|
|
||||||
|
REACT_APP_MAX_FAMILY_MEMBERS=8
|
||||||
@@ -46,3 +46,8 @@ REACT_APP_LOGOUT_TEXT="Sign Out"
|
|||||||
|
|
||||||
REACT_APP_APPLE_SOCIAL_LOGIN=0
|
REACT_APP_APPLE_SOCIAL_LOGIN=0
|
||||||
REACT_APP_LINKEDIN_SOCIAL_LOGIN=0
|
REACT_APP_LINKEDIN_SOCIAL_LOGIN=0
|
||||||
|
|
||||||
|
REACT_APP_MAX_CREDIT_CARDS=4
|
||||||
|
REACT_APP_MAX_CREDIT_BANK_ACCOUNT=4
|
||||||
|
|
||||||
|
REACT_APP_MAX_FAMILY_MEMBERS=8
|
||||||
@@ -52,3 +52,8 @@ REACT_APP_TOTAL_NUM_FILE=4
|
|||||||
REACT_APP_LOGOUT_TEXT="Sign Out"
|
REACT_APP_LOGOUT_TEXT="Sign Out"
|
||||||
REACT_APP_APPLE_SOCIAL_LOGIN=0
|
REACT_APP_APPLE_SOCIAL_LOGIN=0
|
||||||
REACT_APP_LINKEDIN_SOCIAL_LOGIN=0
|
REACT_APP_LINKEDIN_SOCIAL_LOGIN=0
|
||||||
|
|
||||||
|
REACT_APP_MAX_CREDIT_CARDS=4
|
||||||
|
REACT_APP_MAX_CREDIT_BANK_ACCOUNT=4
|
||||||
|
|
||||||
|
REACT_APP_MAX_FAMILY_MEMBERS=8
|
||||||
@@ -1,20 +1,26 @@
|
|||||||
import React, { useCallback, useEffect, useState } from "react";
|
import React, { useCallback, useEffect, useState } from "react";
|
||||||
import { Link, useNavigate } from "react-router-dom";
|
import { Link, useLocation, useNavigate } from "react-router-dom";
|
||||||
import WrenchBoard from "../../../assets/images/wrenchboard-logo-text.png";
|
import WrenchBoard from "../../../assets/images/wrenchboard-logo-text.png";
|
||||||
import usersService from "../../../services/UsersService";
|
import usersService from "../../../services/UsersService";
|
||||||
import InputCom from "../../Helpers/Inputs/InputCom";
|
import InputCom from "../../Helpers/Inputs/InputCom";
|
||||||
import AuthLayout from "../AuthLayout";
|
import AuthLayout from "../AuthLayout";
|
||||||
|
|
||||||
export default function SignUp() {
|
export default function SignUp() {
|
||||||
|
const queryParams = new URLSearchParams(location?.search);
|
||||||
|
const country = queryParams.get("cnt")?.toUpperCase();
|
||||||
|
|
||||||
|
const {pathname} = useLocation()
|
||||||
|
const currentPath = country ? `${pathname}?cnt=${country.toLowerCase()}`:pathname // Determines the new pathname is country query params exist
|
||||||
|
|
||||||
const [signUpLoading, setSignUpLoading] = useState(false);
|
const [signUpLoading, setSignUpLoading] = useState(false);
|
||||||
const [checked, setValue] = useState(false);
|
const [checked, setValue] = useState(false);
|
||||||
// for the catch error
|
// for the catch error
|
||||||
const [msgError, setMsgError] = useState("");
|
const [msgError, setMsgError] = useState("");
|
||||||
const [showPassword, setShowPassword] = useState(false);
|
const [showPassword, setShowPassword] = useState(false);
|
||||||
const [countries, setCountries] = useState([]);
|
const [countries, setCountries] = useState({loading:true, data:[]});
|
||||||
|
|
||||||
const [formData, setFormData] = useState({
|
const [formData, setFormData] = useState({
|
||||||
country: "",
|
country: country? country : "",
|
||||||
first_name: "",
|
first_name: "",
|
||||||
last_name: "",
|
last_name: "",
|
||||||
email: "",
|
email: "",
|
||||||
@@ -45,9 +51,18 @@ export default function SignUp() {
|
|||||||
try {
|
try {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
const { signup_country } = await res.data;
|
const { signup_country } = await res.data;
|
||||||
setCountries(signup_country);
|
// setCountries(signup_country);
|
||||||
|
if(country){ // IF LINK/PATHNAME HAS CNT QUERY VALUE
|
||||||
|
let cnt = signup_country.filter(item => item[0]==country) // test to see country passed in query param exist from list of countries supplied by API
|
||||||
|
if(!cnt.length){ // IF CNT EMPTY, SET FORMDATA COUNTRY BACK TO EMPTY STRING: RE: THIS IS BCOS WE INITAIL SET COUNTRY VALUE IN FORMDATA, IF COUNTRY PARAM IS PRESENT IN LINK
|
||||||
|
setFormData(prev => ({...prev, country: ''}))
|
||||||
|
return setCountries({loading: false, data: signup_country});
|
||||||
|
}
|
||||||
|
return setCountries({loading: false, data: cnt});
|
||||||
|
}
|
||||||
|
setCountries({loading: false, data:signup_country});
|
||||||
} else if (res.data.result !== 100) {
|
} else if (res.data.result !== 100) {
|
||||||
setCountries("Nothing see here!");
|
setCountries({loading: false, data:[]});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(error);
|
throw new Error(error);
|
||||||
@@ -134,7 +149,7 @@ export default function SignUp() {
|
|||||||
<AuthLayout slogan="Welcome to WrenchBoard">
|
<AuthLayout slogan="Welcome to WrenchBoard">
|
||||||
<div className="w-full">
|
<div className="w-full">
|
||||||
<div className="mb-5">
|
<div className="mb-5">
|
||||||
<Link to="#">
|
<Link to={currentPath}>
|
||||||
<img
|
<img
|
||||||
src={WrenchBoard}
|
src={WrenchBoard}
|
||||||
alt="wrenchboard"
|
alt="wrenchboard"
|
||||||
@@ -172,6 +187,7 @@ export default function SignUp() {
|
|||||||
name="country"
|
name="country"
|
||||||
value={formData.country}
|
value={formData.country}
|
||||||
inputHandler={handleInputChange}
|
inputHandler={handleInputChange}
|
||||||
|
disable={country && countries?.data?.length <= 1 ? true : false}
|
||||||
/>
|
/>
|
||||||
<div className="input-fl-name mb-5 sm:flex w-full sm:space-x-6 ">
|
<div className="input-fl-name mb-5 sm:flex w-full sm:space-x-6 ">
|
||||||
<div className="input-item sm:w-1/2 w-full mb-5 sm:mb-0">
|
<div className="input-item sm:w-1/2 w-full mb-5 sm:mb-0">
|
||||||
@@ -306,6 +322,7 @@ export default function SignUp() {
|
|||||||
<div className="signin-area mb-1">
|
<div className="signin-area mb-1">
|
||||||
<div className="flex justify-center">
|
<div className="flex justify-center">
|
||||||
<button
|
<button
|
||||||
|
disabled={countries.loading}
|
||||||
type="button"
|
type="button"
|
||||||
onClick={handleSignUp}
|
onClick={handleSignUp}
|
||||||
className={`rounded-[0.475rem] mb-6 text-white flex justify-center bg-[#4687ba] hover:bg-[#009ef7] transition-all duration-300 items-center h-[42px] py-[0.8875rem] px-[1.81rem] text-[14.95px] btn-login`}
|
className={`rounded-[0.475rem] mb-6 text-white flex justify-center bg-[#4687ba] hover:bg-[#009ef7] transition-all duration-300 items-center h-[42px] py-[0.8875rem] px-[1.81rem] text-[14.95px] btn-login`}
|
||||||
@@ -333,6 +350,7 @@ const SelectOption = ({
|
|||||||
inputHandler,
|
inputHandler,
|
||||||
value,
|
value,
|
||||||
data, // passing the data from parent
|
data, // passing the data from parent
|
||||||
|
disable
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<div className="input-com mb-7">
|
<div className="input-com mb-7">
|
||||||
@@ -346,19 +364,39 @@ const SelectOption = ({
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<select
|
<select
|
||||||
|
disabled={disable}
|
||||||
name={name}
|
name={name}
|
||||||
id={name}
|
id={name}
|
||||||
className="input-wrapper border border-[#f5f8fa] dark:border-[#5e6278] w-full rounded-full h-[42px] overflow-hidden relative font-medium leading-6 bg-clip-padding text-[#5e6278] dark:text-gray-100 bg-[#f5f8fa] dark:bg-[#5e6278] text-base focus-visible:border-transparent focus-visible:outline-0 focus-visible:ring-transparent "
|
className="input-wrapper border border-[#f5f8fa] dark:border-[#5e6278] w-full rounded-full h-[42px] overflow-hidden relative font-medium leading-6 bg-clip-padding text-[#5e6278] dark:text-gray-100 bg-[#f5f8fa] dark:bg-[#5e6278] text-base focus-visible:border-transparent focus-visible:outline-0 focus-visible:ring-transparent "
|
||||||
onChange={inputHandler}
|
onChange={inputHandler}
|
||||||
value={value}
|
value={value}
|
||||||
>
|
>
|
||||||
|
{data?.data?.length > 1 ?
|
||||||
|
<>
|
||||||
<option value={""}>Select your Country</option>
|
<option value={""}>Select your Country</option>
|
||||||
{data?.length > 0 &&
|
{data?.data?.map((item, idx) => (
|
||||||
data?.map((item, idx) => (
|
|
||||||
<option value={item[0]} key={idx}>
|
<option value={item[0]} key={idx}>
|
||||||
{item[1]}
|
{item[1]}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
|
</>
|
||||||
|
:
|
||||||
|
data?.data?.length == 1 ?
|
||||||
|
data?.data?.map((item, idx) => (
|
||||||
|
<option value={item[0]} key={idx}>
|
||||||
|
{item[1]}
|
||||||
|
</option>
|
||||||
|
))
|
||||||
|
:
|
||||||
|
data?.data?.length < 1 && data.loading ?
|
||||||
|
<option value=''>
|
||||||
|
Loading...
|
||||||
|
</option>
|
||||||
|
:
|
||||||
|
<option value=''>
|
||||||
|
No Country Found!
|
||||||
|
</option>
|
||||||
|
}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -64,6 +64,8 @@ const initialValues = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function AddFundDollars(props) {
|
function AddFundDollars(props) {
|
||||||
|
let MaxNoOfCards = process.env.REACT_APP_MAX_CREDIT_CARDS // HOLDS THE VALUE OF THE MAX NUMBER OF CARDS USER CAN ADD
|
||||||
|
|
||||||
const apiCall = new usersService();
|
const apiCall = new usersService();
|
||||||
let countryWallet = props.walletItem.country;
|
let countryWallet = props.walletItem.country;
|
||||||
const [tab, setTab] = useState("previous");
|
const [tab, setTab] = useState("previous");
|
||||||
@@ -240,7 +242,7 @@ function AddFundDollars(props) {
|
|||||||
<label
|
<label
|
||||||
onClick={() => setTab("new")}
|
onClick={() => setTab("new")}
|
||||||
htmlFor="new"
|
htmlFor="new"
|
||||||
className="cursor-pointer flex items-center gap-1"
|
className={`cursor-pointer flex items-center gap-1 ${payListCards.data.length >= MaxNoOfCards ? 'pointer-events-none':''}`}
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
id="new"
|
id="new"
|
||||||
@@ -251,7 +253,7 @@ function AddFundDollars(props) {
|
|||||||
tab == "new" ? "" : ""
|
tab == "new" ? "" : ""
|
||||||
} tracking-wide transition duration-200`}
|
} tracking-wide transition duration-200`}
|
||||||
/>
|
/>
|
||||||
Add New Card
|
Add New Card {payListCards.data.length >= MaxNoOfCards && <span className="text-[14px] text-red-500">Max Reached</span>}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
@@ -314,6 +316,11 @@ function AddFundDollars(props) {
|
|||||||
|
|
||||||
{tab === "new" && (
|
{tab === "new" && (
|
||||||
<div className="new-details w-full max-h-[22rem]">
|
<div className="new-details w-full max-h-[22rem]">
|
||||||
|
{payListCards.loading ?
|
||||||
|
<div className="pt-10 flex w-full h-full justify-center items-center">
|
||||||
|
<LoadingSpinner size='10' color='sky-blue' />
|
||||||
|
</div>
|
||||||
|
:payListCards.data.length < MaxNoOfCards ?
|
||||||
<div className="w-full flex flex-col justify-between">
|
<div className="w-full flex flex-col justify-between">
|
||||||
<Formik
|
<Formik
|
||||||
initialValues={initialValues}
|
initialValues={initialValues}
|
||||||
@@ -553,6 +560,9 @@ function AddFundDollars(props) {
|
|||||||
}}
|
}}
|
||||||
</Formik>
|
</Formik>
|
||||||
</div>
|
</div>
|
||||||
|
:
|
||||||
|
null
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import React from "react";
|
|
||||||
|
|
||||||
function CompleteConfirmCredit({ onClose, confirmCredit }) {
|
function CompleteConfirmCredit({ onClose, confirmCredit }) {
|
||||||
const { data } = confirmCredit;
|
const { data } = confirmCredit;
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -7,25 +7,32 @@ import usersService from "../../../services/UsersService";
|
|||||||
import { tableReload } from "../../../store/TableReloads";
|
import { tableReload } from "../../../store/TableReloads";
|
||||||
import LoadingSpinner from "../../Spinners/LoadingSpinner";
|
import LoadingSpinner from "../../Spinners/LoadingSpinner";
|
||||||
|
|
||||||
|
|
||||||
function ThePaymentText({ value, type }) {
|
function ThePaymentText({ value, type }) {
|
||||||
const cardDetails = value;
|
const { cardNum } = value;
|
||||||
value.description =
|
let description = value.description;
|
||||||
type === "new"
|
let digits = value.digits;
|
||||||
? cardDetails.cardNum[0] === "4"
|
|
||||||
? "Visa"
|
if (type === "new") {
|
||||||
: cardDetails.cardNum[0] == "5"
|
const firstDigit = cardNum[0];
|
||||||
? "Master"
|
if (firstDigit === "4") {
|
||||||
: "ATM"
|
description = "Visa";
|
||||||
: value.description;
|
} else if (firstDigit === "5") {
|
||||||
value.digits = type === "new" ? cardDetails.cardNum.slice(-4) : value.digits;
|
description = "Master";
|
||||||
|
} else {
|
||||||
|
description = "ATM";
|
||||||
|
}
|
||||||
|
digits = cardNum.slice(-4);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="my-2 flex items-center gap-5">
|
<div className="my-2 flex items-center gap-5">
|
||||||
<div className="card-details flex items-center gap-3">
|
<div className="card-details flex items-center gap-3">
|
||||||
<h1 className="text-xl font-bold text-dark-gray dark:text-white tracking-tighter my-1 space-x-1">
|
<h1 className="text-xl font-normal text-dark-gray dark:text-white tracking-tighter my-1 space-x-1">
|
||||||
{value.description} Card
|
{description} Card
|
||||||
</h1>
|
</h1>
|
||||||
<p className="text-base font-bold text-dark-gray dark:text-white tracking-wide">
|
<p className="text-xl font-normal text-dark-gray dark:text-white tracking-wide">
|
||||||
Bank **************{value.digits}
|
Bank **************{digits}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -41,7 +48,7 @@ function AmountSection({ currency, amount, country }) {
|
|||||||
<h1 className="text-xl font-bold text-dark-gray dark:text-white tracking-tighter my-1">
|
<h1 className="text-xl font-bold text-dark-gray dark:text-white tracking-tighter my-1">
|
||||||
Amount({currency})
|
Amount({currency})
|
||||||
</h1>
|
</h1>
|
||||||
<span className="text-xl font-bold text-dark-gray dark:text-white tracking-tighter my-1">
|
<span className="text-xl font-normal text-dark-gray dark:text-white tracking-tighter my-1">
|
||||||
{formattedAmount}
|
{formattedAmount}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -59,7 +66,7 @@ function TransactionFeeSection({ currency, fee, country }) {
|
|||||||
<h1 className="text-xl font-bold text-dark-gray dark:text-white tracking-tighter my-1">
|
<h1 className="text-xl font-bold text-dark-gray dark:text-white tracking-tighter my-1">
|
||||||
Transaction Fee
|
Transaction Fee
|
||||||
</h1>
|
</h1>
|
||||||
<span className="text-xl font-bold text-dark-gray dark:text-white tracking-tighter my-1">
|
<span className="text-xl font-normal text-dark-gray dark:text-white tracking-tighter my-1">
|
||||||
{formattedFee}
|
{formattedFee}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -78,7 +85,7 @@ function TotalSection({ currency, amount, fee, country }) {
|
|||||||
<h1 className="text-xl font-bold text-dark-gray dark:text-white tracking-tighter my-1">
|
<h1 className="text-xl font-bold text-dark-gray dark:text-white tracking-tighter my-1">
|
||||||
Total
|
Total
|
||||||
</h1>
|
</h1>
|
||||||
<span className="text-xl font-bold text-dark-gray dark:text-white tracking-tighter my-1">
|
<span className="text-xl font-normal text-dark-gray dark:text-white tracking-tighter my-1">
|
||||||
{formattedTotal}
|
{formattedTotal}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -127,7 +134,7 @@ function ConfirmAddFund({
|
|||||||
logo: "https://www.wrenchboard.com/assets/images/wrench-500-500-icon.png",
|
logo: "https://www.wrenchboard.com/assets/images/wrench-500-500-icon.png",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
//debugger;
|
|
||||||
const fwConfig = {
|
const fwConfig = {
|
||||||
...config,
|
...config,
|
||||||
text: "Proceed",
|
text: "Proceed",
|
||||||
@@ -188,10 +195,27 @@ function ConfirmAddFund({
|
|||||||
|
|
||||||
const debouncedSuccessPayment = debounce(onSuccessPayment, 5000);
|
const debouncedSuccessPayment = debounce(onSuccessPayment, 5000);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the process of making a payment using a previously saved card.
|
||||||
|
* Updates the state to show a loader while the payment is being processed,
|
||||||
|
* sends a request to the server to make the payment, and updates the state with the response.
|
||||||
|
* If the payment is successful, it also dispatches an action to reload the wallet table.
|
||||||
|
*/
|
||||||
const handlePrevCard = async () => {
|
const handlePrevCard = async () => {
|
||||||
|
try {
|
||||||
|
// Show loader while the payment is being processed
|
||||||
|
setConfirmCredit((prev) => ({
|
||||||
|
...prev,
|
||||||
|
show: {
|
||||||
|
acceptConfirm: { loader: true },
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Extract necessary data from confirmCredit and confirmCardDetails objects
|
||||||
const { amount, credit_reference, currency } = __confirmData;
|
const { amount, credit_reference, currency } = __confirmData;
|
||||||
const { card_uid } = __confirmCardDetails;
|
const { card_uid } = __confirmCardDetails;
|
||||||
|
|
||||||
|
// Create request data object with required parameters for making the payment
|
||||||
const reqData = {
|
const reqData = {
|
||||||
amount: amount * 100,
|
amount: amount * 100,
|
||||||
card_uid,
|
card_uid,
|
||||||
@@ -199,16 +223,12 @@ function ConfirmAddFund({
|
|||||||
currency,
|
currency,
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
// Send request to server to make the payment using getPaidPrevCard method of usersService
|
||||||
setConfirmCredit((prev) => ({
|
|
||||||
...prev,
|
|
||||||
show: {
|
|
||||||
acceptConfirm: { loader: true },
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
const res = await apiURL.getPaidPrevCard(reqData);
|
const res = await apiURL.getPaidPrevCard(reqData);
|
||||||
const _response = res.data;
|
const _response = res.data;
|
||||||
if (res.data.internal_return < 0) {
|
|
||||||
|
// If internal_return value in the response is less than 0, hide the loader and return
|
||||||
|
if (_response.internal_return < 0) {
|
||||||
setConfirmCredit((prev) => ({
|
setConfirmCredit((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
show: {
|
show: {
|
||||||
@@ -218,6 +238,7 @@ function ConfirmAddFund({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update state to show the acceptConfirm state and the response data
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setConfirmCredit((prev) => ({
|
setConfirmCredit((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
@@ -227,9 +248,11 @@ function ConfirmAddFund({
|
|||||||
},
|
},
|
||||||
data: _response,
|
data: _response,
|
||||||
}));
|
}));
|
||||||
|
// Dispatch an action to reload the wallet table
|
||||||
dispatch(tableReload({ type: "WALLETTABLE" }));
|
dispatch(tableReload({ type: "WALLETTABLE" }));
|
||||||
}, 1500);
|
}, 1500);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
// Handle error and hide the loader
|
||||||
setConfirmCredit((prev) => ({
|
setConfirmCredit((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
show: {
|
show: {
|
||||||
@@ -240,11 +263,25 @@ function ConfirmAddFund({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the payment process when a new card is used.
|
||||||
|
* @async
|
||||||
|
*/
|
||||||
const handleNewCard = async () => {
|
const handleNewCard = async () => {
|
||||||
|
try {
|
||||||
|
// Extract necessary data from __confirmData and __confirmCardDetails
|
||||||
const { amount, credit_reference, uid } = __confirmData;
|
const { amount, credit_reference, uid } = __confirmData;
|
||||||
const { address, cardNum, cvv, expirationMonth, expirationYear } =
|
const { address, cardNum, cvv, expirationMonth, expirationYear } = __confirmCardDetails;
|
||||||
__confirmCardDetails;
|
|
||||||
|
|
||||||
|
// Set loading state to indicate payment is being processed
|
||||||
|
setConfirmCredit((prev) => ({
|
||||||
|
...prev,
|
||||||
|
show: {
|
||||||
|
acceptConfirm: { loader: true },
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Prepare request data
|
||||||
const reqData = {
|
const reqData = {
|
||||||
amount: amount * 100,
|
amount: amount * 100,
|
||||||
cardnumber: cardNum.replace(/\s/g, ""),
|
cardnumber: cardNum.replace(/\s/g, ""),
|
||||||
@@ -257,16 +294,13 @@ function ConfirmAddFund({
|
|||||||
uid,
|
uid,
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
// Send request to server to process payment
|
||||||
setConfirmCredit((prev) => ({
|
|
||||||
...prev,
|
|
||||||
show: {
|
|
||||||
acceptConfirm: { loader: true },
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
const res = await apiURL.getPaidNewCard(reqData);
|
const res = await apiURL.getPaidNewCard(reqData);
|
||||||
const _response = res.data;
|
const _response = res.data;
|
||||||
|
|
||||||
|
// Handle response from server
|
||||||
if (res.data.internal_return < 0) {
|
if (res.data.internal_return < 0) {
|
||||||
|
// Payment could not be completed
|
||||||
setConfirmCredit((prev) => ({
|
setConfirmCredit((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
show: {
|
show: {
|
||||||
@@ -275,9 +309,8 @@ function ConfirmAddFund({
|
|||||||
},
|
},
|
||||||
data: _response,
|
data: _response,
|
||||||
}));
|
}));
|
||||||
return;
|
} else {
|
||||||
}
|
// Payment was successful
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
setConfirmCredit((prev) => ({
|
setConfirmCredit((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
@@ -287,9 +320,12 @@ function ConfirmAddFund({
|
|||||||
},
|
},
|
||||||
data: _response,
|
data: _response,
|
||||||
}));
|
}));
|
||||||
|
console.log("Show meeeeeeeeee");
|
||||||
dispatch(tableReload({ type: "WALLETTABLE" }));
|
dispatch(tableReload({ type: "WALLETTABLE" }));
|
||||||
}, 1500);
|
}, 1500);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
// Handle error during payment process
|
||||||
setConfirmCredit((prev) => ({
|
setConfirmCredit((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
show: {
|
show: {
|
||||||
@@ -362,7 +398,7 @@ function ConfirmAddFund({
|
|||||||
<h1 className="text-xl font-bold text-dark-gray dark:text-white tracking-tighter my-1">
|
<h1 className="text-xl font-bold text-dark-gray dark:text-white tracking-tighter my-1">
|
||||||
Reference No
|
Reference No
|
||||||
</h1>
|
</h1>
|
||||||
<span className="text-xl font-bold text-dark-gray dark:text-white tracking-tighter my-1">
|
<span className="text-xl font-normal text-dark-gray dark:text-white tracking-tighter my-1">
|
||||||
{__confirmData?.credit_reference}
|
{__confirmData?.credit_reference}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import CompleteConfirmCredit from "./CompleteConfirmCredit";
|
|||||||
import ConfirmAddFund from "./ConfirmAddFund";
|
import ConfirmAddFund from "./ConfirmAddFund";
|
||||||
|
|
||||||
const CreditPopup = ({ details, onClose, situation, walletItem }) => {
|
const CreditPopup = ({ details, onClose, situation, walletItem }) => {
|
||||||
let [input, setInput] = useState("");
|
const [input, setInput] = useState("");
|
||||||
const [confirmCredit, setConfirmCredit] = useState({
|
const [confirmCredit, setConfirmCredit] = useState({
|
||||||
show: {
|
show: {
|
||||||
awaitConfirm: { loader: false, state: false },
|
awaitConfirm: { loader: false, state: false },
|
||||||
@@ -15,6 +15,8 @@ const CreditPopup = ({ details, onClose, situation, walletItem }) => {
|
|||||||
data: {},
|
data: {},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log(confirmCredit);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalCom
|
<ModalCom
|
||||||
action={onClose}
|
action={onClose}
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ function NairaWithdraw({
|
|||||||
state,
|
state,
|
||||||
setShowConfirmNairaWithdraw,
|
setShowConfirmNairaWithdraw,
|
||||||
}) {
|
}) {
|
||||||
|
|
||||||
|
let MaxNoOfBanks = process.env.REACT_APP_MAX_CREDIT_BANK_ACCOUNT // HOLDS THE VALUE OF THE MAX NUMBER OF BANKS USER CAN ADD
|
||||||
const apiCall = new usersService();
|
const apiCall = new usersService();
|
||||||
const [tab, setTab] = useState("previous");
|
const [tab, setTab] = useState("previous");
|
||||||
let [requestStatus, setRequestStatus] = useState(false);
|
let [requestStatus, setRequestStatus] = useState(false);
|
||||||
@@ -422,7 +424,7 @@ function NairaWithdraw({
|
|||||||
<label
|
<label
|
||||||
onClick={() => setTab("new")}
|
onClick={() => setTab("new")}
|
||||||
htmlFor="new"
|
htmlFor="new"
|
||||||
className="cursor-pointer flex items-center gap-1"
|
className={`cursor-pointer flex items-center gap-1 ${recipients.data.length >= MaxNoOfBanks ? 'pointer-events-none':''}`}
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
id="new"
|
id="new"
|
||||||
@@ -434,7 +436,7 @@ function NairaWithdraw({
|
|||||||
tab == "new" ? "" : ""
|
tab == "new" ? "" : ""
|
||||||
} tracking-wide transition duration-200`}
|
} tracking-wide transition duration-200`}
|
||||||
/>
|
/>
|
||||||
New Account{" "}
|
New Account{" "} {recipients.data.length >= MaxNoOfBanks && <span className="text-[14px] text-red-500">Max Reached</span>}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -522,6 +524,11 @@ function NairaWithdraw({
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{tab == "new" && (
|
{tab == "new" && (
|
||||||
|
recipients.loading ?
|
||||||
|
<div className="mt-3 flex flex-col w-full h-[188px] justify-center items-center">
|
||||||
|
<LoadingSpinner size='10' color='sky-blue' />
|
||||||
|
</div>
|
||||||
|
:recipients.data.length < MaxNoOfBanks ?
|
||||||
<div className="w-full mt-3 rounded-md bg-slate-100">
|
<div className="w-full mt-3 rounded-md bg-slate-100">
|
||||||
<div className="relative fields w-full flex flex-col p-4">
|
<div className="relative fields w-full flex flex-col p-4">
|
||||||
<div className="flex flex-[2] min-h-[52px]">
|
<div className="flex flex-[2] min-h-[52px]">
|
||||||
@@ -789,6 +796,8 @@ function NairaWithdraw({
|
|||||||
{/* end of inputs for new accounts */}
|
{/* end of inputs for new accounts */}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
:
|
||||||
|
<div className="mt-3 flex w-full h-[188px] justify-center items-center"></div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,10 @@ export default function WalletBox({ wallet, payment }) {
|
|||||||
</div>
|
</div>
|
||||||
) : wallet.data.length ? (
|
) : wallet.data.length ? (
|
||||||
wallet.data.map((item, index) => (
|
wallet.data.map((item, index) => (
|
||||||
<div key={item.wallet_uid} className="lg:w-full h-full mb-10 lg:mb-0">
|
<div
|
||||||
|
key={item.wallet_uid}
|
||||||
|
className="lg:w-full h-full mb-10 lg:mb-0"
|
||||||
|
>
|
||||||
<WalletItemCard walletItem={item} payment={payment} />
|
<WalletItemCard walletItem={item} payment={payment} />
|
||||||
</div>
|
</div>
|
||||||
))
|
))
|
||||||
|
|||||||
@@ -7,10 +7,6 @@ import CreditPopup from "./Popup/CreditPopup";
|
|||||||
import WalletAction from "./WalletAction";
|
import WalletAction from "./WalletAction";
|
||||||
|
|
||||||
export default function WalletItemCard({ walletItem, payment }) {
|
export default function WalletItemCard({ walletItem, payment }) {
|
||||||
// const [eth] = useState(90);
|
|
||||||
// const [btc] = useState(85);
|
|
||||||
// const [ltc] = useState(20);
|
|
||||||
|
|
||||||
const { userDetails } = useSelector((state) => state?.userDetails);
|
const { userDetails } = useSelector((state) => state?.userDetails);
|
||||||
let accountType = userDetails?.account_type == "FAMILY";
|
let accountType = userDetails?.account_type == "FAMILY";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user