|
@@ -56,31 +56,15 @@ export const FeaturedNftsSection: FC = () => {
|
|
|
const { nfts, loading } = useNfts({
|
|
|
variables: {
|
|
|
where: {
|
|
|
- OR: [
|
|
|
- {
|
|
|
- isFeatured_eq: true,
|
|
|
- transactionalStatus: {
|
|
|
- isTypeOf_eq: 'TransactionalStatusAuction',
|
|
|
- auction: {
|
|
|
- isCompleted_eq: false,
|
|
|
- isCanceled_eq: false,
|
|
|
- },
|
|
|
- },
|
|
|
- },
|
|
|
- {
|
|
|
- isFeatured_eq: true,
|
|
|
- transactionalStatus: {
|
|
|
- isTypeOf_eq: 'TransactionalStatusBuyNow',
|
|
|
- },
|
|
|
- },
|
|
|
- ],
|
|
|
+ isFeatured_eq: true,
|
|
|
},
|
|
|
},
|
|
|
})
|
|
|
+ const nftsToSort = nfts || []
|
|
|
|
|
|
// 1. English auctions(not upcoming) first - sorted by blocks left
|
|
|
- const englishAuctions = nfts
|
|
|
- ?.filter(
|
|
|
+ const englishAuctions = nftsToSort
|
|
|
+ .filter(
|
|
|
(nft) =>
|
|
|
nft.transactionalStatus?.__typename === 'TransactionalStatusAuction' &&
|
|
|
nft.transactionalStatus.auction.auctionType.__typename === 'AuctionTypeEnglish' &&
|
|
@@ -103,8 +87,8 @@ export const FeaturedNftsSection: FC = () => {
|
|
|
})
|
|
|
|
|
|
// 2. Open and buy now auctions(not upcoming) - sorted by popularity
|
|
|
- const openAuctionsAndBuyNowAuctions = nfts
|
|
|
- ?.filter(
|
|
|
+ const openAuctionsAndBuyNowAuctions = nftsToSort
|
|
|
+ .filter(
|
|
|
(nft) =>
|
|
|
nft.transactionalStatus?.__typename === 'TransactionalStatusBuyNow' ||
|
|
|
(nft.transactionalStatus?.__typename === 'TransactionalStatusAuction' &&
|
|
@@ -114,8 +98,8 @@ export const FeaturedNftsSection: FC = () => {
|
|
|
.sort((a, b) => b.video.viewsNum - a.video.viewsNum)
|
|
|
|
|
|
// 3. Upcoming auctions - sorted by planned start
|
|
|
- const plannedAuctions = nfts
|
|
|
- ?.filter(
|
|
|
+ const plannedAuctions = nftsToSort
|
|
|
+ .filter(
|
|
|
(nft) =>
|
|
|
nft.transactionalStatus?.__typename === 'TransactionalStatusAuction' &&
|
|
|
nft.transactionalStatus.auction.startsAtBlock > currentBlock
|
|
@@ -133,9 +117,15 @@ export const FeaturedNftsSection: FC = () => {
|
|
|
return aPlannedStart - bPlannedStart
|
|
|
})
|
|
|
|
|
|
- const sorted = [...(englishAuctions || []), ...(openAuctionsAndBuyNowAuctions || []), ...(plannedAuctions || [])]
|
|
|
+ // 4. Not for sale - sorted by popularity
|
|
|
+
|
|
|
+ const notForSale = nftsToSort
|
|
|
+ .filter((nft) => nft.transactionalStatus?.__typename === 'TransactionalStatusIdle')
|
|
|
+ .sort((a, b) => b.video.viewsNum - a.video.viewsNum)
|
|
|
+
|
|
|
+ const sortedNfts = [...englishAuctions, ...openAuctionsAndBuyNowAuctions, ...plannedAuctions, ...notForSale]
|
|
|
|
|
|
- const items = loading ? createPlaceholderData(10) : sorted ?? []
|
|
|
+ const items = loading ? createPlaceholderData(10) : sortedNfts ?? []
|
|
|
|
|
|
const mdMatch = useMediaMatch('md')
|
|
|
|