34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
import { createSelector } from 'reselect';
|
|
|
|
const getState = (state) => state;
|
|
|
|
export const getItemBidCount = (state, itemId) => state.getIn(['auctions', itemId, 'bidCount'], 0);
|
|
|
|
export const getItemPrice = (state, itemId) => state.getIn(['auctions', itemId, 'currentPrice'], 0);
|
|
|
|
export const isBiddingItem = (state, itemId) => state.getIn(['auctions', itemId, 'isBidding'], false);
|
|
|
|
export const isWinningItem = (state, itemId) => state.getIn(['auctions', itemId, 'isWinning'], false);
|
|
|
|
export const getAuctionStatus = (state, itemId) => state.getIn(['actions', itemId], false);
|
|
|
|
export const getAuctionStatuses = createSelector(
|
|
[getState],
|
|
(state) => state.get('actions') || new Map(),
|
|
);
|
|
|
|
export const getItemsIdsWithNoBids = createSelector(
|
|
[getAuctionStatuses],
|
|
(auctions) => auctions.filter(auction => auction.bidCount === 0);
|
|
);
|
|
|
|
export const getMyBidItemIds = createSelector(
|
|
[getAuctionStatuses],
|
|
(auctions) => auctions.filter(auction => auction.isBidding);
|
|
);
|
|
|
|
export const getMyWinningItemIds = createSelector(
|
|
[getAuctionStatuses],
|
|
(auctions) => auctions.filter(auction => auction.isWinning);
|
|
);
|