2020-09-02 11:43:15 +02:00
|
|
|
import React, { ReactElement } from 'react'
|
2020-07-13 23:45:20 +02:00
|
|
|
import styles from './index.module.css'
|
2020-10-19 10:32:41 +02:00
|
|
|
import { useMetadata } from '@oceanprotocol/react'
|
2020-08-07 18:12:39 +02:00
|
|
|
import { DDO } from '@oceanprotocol/lib'
|
|
|
|
import Loader from '../Loader'
|
|
|
|
import Tooltip from '../Tooltip'
|
2020-08-18 19:11:52 +02:00
|
|
|
import PriceUnit from './PriceUnit'
|
2020-07-07 23:00:16 +02:00
|
|
|
|
2020-05-07 08:03:30 +02:00
|
|
|
export default function Price({
|
2020-08-07 18:12:39 +02:00
|
|
|
ddo,
|
2020-05-25 14:53:38 +02:00
|
|
|
className,
|
2020-08-11 07:34:32 +02:00
|
|
|
small,
|
2020-08-20 14:22:32 +02:00
|
|
|
conversion
|
2020-05-07 08:03:30 +02:00
|
|
|
}: {
|
2020-08-07 18:12:39 +02:00
|
|
|
ddo: DDO
|
2020-05-07 08:03:30 +02:00
|
|
|
className?: string
|
2020-05-25 14:53:38 +02:00
|
|
|
small?: boolean
|
2020-08-18 19:11:52 +02:00
|
|
|
conversion?: boolean
|
2020-07-07 23:00:16 +02:00
|
|
|
}): ReactElement {
|
2020-11-20 14:31:28 +01:00
|
|
|
// price is not fetched from the chain anymore , will update one AssetProvider is implemented
|
2020-08-20 16:59:17 +02:00
|
|
|
const { price } = useMetadata(ddo)
|
2020-08-07 18:12:39 +02:00
|
|
|
|
2020-10-08 14:32:59 +02:00
|
|
|
return price?.value ? (
|
2020-10-30 14:10:21 +01:00
|
|
|
<PriceUnit
|
|
|
|
price={`${price.value}`}
|
|
|
|
className={className}
|
|
|
|
small={small}
|
|
|
|
conversion={conversion}
|
|
|
|
type={price.type}
|
|
|
|
/>
|
2021-03-01 16:17:44 +01:00
|
|
|
) : !price || !price.address || price.address === '' ? (
|
2020-08-07 18:20:08 +02:00
|
|
|
<div className={styles.empty}>
|
2021-03-01 16:08:50 +01:00
|
|
|
No price set{' '}
|
2021-03-01 16:17:44 +01:00
|
|
|
<Tooltip content="No pricing mechanism has been set yet on this asset." />
|
2020-08-07 18:12:39 +02:00
|
|
|
</div>
|
2021-03-01 16:08:50 +01:00
|
|
|
) : price.isConsumable !== 'true' ? (
|
|
|
|
<div className={styles.empty}>
|
|
|
|
Not enough liquidity{' '}
|
|
|
|
<Tooltip content="This pool does not have enough liquidity for using thisa data set." />
|
|
|
|
</div>
|
2020-08-07 18:12:39 +02:00
|
|
|
) : (
|
|
|
|
<Loader message="Retrieving price..." />
|
|
|
|
)
|
2020-05-07 08:03:30 +02:00
|
|
|
}
|