mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
fix run order
This commit is contained in:
parent
8d8336d169
commit
c8ab797e02
@ -29,7 +29,7 @@ export default function Price({
|
||||
async function init() {
|
||||
const price = await getBestPrice(ddo.dataToken)
|
||||
setPrice(price)
|
||||
setPriceOutside && setPriceOutside(price)
|
||||
setPriceOutside && price !== '' && setPriceOutside(price)
|
||||
}
|
||||
init()
|
||||
}, [chainId])
|
||||
|
@ -33,22 +33,23 @@ export default function Compute({ ddo }: { ddo: DDO }): ReactElement {
|
||||
const [algorithmRawCode, setAlgorithmRawCode] = useState('')
|
||||
const [isPublished, setIsPublished] = useState(false)
|
||||
const [file, setFile] = useState(null)
|
||||
const [isTermsAgreed, setIsTermsAgreed] = useState(true)
|
||||
const [price, setPrice] = useState<string>()
|
||||
|
||||
const isFree = price === '0'
|
||||
|
||||
const isComputeButtonDisabled =
|
||||
isJobStarting ||
|
||||
file === null ||
|
||||
computeType === '' ||
|
||||
!ocean ||
|
||||
!isBalanceSufficient ||
|
||||
!isTermsAgreed
|
||||
!isBalanceSufficient
|
||||
|
||||
useEffect(() => {
|
||||
if (!price || !balance || !balance.ocean) return
|
||||
setIsBalanceSufficient(compareAsBN(balance.ocean, price, Comparison.gte))
|
||||
|
||||
const isFree = price === '0'
|
||||
|
||||
setIsBalanceSufficient(
|
||||
isFree ? true : compareAsBN(balance.ocean, price, Comparison.gte)
|
||||
)
|
||||
|
||||
return () => {
|
||||
setIsBalanceSufficient(false)
|
||||
@ -123,7 +124,6 @@ export default function Compute({ ddo }: { ddo: DDO }): ReactElement {
|
||||
Start job
|
||||
</Button>
|
||||
</div>
|
||||
{/* <TermsCheckbox onChange={onCheck} /> */}
|
||||
</div>
|
||||
|
||||
<footer className={styles.feedback}>
|
||||
|
@ -22,13 +22,15 @@ export default function Consume({
|
||||
const [price, setPrice] = useState<string>()
|
||||
const [isBalanceSufficient, setIsBalanceSufficient] = useState(false)
|
||||
|
||||
const isFree = price === '0'
|
||||
const isDisabled = !ocean || !isBalanceSufficient
|
||||
|
||||
useEffect(() => {
|
||||
if (!price || !balance || !balance.ocean) return
|
||||
|
||||
setIsBalanceSufficient(compareAsBN(balance.ocean, price, Comparison.gte))
|
||||
const isFree = price === '0'
|
||||
setIsBalanceSufficient(
|
||||
isFree ? true : compareAsBN(balance.ocean, price, Comparison.gte)
|
||||
)
|
||||
|
||||
return () => {
|
||||
setIsBalanceSufficient(false)
|
||||
|
Loading…
Reference in New Issue
Block a user