parent
6e7299cdf2
commit
9f689c0233
@ -0,0 +1,63 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import React, { Component } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { createSelector } from 'reselect';
|
||||
import { fetchAlbumHistory, clearAlbumHistory, albumHistoryMarkAsFailed } from 'Store/Actions/albumHistoryActions';
|
||||
import AlbumHistory from './AlbumHistory';
|
||||
|
||||
function createMapStateToProps() {
|
||||
return createSelector(
|
||||
(state) => state.albumHistory,
|
||||
(albumHistory) => {
|
||||
return albumHistory;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
const mapDispatchToProps = {
|
||||
fetchAlbumHistory,
|
||||
clearAlbumHistory,
|
||||
albumHistoryMarkAsFailed
|
||||
};
|
||||
|
||||
class AlbumHistoryConnector extends Component {
|
||||
|
||||
//
|
||||
// Lifecycle
|
||||
|
||||
componentDidMount() {
|
||||
this.props.fetchAlbumHistory({ albumId: this.props.albumId });
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.props.clearAlbumHistory();
|
||||
}
|
||||
|
||||
//
|
||||
// Listeners
|
||||
|
||||
onMarkAsFailedPress = (historyId) => {
|
||||
this.props.albumHistoryMarkAsFailed({ historyId, albumId: this.props.albumId });
|
||||
}
|
||||
|
||||
//
|
||||
// Render
|
||||
|
||||
render() {
|
||||
return (
|
||||
<AlbumHistory
|
||||
{...this.props}
|
||||
onMarkAsFailedPress={this.onMarkAsFailedPress}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
AlbumHistoryConnector.propTypes = {
|
||||
albumId: PropTypes.number.isRequired,
|
||||
fetchAlbumHistory: PropTypes.func.isRequired,
|
||||
clearAlbumHistory: PropTypes.func.isRequired,
|
||||
albumHistoryMarkAsFailed: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
export default connect(createMapStateToProps, mapDispatchToProps)(AlbumHistoryConnector);
|
@ -1,63 +0,0 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import React, { Component } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { createSelector } from 'reselect';
|
||||
import { fetchEpisodeHistory, clearEpisodeHistory, episodeHistoryMarkAsFailed } from 'Store/Actions/episodeHistoryActions';
|
||||
import EpisodeHistory from './EpisodeHistory';
|
||||
|
||||
function createMapStateToProps() {
|
||||
return createSelector(
|
||||
(state) => state.episodeHistory,
|
||||
(episodeHistory) => {
|
||||
return episodeHistory;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
const mapDispatchToProps = {
|
||||
fetchEpisodeHistory,
|
||||
clearEpisodeHistory,
|
||||
episodeHistoryMarkAsFailed
|
||||
};
|
||||
|
||||
class EpisodeHistoryConnector extends Component {
|
||||
|
||||
//
|
||||
// Lifecycle
|
||||
|
||||
componentDidMount() {
|
||||
this.props.fetchEpisodeHistory({ episodeId: this.props.episodeId });
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.props.clearEpisodeHistory();
|
||||
}
|
||||
|
||||
//
|
||||
// Listeners
|
||||
|
||||
onMarkAsFailedPress = (historyId) => {
|
||||
this.props.episodeHistoryMarkAsFailed({ historyId, episodeId: this.props.episodeId });
|
||||
}
|
||||
|
||||
//
|
||||
// Render
|
||||
|
||||
render() {
|
||||
return (
|
||||
<EpisodeHistory
|
||||
{...this.props}
|
||||
onMarkAsFailedPress={this.onMarkAsFailedPress}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
EpisodeHistoryConnector.propTypes = {
|
||||
episodeId: PropTypes.number.isRequired,
|
||||
fetchEpisodeHistory: PropTypes.func.isRequired,
|
||||
clearEpisodeHistory: PropTypes.func.isRequired,
|
||||
episodeHistoryMarkAsFailed: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
export default connect(createMapStateToProps, mapDispatchToProps)(EpisodeHistoryConnector);
|
@ -0,0 +1,7 @@
|
||||
import { createAction } from 'redux-actions';
|
||||
import * as types from './actionTypes';
|
||||
import albumHistoryActionHandlers from './albumHistoryActionHandlers';
|
||||
|
||||
export const fetchAlbumHistory = albumHistoryActionHandlers[types.FETCH_ALBUM_HISTORY];
|
||||
export const clearAlbumHistory = createAction(types.CLEAR_ALBUM_HISTORY);
|
||||
export const albumHistoryMarkAsFailed = albumHistoryActionHandlers[types.ALBUM_HISTORY_MARK_AS_FAILED];
|
@ -1,7 +0,0 @@
|
||||
import { createAction } from 'redux-actions';
|
||||
import * as types from './actionTypes';
|
||||
import episodeHistoryActionHandlers from './episodeHistoryActionHandlers';
|
||||
|
||||
export const fetchEpisodeHistory = episodeHistoryActionHandlers[types.FETCH_EPISODE_HISTORY];
|
||||
export const clearEpisodeHistory = createAction(types.CLEAR_EPISODE_HISTORY);
|
||||
export const episodeHistoryMarkAsFailed = episodeHistoryActionHandlers[types.EPISODE_HISTORY_MARK_AS_FAILED];
|
Loading…
Reference in new issue