Check balance after loading iframe
This commit is contained in:
parent
10569f0ece
commit
4ba3b86c39
@ -1,4 +1,4 @@
|
|||||||
import { useEffect } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
|
|
||||||
import { Modal } from '@mui/material';
|
import { Modal } from '@mui/material';
|
||||||
|
|
||||||
@ -22,12 +22,17 @@ const CheckBalanceIframe = ({
|
|||||||
IFRAME_ID,
|
IFRAME_ID,
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
const [isLoaded, setIsLoaded] = useState(false);
|
||||||
checkBalance();
|
|
||||||
}, [amount, checkBalance]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isPollingEnabled || isBalanceSufficient) {
|
if (!isLoaded) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
checkBalance();
|
||||||
|
}, [amount, checkBalance, isLoaded]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!isPollingEnabled || !isLoaded || isBalanceSufficient) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +43,7 @@ const CheckBalanceIframe = ({
|
|||||||
return () => {
|
return () => {
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
};
|
};
|
||||||
}, [isBalanceSufficient, isPollingEnabled, checkBalance]);
|
}, [isBalanceSufficient, isPollingEnabled, checkBalance, isLoaded]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
onBalanceChange(isBalanceSufficient);
|
onBalanceChange(isBalanceSufficient);
|
||||||
@ -47,7 +52,7 @@ const CheckBalanceIframe = ({
|
|||||||
return (
|
return (
|
||||||
<Modal open={false} disableEscapeKeyDown keepMounted>
|
<Modal open={false} disableEscapeKeyDown keepMounted>
|
||||||
<iframe
|
<iframe
|
||||||
onLoad={checkBalance}
|
onLoad={() => setIsLoaded(true)}
|
||||||
id={IFRAME_ID}
|
id={IFRAME_ID}
|
||||||
src={VITE_WALLET_IFRAME_URL}
|
src={VITE_WALLET_IFRAME_URL}
|
||||||
width="100%"
|
width="100%"
|
||||||
|
@ -95,6 +95,9 @@ const Configure = () => {
|
|||||||
if (selectedOption === 'LRN') {
|
if (selectedOption === 'LRN') {
|
||||||
amount = selectedDeployer?.minimumPayment?.toString() ?? '0';
|
amount = selectedDeployer?.minimumPayment?.toString() ?? '0';
|
||||||
} else {
|
} else {
|
||||||
|
if (!selectedNumProviders) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
const bigMaxPrice = BigNumber.from(selectedMaxPrice);
|
const bigMaxPrice = BigNumber.from(selectedMaxPrice);
|
||||||
amount = bigMaxPrice.mul(selectedNumProviders).toString();
|
amount = bigMaxPrice.mul(selectedNumProviders).toString();
|
||||||
}
|
}
|
||||||
@ -635,7 +638,11 @@ const Configure = () => {
|
|||||||
onClick={(e: any) => {
|
onClick={(e: any) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
setBalanceMessage('Waiting for payment');
|
setBalanceMessage('Waiting for payment');
|
||||||
window.open('https://store.laconic.com', '_blank', 'noopener,noreferrer');
|
window.open(
|
||||||
|
'https://store.laconic.com',
|
||||||
|
'_blank',
|
||||||
|
'noopener,noreferrer',
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Buy prepaid service
|
Buy prepaid service
|
||||||
@ -665,7 +672,11 @@ const Configure = () => {
|
|||||||
setIsDataReceived={setIsAccountsDataReceived}
|
setIsDataReceived={setIsAccountsDataReceived}
|
||||||
isVisible={isFrameVisible}
|
isVisible={isFrameVisible}
|
||||||
/>
|
/>
|
||||||
<CheckBalanceIframe onBalanceChange={setIsBalanceSufficient} amount={amountToBePaid} isPollingEnabled={true} />
|
<CheckBalanceIframe
|
||||||
|
onBalanceChange={setIsBalanceSufficient}
|
||||||
|
amount={amountToBePaid}
|
||||||
|
isPollingEnabled={true}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user