spee.ch/react/containers/ShowChannel/index.js

44 lines
1.3 KiB
JavaScript
Raw Normal View History

import { connect } from 'react-redux';
import {newChannelRequest, updateRequestError, showNewChannel, updateShowChannel, clearShowChannel} from 'actions/show';
import View from './view';
const mapStateToProps = ({ show }) => {
return {
2018-02-08 08:02:57 +01:00
// request
2018-02-08 05:15:44 +01:00
requestId : show.request.id,
2018-02-08 06:30:32 +01:00
requestType : show.request.type,
2018-02-08 05:15:44 +01:00
requestChannelName: show.request.data.name,
requestChannelId : show.request.data.id,
2018-02-08 06:30:32 +01:00
requestList : show.channelRequests,
channelList : show.channelList,
2018-02-08 08:02:57 +01:00
// show channel
2018-02-08 05:15:44 +01:00
error : show.showChannel.error,
2018-02-09 01:42:13 +01:00
id : show.showChannel.id,
channel : show.channelList[show.showChannel.id],
};
};
2018-02-03 03:16:18 +01:00
const mapDispatchToProps = dispatch => {
return {
2018-02-09 01:42:13 +01:00
// request
2018-02-08 07:22:17 +01:00
onNewChannelRequest (id, name, channelId) {
dispatch(newChannelRequest(id, name, channelId));
},
onRequestError: (error) => {
dispatch(updateRequestError(error, null, null));
},
2018-02-09 01:42:13 +01:00
// show channel
onShowNewChannel: (channelData) => {
dispatch(showNewChannel(channelData));
},
2018-02-09 01:42:13 +01:00
onShowExistingChannel: (id) => {
dispatch(updateShowChannel(null, id));
2018-02-08 07:22:17 +01:00
},
onShowChannelClear: () => {
dispatch(clearShowChannel());
},
2018-02-03 03:16:18 +01:00
};
};
export default connect(mapStateToProps, mapDispatchToProps)(View);