1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

use action view changes by asset type

This commit is contained in:
Norbi 2021-02-19 16:25:49 +02:00
parent c731bab782
commit 14942b5785
3 changed files with 47 additions and 21 deletions

View File

@ -17,6 +17,7 @@ import Input from '../../atoms/Input'
import Alert from '../../atoms/Alert' import Alert from '../../atoms/Alert'
import { useSiteMetadata } from '../../../hooks/useSiteMetadata' import { useSiteMetadata } from '../../../hooks/useSiteMetadata'
import checkPreviousOrder from '../../../utils/checkPreviousOrder' import checkPreviousOrder from '../../../utils/checkPreviousOrder'
import { useAsset } from '../../../providers/Asset'
export default function Compute({ export default function Compute({
ddo, ddo,
@ -29,6 +30,7 @@ export default function Compute({
}): ReactElement { }): ReactElement {
const { marketFeeAddress } = useSiteMetadata() const { marketFeeAddress } = useSiteMetadata()
const { type } = useAsset()
const { ocean, accountId } = useOcean() const { ocean, accountId } = useOcean()
const { compute, isLoading, computeStepText, computeError } = useCompute() const { compute, isLoading, computeStepText, computeError } = useCompute()
const { buyDT, dtSymbol } = usePricing(ddo) const { buyDT, dtSymbol } = usePricing(ddo)
@ -129,16 +131,29 @@ export default function Compute({
</div> </div>
</div> </div>
<Input {type === 'algorithm' ? (
type="select" <Input
name="algorithm" type="select"
label="Select image to run the algorithm" name="data"
placeholder="" label="Select dataset for the algorithm"
size="small" placeholder=""
value={computeType} size="small"
options={computeOptions.map((x) => x.name)} value="dataset-1"
onChange={handleSelectChange} options={['dataset-1', 'dataset-2', 'dataset-3'].map((x) => x)}
/> onChange={handleSelectChange}
/>
) : (
<Input
type="select"
name="algorithm"
label="Select image to run the algorithm"
placeholder=""
size="small"
value={computeType}
options={computeOptions.map((x) => x.name)}
onChange={handleSelectChange}
/>
)}
<Dropzone multiple={false} handleOnDrop={onDrop} /> <Dropzone multiple={false} handleOnDrop={onDrop} />
<div className={styles.actions}> <div className={styles.actions}>

View File

@ -48,7 +48,7 @@ export default function Consume({
const { marketFeeAddress } = useSiteMetadata() const { marketFeeAddress } = useSiteMetadata()
const [hasPreviousOrder, setHasPreviousOrder] = useState(false) const [hasPreviousOrder, setHasPreviousOrder] = useState(false)
const [previousOrderId, setPreviousOrderId] = useState<string>() const [previousOrderId, setPreviousOrderId] = useState<string>()
const { isInPurgatory, price } = useAsset() const { isInPurgatory, price, type } = useAsset()
const { buyDT, pricingStepText, pricingError, pricingIsLoading } = usePricing( const { buyDT, pricingStepText, pricingError, pricingIsLoading } = usePricing(
ddo ddo
) )
@ -157,16 +157,23 @@ export default function Consume({
<div className={styles.filewrapper}> <div className={styles.filewrapper}>
<File file={file} /> <File file={file} />
</div> </div>
<div className={styles.pricewrapper}> {type === 'algorithm' ? (
{isConsumable ? ( <div className={styles.pricewrapper}>
<Price ddo={ddo} conversion /> This asset can not be downloaded, it can only be used in a compute
) : ( job
<div className={styles.help}> </div>
There is not enough liquidity in the pool to buy this data set. ) : (
</div> <div className={styles.pricewrapper}>
)} {isConsumable ? (
{!isInPurgatory && <PurchaseButton />} <Price ddo={ddo} conversion />
</div> ) : (
<div className={styles.help}>
There is not enough liquidity in the pool to buy this data set.
</div>
)}
{!isInPurgatory && <PurchaseButton />}
</div>
)}
</div> </div>
<footer className={styles.feedback}> <footer className={styles.feedback}>

View File

@ -25,6 +25,7 @@ interface AssetProviderValue {
title: string | undefined title: string | undefined
owner: string | undefined owner: string | undefined
price: BestPrice | undefined price: BestPrice | undefined
type: string | undefined
error?: string error?: string
refreshInterval: number refreshInterval: number
refreshDdo: (token?: CancelToken) => Promise<void> refreshDdo: (token?: CancelToken) => Promise<void>
@ -52,6 +53,7 @@ function AssetProvider({
const [price, setPrice] = useState<BestPrice>() const [price, setPrice] = useState<BestPrice>()
const [owner, setOwner] = useState<string>() const [owner, setOwner] = useState<string>()
const [error, setError] = useState<string>() const [error, setError] = useState<string>()
const [type, setType] = useState<string>()
const refreshPrice = useCallback(async () => { const refreshPrice = useCallback(async () => {
if ( if (
@ -160,6 +162,7 @@ function AssetProvider({
const { attributes } = ddo.findServiceByType('metadata') const { attributes } = ddo.findServiceByType('metadata')
setMetadata((attributes as unknown) as MetadataMarket) setMetadata((attributes as unknown) as MetadataMarket)
setTitle(attributes?.main.name) setTitle(attributes?.main.name)
setType(attributes.main.type)
setOwner(ddo.publicKey[0].owner) setOwner(ddo.publicKey[0].owner)
setIsInPurgatory(ddo.isInPurgatory === 'true') setIsInPurgatory(ddo.isInPurgatory === 'true')
@ -184,6 +187,7 @@ function AssetProvider({
title, title,
owner, owner,
price, price,
type,
error, error,
isInPurgatory, isInPurgatory,
purgatoryData, purgatoryData,