-More!
This commit is contained in:
13
app/selectors/activeEvent.js
Normal file
13
app/selectors/activeEvent.js
Normal 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'),
|
||||
);
|
||||
@@ -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
24
app/selectors/profile.js
Normal 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'),
|
||||
);
|
||||
Reference in New Issue
Block a user