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

Disable ordering when state is 4 (#1746)

* fix state 4

* update var name

* fix typo
This commit is contained in:
mihaisc 2022-10-19 15:53:24 +03:00 committed by GitHub
parent 67621f5639
commit af93b561ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 14 deletions

View File

@ -76,8 +76,7 @@ function AssetProvider({
LoggerInstance.error(`[asset] Failed getting asset for ${did}`, asset)
return
}
if (asset.nft.state) {
if (asset.nft.state !== 0 && asset.nft.state !== 4) {
// handle nft states as documented in https://docs.oceanprotocol.com/concepts/did-ddo/#state
let state
switch (asset.nft.state) {

View File

@ -45,11 +45,15 @@ export default function Download({
const [isPriceLoading, setIsPriceLoading] = useState(false)
const [isOwned, setIsOwned] = useState(false)
const [validOrderTx, setValidOrderTx] = useState('')
const [isOrderDisabled, setIsOrderDisabled] = useState(false)
const [orderPriceAndFees, setOrderPriceAndFees] =
useState<OrderPriceAndFees>()
const isUnsupportedPricing = asset?.accessDetails?.type === 'NOT_SUPPORTED'
useEffect(() => {
Number(asset?.nft.state) === 4 && setIsOrderDisabled(true)
}, [asset?.nft.state])
useEffect(() => {
if (!asset?.accessDetails || isUnsupportedPricing) return
@ -183,6 +187,14 @@ export default function Download({
const AssetAction = ({ asset }: { asset: AssetExtended }) => {
return (
<div>
{isOrderDisabled ? (
<Alert
className={styles.fieldWarning}
state="info"
text={`The publisher temporarily disabled ordering for this asset`}
/>
) : (
<>
{isUnsupportedPricing ? (
<Alert
className={styles.fieldWarning}
@ -205,6 +217,8 @@ export default function Download({
{!isInPurgatory && <PurchaseButton />}
</>
)}
</>
)}
</div>
)
}