Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 30642bba14 | |||
| f5921612b8 | |||
| 38afece043 | |||
| d44447c6b3 | |||
| d942c6641a | |||
| beed565ba0 | |||
| 329e27b83d | |||
| 3145656d80 | |||
| 5098a45bd5 | |||
| 9e65a6e7d5 |
@@ -4,9 +4,12 @@ import InputCom from '../../../Helpers/Inputs/InputCom'
|
|||||||
import { Form, Formik } from "formik";
|
import { Form, Formik } from "formik";
|
||||||
import * as Yup from "yup";
|
import * as Yup from "yup";
|
||||||
|
|
||||||
|
import {AmountTo2DP} from '../../../Helpers/PriceFormatter'
|
||||||
import usersService from '../../../../services/UsersService';
|
import usersService from '../../../../services/UsersService';
|
||||||
import LoadingSpinner from '../../../Spinners/LoadingSpinner';
|
import LoadingSpinner from '../../../Spinners/LoadingSpinner';
|
||||||
import { PriceFormatter } from '../../../Helpers/PriceFormatter';
|
import { PriceFormatter } from '../../../Helpers/PriceFormatter';
|
||||||
|
import { tableReload } from '../../../../store/TableReloads';
|
||||||
|
import { useDispatch } from 'react-redux';
|
||||||
|
|
||||||
const validationSchema = Yup.object().shape({
|
const validationSchema = Yup.object().shape({
|
||||||
// amount: Yup.string()
|
// amount: Yup.string()
|
||||||
@@ -28,6 +31,8 @@ const validationSchema = Yup.object().shape({
|
|||||||
|
|
||||||
function FamilyAddFundPopout({action, situation, wallet, familyData}) {
|
function FamilyAddFundPopout({action, situation, wallet, familyData}) {
|
||||||
|
|
||||||
|
const dispatch = useDispatch()
|
||||||
|
|
||||||
const apiUrl = new usersService()
|
const apiUrl = new usersService()
|
||||||
|
|
||||||
const [startTransfer, setStartTransfer] = useState({loading:true, data: {}})
|
const [startTransfer, setStartTransfer] = useState({loading:true, data: {}})
|
||||||
@@ -38,7 +43,7 @@ function FamilyAddFundPopout({action, situation, wallet, familyData}) {
|
|||||||
// initial values for formik
|
// initial values for formik
|
||||||
let initialValues = {
|
let initialValues = {
|
||||||
amount: '',
|
amount: '',
|
||||||
from : startTransfer?.data?.origing_current_balance*0.01 || 'N/A',
|
from : AmountTo2DP(startTransfer?.data?.origing_current_balance*0.01),
|
||||||
to: `${familyData.firstname} ${familyData.lastname}`,
|
to: `${familyData.firstname} ${familyData.lastname}`,
|
||||||
comment: ''
|
comment: ''
|
||||||
};
|
};
|
||||||
@@ -54,7 +59,7 @@ function FamilyAddFundPopout({action, situation, wallet, familyData}) {
|
|||||||
wallet_uid : wallet.wallet_uid,
|
wallet_uid : wallet.wallet_uid,
|
||||||
origing_wallet_uid : startTransfer?.data?.origing_wallet_uid,
|
origing_wallet_uid : startTransfer?.data?.origing_wallet_uid,
|
||||||
currency : startTransfer?.data?.currency,
|
currency : startTransfer?.data?.currency,
|
||||||
amount : values.amount,
|
amount : values.amount*100,
|
||||||
description : values.comment,
|
description : values.comment,
|
||||||
family_transfer_mode : 100,
|
family_transfer_mode : 100,
|
||||||
action : 22014
|
action : 22014
|
||||||
@@ -75,14 +80,14 @@ function FamilyAddFundPopout({action, situation, wallet, familyData}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(values.amount > senderLimit*0.01){ // CHECKS TO SEE IF SENDER IS SENDING MORE THAN HIS LIMIT
|
if(values.amount > senderLimit*0.01){ // CHECKS TO SEE IF SENDER IS SENDING MORE THAN HIS LIMIT
|
||||||
setRequestStatus({loading:false, status:false, message:`You cannot exceed ${senderLimit*0.01}`})
|
setRequestStatus({loading:false, status:false, message:`You cannot exceed ${senderLimit*0.01} ${startTransfer?.data?.origing_currency.charAt(0).toUpperCase() + startTransfer?.data?.origing_currency.slice(1).toLowerCase()}`})
|
||||||
return setTimeout(()=>{
|
return setTimeout(()=>{
|
||||||
setRequestStatus({loading:false, status:false, message:''})
|
setRequestStatus({loading:false, status:false, message:''})
|
||||||
}, 5000)
|
}, 5000)
|
||||||
}
|
}
|
||||||
|
|
||||||
apiUrl.familyTransfer(reqData).then(({data}) => {
|
apiUrl.familyTransfer(reqData).then(({data}) => {
|
||||||
if(data.internal_return < 0){
|
if(data.internal_return < 0 || data.credit_confirm == '' || data.pay_confirm == ''){
|
||||||
setRequestStatus({loading:false, status:false, message:'Transfer Failed'})
|
setRequestStatus({loading:false, status:false, message:'Transfer Failed'})
|
||||||
return setTimeout(()=>{
|
return setTimeout(()=>{
|
||||||
setRequestStatus({loading:false, status:false, message:''})
|
setRequestStatus({loading:false, status:false, message:''})
|
||||||
@@ -91,6 +96,7 @@ function FamilyAddFundPopout({action, situation, wallet, familyData}) {
|
|||||||
setRequestStatus({loading:false, status:true, message:'Transfer Successful'})
|
setRequestStatus({loading:false, status:true, message:'Transfer Successful'})
|
||||||
setTimeout(()=>{
|
setTimeout(()=>{
|
||||||
setRequestStatus({loading:false, status:false, message:''})
|
setRequestStatus({loading:false, status:false, message:''})
|
||||||
|
dispatch(tableReload({ type: "WALLETTABLE" })); // UPDATES PARENT WALLET ACCOUNT
|
||||||
action() // TO CLOSE THE MODAL
|
action() // TO CLOSE THE MODAL
|
||||||
}, 5000)
|
}, 5000)
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
@@ -272,7 +278,8 @@ function FamilyAddFundPopout({action, situation, wallet, familyData}) {
|
|||||||
:
|
:
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
className="w-[150px] h-[48px] rounded-full text-base text-white bg-sky-500 hover:bg-sky-400"
|
className={`w-[150px] h-[48px] rounded-full text-base text-white bg-sky-500 hover:bg-sky-400 ${requestStatus.status ? 'opacity-50' : ''}`}
|
||||||
|
disabled={requestStatus.status}
|
||||||
>
|
>
|
||||||
Send
|
Send
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -50,3 +50,29 @@ export const PriceFormatter = (
|
|||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// FUNCTION TO RETURN AMOUNT TO TWO DECIMAL PLACES
|
||||||
|
export const AmountTo2DP = (
|
||||||
|
amount = "00",
|
||||||
|
) => {
|
||||||
|
// Convert the number to a string
|
||||||
|
let numStr = String(amount);
|
||||||
|
|
||||||
|
// Split the string into integer and decimal parts
|
||||||
|
let parts = numStr.split(".");
|
||||||
|
let integerPart = parts[0] || "";
|
||||||
|
let decimalPart = parts[1] || "";
|
||||||
|
|
||||||
|
// Add thousands separators to the integer part
|
||||||
|
let formattedInteger = integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||||
|
|
||||||
|
// Truncate or pad the decimal part to two decimal points
|
||||||
|
let formattedDecimal = decimalPart.slice(0, 2).padEnd(2, "0");
|
||||||
|
|
||||||
|
// Combine the formatted integer and decimal parts
|
||||||
|
let formattedNumber = formattedInteger + '.' + formattedDecimal;
|
||||||
|
|
||||||
|
// return formattedNumber;
|
||||||
|
return formattedNumber;
|
||||||
|
};
|
||||||
@@ -80,14 +80,16 @@ function CompleteConfirmCredit({ onClose, confirmCredit }) {
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center gap-8">
|
{isSuccess && (
|
||||||
<h1 className="text-xl font-bold text-dark-gray dark:text-white tracking-tighter my-1">
|
<div className="flex items-center gap-8">
|
||||||
Confirmation Number
|
<h1 className="text-xl font-bold text-dark-gray dark:text-white tracking-tighter my-1">
|
||||||
</h1>
|
Confirmation Number
|
||||||
<span className="text-xl font-bold text-dark-gray dark:text-white tracking-tighter my-1">
|
</h1>
|
||||||
{data?.confirmation}
|
<span className="text-xl font-bold text-dark-gray dark:text-white tracking-tighter my-1">
|
||||||
</span>
|
{data?.confirmation}
|
||||||
</div>
|
</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ const CreditPopup = ({ details, onClose, situation, walletItem }) => {
|
|||||||
|
|
||||||
const getTitle = () => {
|
const getTitle = () => {
|
||||||
if (confirmCredit?.show?.acceptConfirm?.state) {
|
if (confirmCredit?.show?.acceptConfirm?.state) {
|
||||||
if (confirmCredit?.data?.internal_return < 0) {
|
if (confirmCredit?.data?.internal_return <= 0) {
|
||||||
return "Credit Unsuccessful";
|
return "Credit Unsuccessful";
|
||||||
} else {
|
} else {
|
||||||
return "Credit Add Completed";
|
return "Credit Add Completed";
|
||||||
|
|||||||
Reference in New Issue
Block a user