spee.ch/react/reducers/show.js

80 lines
1.8 KiB
JavaScript
Raw Normal View History

import * as actions from 'constants/show_action_types';
import { CHANNEL, ASSET } from 'constants/show_request_types';
const initialState = {
requestType : null,
channelRequest: {
name: null,
id : null,
},
assetRequest: {
name : null,
modifier: {
id : null,
channel: {
name: null,
id : null,
},
},
extension: null,
},
2018-02-03 03:16:18 +01:00
showChannel: {
channelData: {
name : null,
shortId: null,
longId : null,
},
channelClaimsData: {
claims : null,
currentPage: null,
totalPages : null,
totalClaims: null,
},
},
showAsset: {
2018-02-05 02:43:02 +01:00
claimData: {
data : null,
shortId: null,
},
2018-02-03 03:16:18 +01:00
},
};
/*
Reducers describe how the application's state changes in response to actions
*/
export default function (state = initialState, action) {
switch (action.type) {
case actions.REQUEST_UPDATE_CHANNEL:
return Object.assign({}, state, {
requestType : CHANNEL,
2018-02-06 20:55:46 +01:00
channelRequest: action.data,
});
case actions.REQUEST_UPDATE_CLAIM:
return Object.assign({}, state, {
requestType : ASSET,
2018-02-06 20:55:46 +01:00
assetRequest: action.data,
});
2018-02-03 03:16:18 +01:00
case actions.CHANNEL_DATA_UPDATE:
return Object.assign({}, state, {
showChannel: Object.assign({}, state.showChannel, {
2018-02-06 20:55:46 +01:00
channelData: action.data,
2018-02-03 03:16:18 +01:00
}),
});
case actions.CHANNEL_CLAIMS_DATA_UPDATE:
return Object.assign({}, state, {
showChannel: Object.assign({}, state.showChannel, {
2018-02-06 20:55:46 +01:00
channelClaimsData: action.data,
2018-02-03 03:16:18 +01:00
}),
});
case actions.ASSET_CLAIM_DATA_UPDATE:
return Object.assign({}, state, {
showAsset: {
2018-02-06 20:55:46 +01:00
claimData: action.data,
2018-02-03 03:16:18 +01:00
},
});
default:
return state;
}
}