Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Use MVMF collections in the mvmf event page #875

Merged
merged 3 commits into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion webapp/src/components/AssetBrowse/AssetBrowse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ const AssetBrowse = (props: Props) => {
</Container>
</div>
) : (
<NFTFilters isMap={Boolean(isMap)} />
<NFTFilters isMap={Boolean(isMap)} contracts={contracts} />
)}
{isMap ? (
<div className="Atlas">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,28 @@ import {
} from 'decentraland-ui'
import { WearableGender } from '../../../../modules/nft/wearable/types'
import { contracts } from '../../../../modules/contract/utils'
import { Contract } from '../../../../modules/vendor/services'
import { ArrayFilter } from '../ArrayFilter'
import { SelectFilter } from '../SelectFilter'
import { Props } from './FiltersMenu.types'

export const ALL_FILTER_OPTION = 'ALL'

const getContracts = (availableContracts: string[] | undefined): Contract[] => {
if (availableContracts && availableContracts.length > 0) {
let filteredContracts = []
for (const contract of contracts) {
if (availableContracts.some(address => contract.address === address)) {
filteredContracts.push(contract)
}
}

return filteredContracts
}

return contracts
}

const FiltersMenu = (props: Props) => {
const {
selectedCollection,
Expand All @@ -28,6 +44,7 @@ const FiltersMenu = (props: Props) => {
selectedNetwork,
selectedEmotePlayMode,
isOnlySmart,
availableContracts,
onCollectionsChange,
onRaritiesChange,
onGendersChange,
Expand All @@ -42,14 +59,14 @@ const FiltersMenu = (props: Props) => {
value: ALL_FILTER_OPTION,
text: t('nft_filters.all_collections')
},
...contracts
...getContracts(availableContracts)
.filter(contract => contract.category === NFTCategory.WEARABLE)
.map(contract => ({
value: contract.address,
text: contract.name
}))
]
}, [])
}, [availableContracts])

const rarityOptions = useMemo(() => {
const options = Object.values(Rarity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type Props = {
selectedGenders?: string[]
selectedNetwork?: Network
selectedEmotePlayMode?: string
availableContracts?: string[]
isOnlySmart?: boolean
onCollectionsChange: (contract?: string) => void
onGendersChange?: (options: string[]) => void
Expand Down
10 changes: 8 additions & 2 deletions webapp/src/components/Vendor/NFTFilters/NFTFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@ import './NFTFilters.css'

// TODO: Code on each NFTFilters can be extracted
const NFTFilters = (props: Props) => {
const { vendor, isMap, onBrowse } = props
const { vendor, contracts, isMap, onBrowse } = props

switch (vendor) {
case VendorName.DECENTRALAND:
default:
return <DecentralandNFTFilters isMap={isMap} onBrowse={onBrowse} />
return (
<DecentralandNFTFilters
isMap={isMap}
availableContracts={contracts}
onBrowse={onBrowse}
/>
)
}
}

Expand Down
3 changes: 2 additions & 1 deletion webapp/src/components/Vendor/NFTFilters/NFTFilters.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ export type Props = {
vendor?: string
onBrowse: typeof browse
isMap: boolean
contracts?: string[]
}

export type MapStateProps = Pick<Props, 'vendor'>
export type MapDispatchProps = Pick<Props, 'onBrowse'>
export type MapDispatch = Dispatch<BrowseAction>
export type OwnProps = Pick<Props, 'isMap'>
export type OwnProps = Pick<Props, 'isMap' | 'contracts'>
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ const NFTFilters = (props: Props) => {
assetType,
hasFiltersEnabled,
onClearFilters,
isRentalsEnabled
isRentalsEnabled,
availableContracts
} = props

const category = section ? getCategoryFromSection(section) : undefined
Expand Down Expand Up @@ -360,6 +361,7 @@ const NFTFilters = (props: Props) => {
selectedRarities={rarities}
selectedGenders={isWearableCategory ? wearableGenders : undefined}
selectedEmotePlayMode={isEmoteCategory ? emotePlayMode : undefined}
availableContracts={availableContracts}
isOnlySmart={isWearableCategory ? !!onlySmart : undefined}
onCollectionsChange={handleCollectionsChange}
onGendersChange={
Expand Down Expand Up @@ -421,6 +423,7 @@ const NFTFilters = (props: Props) => {
isEmoteCategory ? emotePlayMode : undefined
}
isOnlySmart={isWearableCategory ? !!onlySmart : undefined}
availableContracts={availableContracts}
onCollectionsChange={handleCollectionsChange}
onGendersChange={
isWearableCategory ? handleGendersChange : undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export type Props = {
contracts: string[]
network?: Network
emotePlayMode?: EmotePlayMode
availableContracts?: string[]
hasFiltersEnabled: boolean
isRentalsEnabled: boolean
onBrowse: typeof browse
Expand Down Expand Up @@ -52,4 +53,4 @@ export type MapStateProps = Pick<
>
export type MapDispatchProps = Pick<Props, 'onClearFilters'>
export type MapDispatch = Dispatch<ClearFiltersAction>
export type OwnProps = Pick<Props, 'onBrowse' | 'isMap'>
export type OwnProps = Pick<Props, 'onBrowse' | 'isMap' | 'availableContracts'>
5 changes: 4 additions & 1 deletion webapp/src/modules/routing/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,10 @@ export function* handleBrowse(action: BrowseAction) {
yield call(fetchAssetsFromRoute, {
...options,
...(isAnEventRoute && {
contracts: isAnEventRoute ? eventsContracts[pathname.slice(1)] : undefined
contracts:
options.contracts && options.contracts.length > 0
? options.contracts
: eventsContracts[pathname.slice(1)]
})
})
yield put(push(buildBrowseURL(pathname, options)))
Expand Down