- more!
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
import { createSelector } from 'reselect';
|
||||
|
||||
//import { getItemsIdsWithNoBids, getMyBidItemIds, getMyWinningItemIds } from './auctions.js';
|
||||
|
||||
const getState = (state) => state;
|
||||
|
||||
export const getItemBidCount = (state, itemId) => state.getIn(['auctions', itemId, 'bidCount'], 0);
|
||||
@@ -11,3 +9,25 @@ export const getItemPrice = (state, itemId) => state.getIn(['auctions', itemId,
|
||||
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);
|
||||
);
|
||||
|
||||
21
app/selectors/events.js
Normal file
21
app/selectors/events.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import { Map } from 'immutable';
|
||||
import { createSelector } from 'reselect';
|
||||
|
||||
const getState = (state) => state;
|
||||
|
||||
export const getActiveEvent = (state) => {
|
||||
const eventId = state.get('activeEvent');
|
||||
return state.getIn(['events', eventId], false)
|
||||
};
|
||||
|
||||
export const getEventById = (state, eventId) => state.getIn(['events', eventId], false);
|
||||
|
||||
export const getEvents = createSelector(
|
||||
[getState],
|
||||
(state) => state.get('events') || new Map(),
|
||||
);
|
||||
|
||||
export const getEventsAsList = createSelector(
|
||||
[getEvents],
|
||||
(eventsAsMap) => eventsAsMap.toList(),
|
||||
);
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Map } from 'immutable';
|
||||
import { createSelector } from 'reselect';
|
||||
|
||||
//import { getItemsIdsWithNoBids, getMyBidItemIds, getMyWinningItemIds } from './auctions.js';
|
||||
import { getItemsIdsWithNoBids, getMyBidItemIds, getMyWinningItemIds } from './auctions.js';
|
||||
|
||||
const getState = (state) => state;
|
||||
|
||||
@@ -26,6 +27,36 @@ export const getAuctionItemsAsList = createSelector(
|
||||
(auctionItemsAsMap) => auctionItemsAsMap.toList(),
|
||||
);
|
||||
|
||||
export const getAuctionItemsUserIsBidding = createSelector(
|
||||
[getAuctionItems, getMyBidItemIds],
|
||||
(items, myBids) => items.filter(i => myBids.indexOf(i.id)) || new Map(),
|
||||
);
|
||||
|
||||
export const getAuctionItemsUserIsBiddingAsList = createSelector(
|
||||
[getAuctionItemsUserIsBidding],
|
||||
(auctionItemsAsMap) => auctionItemsAsMap.toList(),
|
||||
);
|
||||
|
||||
export const getAuctionItemsUserIsWinning = createSelector(
|
||||
[getAuctionItemsUserIsBidding, getMyWinningItemIds],
|
||||
(items, myWins) => items.filter(i => myWins.indexOf(i.id)) || new Map(),
|
||||
);
|
||||
|
||||
export const getAuctionItemsUserIsWinningAsList = createSelector(
|
||||
[getAuctionItemsUserIsWinning],
|
||||
(auctionItemsAsMap) => auctionItemsAsMap.toList(),
|
||||
);
|
||||
|
||||
export const getAuctionItemsWithNoBids = createSelector(
|
||||
[getAuctionItems, getItemsIdsWithNoBids],
|
||||
(items, noBids) => items.filter(i => noBids.indexOf(i.id)) || new Map(),
|
||||
);
|
||||
|
||||
export const getAuctionItemsWithNoBidsAsList = createSelector(
|
||||
[getAuctionItemsWithNoBids],
|
||||
(auctionItemsAsMap) => auctionItemsAsMap.toList(),
|
||||
);
|
||||
|
||||
export const getTicketItems = createSelector(
|
||||
[getState],
|
||||
(state) => state.get('items').filter(i => i.type === 'ticket') || new Map(),
|
||||
@@ -35,8 +66,3 @@ export const getTicketItemsAsList = createSelector(
|
||||
[getTicketItems],
|
||||
(ticketItemsAsMap) => ticketItemsAsMap.toList(),
|
||||
);
|
||||
|
||||
export const getAuctionItemsWithNoBids = createSelector(
|
||||
[getAuctionItems],
|
||||
(auctionItemsAsMap) => auctionItemsAsMap.filter(i => i.bidCount),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user