You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.1 KiB

import { setBikes, setBikesFetched, setBikesIsFetching, setBikesFetchFailed, createBike, editBike, mergeBike } from './actions';
import { handleActions } from 'redux-actions';
export default handleActions({
[setBikes]: (state, action) => ({
...state,
8 years ago
entities: action.payload.entities.bikes,
}),
[setBikesIsFetching]: (state, action) => ({
...state,
8 years ago
isFetching: action.payload,
}),
[setBikesFetched]: (state, action) => ({
...state,
8 years ago
fetched: action.payload,
}),
8 years ago
[setBikesFetchFailed]: (state, action) => ({
...state,
fetchFailed: {
message: action.payload,
},
8 years ago
}),
8 years ago
[editBike]: (state, action) => ({
...state,
form: {
bike: action.payload,
create: false,
},
}),
[createBike]: (state, action) => ({
...state,
form: {
bike: null,
create: true,
},
}),
[mergeBike]: (state, action) => ({
...state,
entities: { ...state.entities, ...action.payload.entities.bikes },
})
8 years ago
}, { entities: {}, form: { bike: null, create: undefined }, isFetching: false, fetched: false, fetchFailed: undefined });