trc-client-core
Version:
The core of the TRC Client
32 lines (29 loc) • 983 B
JavaScript
import {FETCH_DEALER_CODES,TRAINING_ACTIVITY_SUMMARY_RECEIVE} from 'trc-client-core/src/constants/ActionTypes';
import {List, Map, fromJS} from 'immutable';
const initialState = {
dealerCodes: List(),
trainingActivitySummary: Map()
};
export default function dealer(state = initialState, action) {
switch (action.type) {
case FETCH_DEALER_CODES:
return {
...state,
dealerCodes: fromJS(action.payload)
.toList()
.flatten(true)
.map(item => Map({
label: item.get('name'),
value: item.get('code'),
region: item.get('region')
}))
}
case TRAINING_ACTIVITY_SUMMARY_RECEIVE:
return {
...state,
trainingActivitySummary: fromJS(action.payload)
}
default:
return state;
}
}