1
0
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:
Matthias Kretschmann 2020-08-11 07:51:55 +02:00
parent 8d8336d169
commit c8ab797e02
Signed by: m
GPG Key ID: 606EEEF3C479A91F
3 changed files with 12 additions and 10 deletions

View File

@ -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])

View File

@ -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}>

View File

@ -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)