fix: add back floor to search results (#5087)
* add back floor to search results * fix search by address * slice const
This commit is contained in:
parent
4b1b6098f3
commit
7f2bb6c6ae
@ -134,6 +134,7 @@ export const SearchBarDropdown = ({
|
|||||||
stats: {
|
stats: {
|
||||||
total_supply: collection.totalSupply,
|
total_supply: collection.totalSupply,
|
||||||
one_day_change: collection.floorChange,
|
one_day_change: collection.floorChange,
|
||||||
|
floor_price: formatEthPrice(collection.floor?.toString()),
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
.slice(0, isNFTPage ? 3 : 2)
|
.slice(0, isNFTPage ? 3 : 2)
|
||||||
|
@ -2,6 +2,8 @@ import { isAddress } from '@ethersproject/address'
|
|||||||
|
|
||||||
import { GenieCollection } from '../../types'
|
import { GenieCollection } from '../../types'
|
||||||
|
|
||||||
|
const MAX_SEARCH_RESULTS = 6
|
||||||
|
|
||||||
export const fetchSearchCollections = async (addressOrName: string, recursive = false): Promise<GenieCollection[]> => {
|
export const fetchSearchCollections = async (addressOrName: string, recursive = false): Promise<GenieCollection[]> => {
|
||||||
const url = `${process.env.REACT_APP_GENIE_V3_API_URL}/searchCollections`
|
const url = `${process.env.REACT_APP_GENIE_V3_API_URL}/searchCollections`
|
||||||
const isName = !isAddress(addressOrName.toLowerCase())
|
const isName = !isAddress(addressOrName.toLowerCase())
|
||||||
@ -39,10 +41,21 @@ export const fetchSearchCollections = async (addressOrName: string, recursive =
|
|||||||
body: JSON.stringify(payload),
|
body: JSON.stringify(payload),
|
||||||
})
|
})
|
||||||
if (isName) {
|
if (isName) {
|
||||||
const data = (await r.json()) as { data: GenieCollection[] }
|
const data = await r.json()
|
||||||
return data?.data ? data.data.slice(0, 6) : []
|
const formattedData = data?.data
|
||||||
|
? data.data.map((collection: { stats: Record<string, unknown>; floorPrice: string }) => {
|
||||||
|
return {
|
||||||
|
...collection,
|
||||||
|
stats: {
|
||||||
|
...collection.stats,
|
||||||
|
floor_price: collection.floorPrice,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
: []
|
||||||
|
return formattedData.slice(0, MAX_SEARCH_RESULTS)
|
||||||
}
|
}
|
||||||
const data = await r.json()
|
const data = await r.json()
|
||||||
|
|
||||||
return data.data ? [data.data[0]] : []
|
return data.data ? [{ ...data.data[0], stats: { ...data.data[0].stats, floor_price: data.data[0].floorPrice } }] : []
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user