From d88b4c9d5dc89510dba4970d76d7b983a7052308 Mon Sep 17 00:00:00 2001 From: EnzoVezzaro Date: Thu, 20 Oct 2022 08:17:36 -0400 Subject: [PATCH] fix code after prev merge --- src/components/@shared/ButtonBuy/index.tsx | 36 ++++++++++------------ 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/components/@shared/ButtonBuy/index.tsx b/src/components/@shared/ButtonBuy/index.tsx index 695465bb7..e4cf71940 100644 --- a/src/components/@shared/ButtonBuy/index.tsx +++ b/src/components/@shared/ButtonBuy/index.tsx @@ -3,6 +3,7 @@ import Button from '../atoms/Button' import styles from './index.module.css' import Loader from '../atoms/Loader' import { useWeb3 } from '@context/Web3' +import Web3 from 'web3' interface ButtonBuyProps { action: 'download' | 'compute' @@ -33,7 +34,6 @@ interface ButtonBuyProps { hasProviderFee?: boolean } -// TODO: we need to take a look at these messages function getConsumeHelpText( btSymbol: string, dtBalance: string, @@ -45,7 +45,7 @@ function getConsumeHelpText( isBalanceSufficient: boolean, consumableFeedback: string, isSupportedOceanNetwork: boolean, - web3: any + web3: Web3 ) { const text = isConsumable === false @@ -68,10 +68,9 @@ function getAlgoHelpText( hasPreviousOrderSelectedComputeAsset: boolean, selectedComputeAssetType: string, hasDatatokenSelectedComputeAsset: boolean, - selectedComputeAssettLowPoolLiquidity: boolean, isBalanceSufficient: boolean, isSupportedOceanNetwork: boolean, - web3: any + web3: Web3 ) { const text = (!dtSymbolSelectedComputeAsset && !dtBalanceSelectedComputeAsset) || @@ -82,8 +81,6 @@ function getAlgoHelpText( ? `You already bought the selected ${selectedComputeAssetType}, allowing you to use it without paying again.` : hasDatatokenSelectedComputeAsset ? `You own ${dtBalanceSelectedComputeAsset} ${dtSymbolSelectedComputeAsset} allowing you to use the selected ${selectedComputeAssetType} by spending 1 ${dtSymbolSelectedComputeAsset}, but without paying OCEAN again.` - : selectedComputeAssettLowPoolLiquidity - ? `There are not enought ${dtSymbolSelectedComputeAsset} available in the pool for the transaction to take place` : web3 && !isSupportedOceanNetwork ? `Connect to the correct network to interact with this asset.` : isBalanceSufficient === false @@ -109,7 +106,7 @@ function getComputeAssetHelpText( selectedComputeAssetType?: string, isAlgorithmConsumable?: boolean, isSupportedOceanNetwork?: boolean, - web3?: any, + web3?: Web3, hasProviderFee?: boolean ) { const computeAssetHelpText = getConsumeHelpText( @@ -126,18 +123,19 @@ function getComputeAssetHelpText( web3 ) - const computeAlgoHelpText = - (!dtSymbolSelectedComputeAsset && !dtBalanceSelectedComputeAsset) || - isConsumable === false || - isAlgorithmConsumable === false - ? '' - : hasPreviousOrderSelectedComputeAsset - ? `You already bought the selected ${selectedComputeAssetType}, allowing you to use it without paying again.` - : hasDatatokenSelectedComputeAsset - ? `You own ${dtBalanceSelectedComputeAsset} ${dtSymbolSelectedComputeAsset} allowing you to use the selected ${selectedComputeAssetType} by spending 1 ${dtSymbolSelectedComputeAsset}, but without paying ${btSymbol} again.` - : isBalanceSufficient === false - ? '' - : `Additionally, you will buy 1 ${dtSymbolSelectedComputeAsset} for the ${selectedComputeAssetType} and spend it back to its publisher.` + const computeAlgoHelpText = getAlgoHelpText( + dtSymbolSelectedComputeAsset, + dtBalanceSelectedComputeAsset, + isConsumable, + isAlgorithmConsumable, + hasPreviousOrderSelectedComputeAsset, + selectedComputeAssetType, + hasDatatokenSelectedComputeAsset, + isBalanceSufficient, + isSupportedOceanNetwork, + web3 + ) + const providerFeeHelpText = hasProviderFee ? 'In order to start the job you also need to pay the fees for renting the c2d resources.' : 'C2D resources required to start the job are available, no payment required for those fees.'