This commit is contained in:
2019-08-05 21:23:17 -04:00
parent a9f4324f29
commit 1e464de7e8
42 changed files with 837 additions and 165 deletions

View File

@@ -0,0 +1,13 @@
import { createSelector } from 'reselect';
const getState = (state) => state;
export const getActiveEventId = createSelector(
[getState],
(state) => state.get('activeEvent'),
);
export const hasActiveEvent = createSelector(
[getState],
(state) => !!state.get('activeEvent'),
);

View File

@@ -1,12 +1,9 @@
import { Map } from 'immutable';
import { createSelector } from 'reselect';
const getState = (state) => state;
import { getActiveEventId } from './activeEvent.js';
export const getActiveEvent = (state) => {
const eventId = state.get('activeEvent');
return state.getIn(['events', eventId], false)
};
const getState = (state) => state;
export const getEventById = (state, eventId) => state.getIn(['events', eventId], false);
@@ -15,7 +12,22 @@ export const getEvents = createSelector(
(state) => state.get('events') || new Map(),
);
export const getActiveEvent = createSelector(
[getActiveEventId, getEvents],
(eventId, eventsAsMap) => eventId ? eventsAsMap.get(eventId) : false,
);
export const getDefaultEvent = createSelector(
[getEvents],
(eventsAsMap) => eventsAsMap.first(),
);
export const getEventsAsList = createSelector(
[getEvents],
(eventsAsMap) => eventsAsMap.toList(),
);
export const hasMultipleEvents = createSelector(
[getEvents],
(eventsAsMap) => eventsAsMap.size > 1,
);

24
app/selectors/profile.js Normal file
View File

@@ -0,0 +1,24 @@
import { Map } from 'immutable';
import { createSelector } from 'reselect';
const getState = (state) => state;
export const getProfile = createSelector(
[getState],
(state) => state.get('profile'),
);
export const getNomDeBid = createSelector(
[getProfile],
(profile) => profile.get('nomDeBid'),
);
export const getProfileAvatarUrl = createSelector(
[getProfile],
(profile) => profile.get('avatar'),
);
export const isAllowedToBid = createSelector(
[getProfile],
(profile) => profile.get('isAllowedToBid'),
);