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) LoggerInstance.error(`[asset] Failed getting asset for ${did}`, asset)
return return
} }
if (asset.nft.state !== 0 && asset.nft.state !== 4) {
if (asset.nft.state) {
// handle nft states as documented in https://docs.oceanprotocol.com/concepts/did-ddo/#state // handle nft states as documented in https://docs.oceanprotocol.com/concepts/did-ddo/#state
let state let state
switch (asset.nft.state) { switch (asset.nft.state) {

View File

@ -45,11 +45,15 @@ export default function Download({
const [isPriceLoading, setIsPriceLoading] = useState(false) const [isPriceLoading, setIsPriceLoading] = useState(false)
const [isOwned, setIsOwned] = useState(false) const [isOwned, setIsOwned] = useState(false)
const [validOrderTx, setValidOrderTx] = useState('') const [validOrderTx, setValidOrderTx] = useState('')
const [isOrderDisabled, setIsOrderDisabled] = useState(false)
const [orderPriceAndFees, setOrderPriceAndFees] = const [orderPriceAndFees, setOrderPriceAndFees] =
useState<OrderPriceAndFees>() useState<OrderPriceAndFees>()
const isUnsupportedPricing = asset?.accessDetails?.type === 'NOT_SUPPORTED' const isUnsupportedPricing = asset?.accessDetails?.type === 'NOT_SUPPORTED'
useEffect(() => {
Number(asset?.nft.state) === 4 && setIsOrderDisabled(true)
}, [asset?.nft.state])
useEffect(() => { useEffect(() => {
if (!asset?.accessDetails || isUnsupportedPricing) return if (!asset?.accessDetails || isUnsupportedPricing) return
@ -183,26 +187,36 @@ export default function Download({
const AssetAction = ({ asset }: { asset: AssetExtended }) => { const AssetAction = ({ asset }: { asset: AssetExtended }) => {
return ( return (
<div> <div>
{isUnsupportedPricing ? ( {isOrderDisabled ? (
<Alert <Alert
className={styles.fieldWarning} className={styles.fieldWarning}
state="info" state="info"
text={`No pricing schema available for this asset.`} text={`The publisher temporarily disabled ordering for this asset`}
/> />
) : ( ) : (
<> <>
{isPriceLoading ? ( {isUnsupportedPricing ? (
<Loader message="Calculating full price (including fees)" /> <Alert
) : ( className={styles.fieldWarning}
<Price state="info"
accessDetails={asset.accessDetails} text={`No pricing schema available for this asset.`}
orderPriceAndFees={orderPriceAndFees}
conversion
size="large"
/> />
)} ) : (
<>
{isPriceLoading ? (
<Loader message="Calculating full price (including fees)" />
) : (
<Price
accessDetails={asset.accessDetails}
orderPriceAndFees={orderPriceAndFees}
conversion
size="large"
/>
)}
{!isInPurgatory && <PurchaseButton />} {!isInPurgatory && <PurchaseButton />}
</>
)}
</> </>
)} )}
</div> </div>