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.
66 lines
1.5 KiB
66 lines
1.5 KiB
7 years ago
|
import _ from 'lodash';
|
||
|
import PropTypes from 'prop-types';
|
||
|
import React, { Component } from 'react';
|
||
|
import { connect } from 'react-redux';
|
||
|
import { createSelector } from 'reselect';
|
||
|
import { updateInteractiveImportItem } from 'Store/Actions/interactiveImportActions';
|
||
7 years ago
|
import createAllArtistSelector from 'Store/Selectors/createAllArtistSelector';
|
||
7 years ago
|
import SelectArtistModalContent from './SelectArtistModalContent';
|
||
7 years ago
|
|
||
|
function createMapStateToProps() {
|
||
|
return createSelector(
|
||
7 years ago
|
createAllArtistSelector(),
|
||
7 years ago
|
(items) => {
|
||
|
return {
|
||
|
items
|
||
|
};
|
||
|
}
|
||
|
);
|
||
|
}
|
||
|
|
||
|
const mapDispatchToProps = {
|
||
|
updateInteractiveImportItem
|
||
|
};
|
||
|
|
||
7 years ago
|
class SelectArtistModalContentConnector extends Component {
|
||
7 years ago
|
|
||
|
//
|
||
|
// Listeners
|
||
|
|
||
7 years ago
|
onArtistSelect = (artistId) => {
|
||
|
const artist = _.find(this.props.items, { id: artistId });
|
||
7 years ago
|
|
||
|
this.props.ids.forEach((id) => {
|
||
|
this.props.updateInteractiveImportItem({
|
||
|
id,
|
||
7 years ago
|
artist,
|
||
|
album: undefined,
|
||
|
tracks: []
|
||
7 years ago
|
});
|
||
|
});
|
||
|
|
||
|
this.props.onModalClose(true);
|
||
|
}
|
||
|
|
||
|
//
|
||
|
// Render
|
||
|
|
||
|
render() {
|
||
|
return (
|
||
7 years ago
|
<SelectArtistModalContent
|
||
7 years ago
|
{...this.props}
|
||
7 years ago
|
onArtistSelect={this.onArtistSelect}
|
||
7 years ago
|
/>
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
|
||
7 years ago
|
SelectArtistModalContentConnector.propTypes = {
|
||
7 years ago
|
ids: PropTypes.arrayOf(PropTypes.number).isRequired,
|
||
|
items: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||
|
updateInteractiveImportItem: PropTypes.func.isRequired,
|
||
|
onModalClose: PropTypes.func.isRequired
|
||
|
};
|
||
|
|
||
7 years ago
|
export default connect(createMapStateToProps, mapDispatchToProps)(SelectArtistModalContentConnector);
|