Round off USD value while displaying
This commit is contained in:
parent
eeed871583
commit
083feb4e55
@ -50,7 +50,7 @@ export default function PaymentModal({
|
|||||||
|
|
||||||
// Fetch payment amount based on USD price for both payment methods
|
// Fetch payment amount based on USD price for both payment methods
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isOpen || deploymentCost === null || !paymentMethod) return;
|
if (!isOpen || !deploymentCost || !paymentMethod) return;
|
||||||
|
|
||||||
const fetchPaymentAmount = async () => {
|
const fetchPaymentAmount = async () => {
|
||||||
setLoadingPrice(true);
|
setLoadingPrice(true);
|
||||||
@ -86,7 +86,7 @@ export default function PaymentModal({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
setError('');
|
setError('');
|
||||||
setTokenAmount(-1);
|
setTokenAmount(0);
|
||||||
}
|
}
|
||||||
}, [isOpen]);
|
}, [isOpen]);
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ export default function PaymentModal({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tokenAmount === -1 || loadingPrice) {
|
if (tokenAmount === 0 || loadingPrice) {
|
||||||
setError('Payment amount not ready. Please wait.');
|
setError('Payment amount not ready. Please wait.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -192,7 +192,7 @@ export default function PaymentModal({
|
|||||||
<div className="relative">
|
<div className="relative">
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
value={`$${deploymentCost}`}
|
value={`$${deploymentCost ? deploymentCost.toPrecision(2) : null}`}
|
||||||
disabled={true}
|
disabled={true}
|
||||||
className="w-full p-3 pr-12 rounded-md"
|
className="w-full p-3 pr-12 rounded-md"
|
||||||
style={{
|
style={{
|
||||||
|
@ -87,8 +87,5 @@ export const getCostOfDeployment = async (): Promise<number> => {
|
|||||||
const deploymentCostAlnt = parseFloat(deploymentCostRecord.amount); // ALNT required
|
const deploymentCostAlnt = parseFloat(deploymentCostRecord.amount); // ALNT required
|
||||||
|
|
||||||
// Calculate deployment cost in USD: (ALNT required) * (USD per ALNT)
|
// Calculate deployment cost in USD: (ALNT required) * (USD per ALNT)
|
||||||
const deploymentCostUsd = deploymentCostAlnt * alntPriceUsd;
|
return deploymentCostAlnt * alntPriceUsd;
|
||||||
|
|
||||||
// Return with 6 decimal precision
|
|
||||||
return parseFloat(deploymentCostUsd.toFixed(2));
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user