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

* 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
src
@context
components/Asset/AssetActions

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,26 +187,36 @@ export default function Download({
const AssetAction = ({ asset }: { asset: AssetExtended }) => {
return (
<div>
{isUnsupportedPricing ? (
{isOrderDisabled ? (
<Alert
className={styles.fieldWarning}
state="info"
text={`No pricing schema available for this asset.`}
text={`The publisher temporarily disabled ordering for this asset`}
/>
) : (
<>
{isPriceLoading ? (
<Loader message="Calculating full price (including fees)" />
) : (
<Price
accessDetails={asset.accessDetails}
orderPriceAndFees={orderPriceAndFees}
conversion
size="large"
{isUnsupportedPricing ? (
<Alert
className={styles.fieldWarning}
state="info"
text={`No pricing schema available for this asset.`}
/>
)}
) : (
<>
{isPriceLoading ? (
<Loader message="Calculating full price (including fees)" />
) : (
<Price
accessDetails={asset.accessDetails}
orderPriceAndFees={orderPriceAndFees}
conversion
size="large"
/>
)}
{!isInPurgatory && <PurchaseButton />}
{!isInPurgatory && <PurchaseButton />}
</>
)}
</>
)}
</div>