Skip to content

Commit

Permalink
feat: change prices endpoint to the marketplacE (#2310)
Browse files Browse the repository at this point in the history
Co-authored-by: Melisa Anabella Rossi <[email protected]>
  • Loading branch information
meelrossi and Melisa Anabella Rossi authored Oct 25, 2024
1 parent 82f1aae commit db91387
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { connect } from 'react-redux'
import { getIsOffchainPublicItemOrdersEnabled, getIsOffchainPublicNFTOrdersEnabled } from '../../../modules/features/selectors'
import { RootState } from '../../../modules/reducer'
import { getCategoryFromSection } from '../../../modules/routing/search'
import {
Expand Down Expand Up @@ -56,7 +57,9 @@ const mapState = (state: RootState, ownProps: OwnProps): MapStateProps => {
maxEstateSize: 'maxEstateSize' in values ? values.maxEstateSize || '' : getMaxEstateSize(state),
rentalDays: 'rentalDays' in values ? values.rentalDays : getRentalDays(state),
emoteHasGeometry: 'emoteHasGeometry' in values ? values.emoteHasGeometry : getEmoteHasGeometry(state),
emoteHasSound: 'emoteHasSound' in values ? values.emoteHasSound : getEmoteHasSound(state)
emoteHasSound: 'emoteHasSound' in values ? values.emoteHasSound : getEmoteHasSound(state),
isOffchainPublicItemOrdersEnabled: getIsOffchainPublicItemOrdersEnabled(state),
isOffchainPublicNFTOrdersEnabled: getIsOffchainPublicNFTOrdersEnabled(state)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ethers } from 'ethers'
import { RentalsListingsFilterByCategory } from '@dcl/schemas'
import { t } from 'decentraland-dapps/dist/modules/translation/utils'
import { Box, useTabletAndBelowMediaQuery } from 'decentraland-ui'
import { nftAPI } from '../../../modules/vendor/decentraland/nft/api'
import { nftAPI, nftMarketplaceAPI } from '../../../modules/vendor/decentraland/nft/api'
import { rentalsAPI } from '../../../modules/vendor/decentraland/rentals/api'
import { Section } from '../../../modules/vendor/routing/types'
import { getNetwork, getPriceLabel } from '../../../utils/filters'
Expand Down Expand Up @@ -35,6 +35,8 @@ export const PriceFilter = ({
rentalDays,
emoteHasGeometry,
emoteHasSound,
isOffchainPublicItemOrdersEnabled,
isOffchainPublicNFTOrdersEnabled,
onChange
}: Props) => {
const isMobileOrTablet = useTabletAndBelowMediaQuery()
Expand Down Expand Up @@ -117,7 +119,8 @@ export const PriceFilter = ({
if (landStatus === LANDFilters.ONLY_FOR_RENT) {
data = await rentalsAPI.getRentalListingsPrices(rentalPriceFetchFilters())
} else {
data = await nftAPI.fetchPrices(priceFetchFilters)
const api = isOffchainPublicItemOrdersEnabled || isOffchainPublicNFTOrdersEnabled ? nftMarketplaceAPI : nftAPI
data = await api.fetchPrices(priceFetchFilters)
}
return Object.entries(data).reduce(
(acc, [key, value]) => {
Expand All @@ -126,7 +129,7 @@ export const PriceFilter = ({
},
{} as Record<string, number>
)
}, [priceFetchFilters, landStatus, rentalPriceFetchFilters])
}, [priceFetchFilters, landStatus, isOffchainPublicItemOrdersEnabled, isOffchainPublicNFTOrdersEnabled, rentalPriceFetchFilters])

return (
<Box header={header} className="filters-sidebar-box price-filter" collapsible defaultCollapsed={defaultCollapsed || isMobileOrTablet}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export type Props = {
isRentalPriceFitlerChartEnabled?: boolean
emoteHasGeometry?: boolean
emoteHasSound?: boolean
isOffchainPublicItemOrdersEnabled: boolean
isOffchainPublicNFTOrdersEnabled: boolean
}

export type MapStateProps = Pick<
Expand All @@ -53,6 +55,8 @@ export type MapStateProps = Pick<
| 'isRentalPriceFitlerChartEnabled'
| 'emoteHasGeometry'
| 'emoteHasSound'
| 'isOffchainPublicItemOrdersEnabled'
| 'isOffchainPublicNFTOrdersEnabled'
>

export type OwnProps = Pick<Props, 'values'>

0 comments on commit db91387

Please sign in to comment.