Skip to content

Commit

Permalink
Simplify splitting bids into auction and raffle
Browse files Browse the repository at this point in the history
  • Loading branch information
b-tarczynski committed Apr 18, 2024
1 parent 1d88631 commit 2414d08
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions packages/frontend/src/components/allBids/AllBidsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ export const AllBidsList = ({ search, auctionWinnersCount, raffleWinnersCount }:

const firstRaffleBidIndex = getFirstRaffleBidIndex(bidList.length, auctionWinnersCount, raffleWinnersCount)

const auctionBids = useMemo(() => {
const sectionBids = bidList.slice(0, firstRaffleBidIndex)
return sectionBids.filter(matchesSearch)
}, [bidList, firstRaffleBidIndex, matchesSearch])
const raffleBids = useMemo(() => {
const sectionBids = bidList.slice(firstRaffleBidIndex)
return sectionBids.filter(matchesSearch)
const bids = useMemo(() => {
const auctionBids = bidList.slice(0, firstRaffleBidIndex)
const raffleBids = bidList.slice(firstRaffleBidIndex)
return {
auction: auctionBids.filter(matchesSearch),
raffle: raffleBids.filter(matchesSearch),
}
}, [bidList, firstRaffleBidIndex, matchesSearch])

const nothingFound = search && auctionBids.length === 0 && raffleBids.length === 0
const nothingFound = search && bids.auction.length === 0 && bids.raffle.length === 0

return (
<>
Expand All @@ -36,8 +36,10 @@ export const AllBidsList = ({ search, auctionWinnersCount, raffleWinnersCount }:
) : (
<>
<BidsListHeaders />
{auctionBids.length !== 0 && <BidsSubList bids={auctionBids} placeOffset={0} title="AUCTION" />}
{raffleBids.length !== 0 && <BidsSubList bids={raffleBids} placeOffset={auctionBids.length} title="RAFFLE" />}
{bids.auction.length !== 0 && <BidsSubList bids={bids.auction} placeOffset={0} title="AUCTION" />}
{bids.raffle.length !== 0 && (
<BidsSubList bids={bids.raffle} placeOffset={bids.auction.length} title="RAFFLE" />
)}
</>
)}
</>
Expand Down

0 comments on commit 2414d08

Please sign in to comment.