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.
98 lines
2.1 KiB
98 lines
2.1 KiB
import PropTypes from 'prop-types';
|
|
import React, { Component } from 'react';
|
|
import { createSelector } from 'reselect';
|
|
import connectSection from 'Store/connectSection';
|
|
import createClientSideCollectionSelector from 'Store/Selectors/createClientSideCollectionSelector';
|
|
import { setAlbumStudioSort, setAlbumStudioFilter, saveAlbumStudio } from 'Store/Actions/albumStudioActions';
|
|
import { fetchAlbums, clearAlbums } from 'Store/Actions/albumActions';
|
|
import AlbumStudio from './AlbumStudio';
|
|
|
|
function createMapStateToProps() {
|
|
return createSelector(
|
|
createClientSideCollectionSelector(),
|
|
(artist) => {
|
|
return {
|
|
...artist
|
|
};
|
|
}
|
|
);
|
|
}
|
|
|
|
const mapDispatchToProps = {
|
|
fetchAlbums,
|
|
clearAlbums,
|
|
setAlbumStudioSort,
|
|
setAlbumStudioFilter,
|
|
saveAlbumStudio
|
|
};
|
|
|
|
class AlbumStudioConnector extends Component {
|
|
|
|
//
|
|
// Lifecycle
|
|
|
|
componentDidMount() {
|
|
this.populate();
|
|
}
|
|
|
|
componentWillUnmount() {
|
|
this.unpopulate();
|
|
}
|
|
|
|
//
|
|
// Control
|
|
|
|
populate = () => {
|
|
this.props.fetchAlbums();
|
|
}
|
|
|
|
unpopulate = () => {
|
|
this.props.clearAlbums();
|
|
}
|
|
|
|
//
|
|
// Listeners
|
|
|
|
onSortPress = (sortKey) => {
|
|
this.props.setAlbumStudioSort({ sortKey });
|
|
}
|
|
|
|
onFilterSelect = (selectedFilterKey) => {
|
|
this.props.setAlbumStudioFilter({ selectedFilterKey });
|
|
}
|
|
|
|
onUpdateSelectedPress = (payload) => {
|
|
this.props.saveAlbumStudio(payload);
|
|
}
|
|
|
|
//
|
|
// Render
|
|
|
|
render() {
|
|
return (
|
|
<AlbumStudio
|
|
{...this.props}
|
|
onSortPress={this.onSortPress}
|
|
onFilterSelect={this.onFilterSelect}
|
|
onUpdateSelectedPress={this.onUpdateSelectedPress}
|
|
/>
|
|
);
|
|
}
|
|
}
|
|
|
|
AlbumStudioConnector.propTypes = {
|
|
setAlbumStudioSort: PropTypes.func.isRequired,
|
|
setAlbumStudioFilter: PropTypes.func.isRequired,
|
|
fetchAlbums: PropTypes.func.isRequired,
|
|
clearAlbums: PropTypes.func.isRequired,
|
|
saveAlbumStudio: PropTypes.func.isRequired
|
|
};
|
|
|
|
export default connectSection(
|
|
createMapStateToProps,
|
|
mapDispatchToProps,
|
|
undefined,
|
|
undefined,
|
|
{ section: 'artist', uiSection: 'albumStudio' }
|
|
)(AlbumStudioConnector);
|