-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
102 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
37 changes: 29 additions & 8 deletions
37
client/src/Components/SimilarArtists/SimilarArtistsList.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,39 @@ | ||
import React from 'react' | ||
import { connect } from 'react-redux'; | ||
import { withRouter } from 'react-router-dom'; | ||
import { fetchArtistIdAC, fetchArtistInfoAC, switchSearchBarAC } from '../../Redux/artistReducer/artistActions'; | ||
|
||
|
||
import SimilarArtist from './SimilarArtist'; | ||
|
||
const SimilarArtistsList = ({ similar }) => { | ||
return similar.map(({ name }, i) => ( | ||
<SimilarArtist title={name} key={`${name}_${i}`} /> | ||
)); | ||
class SimilarArtistsList extends React.Component { | ||
async onClick(name) { | ||
await this.props.fetchArtistIdAC(name); | ||
await this.props.fetchArtistInfoAC(name); | ||
this.props.history.push(`/artists/${this.props.artist.id}`); | ||
} | ||
|
||
render() { | ||
return this.props.artist.similar && this.props.artist.similar.map((el, i) => ( | ||
<button value={el.name} onClick={() => this.onClick(el.name)}> | ||
<SimilarArtist title={el.name} key={`${el.name}_${i}`} /> | ||
</button> | ||
)); | ||
} | ||
} | ||
|
||
const mapStateToProps = (state) => ({ | ||
similar: state.artist.similar | ||
|
||
const mapStateToProps = (store) => ({ | ||
artist: store.artist, | ||
}); | ||
|
||
const mapDispatchToProps = { | ||
fetchArtistIdAC, | ||
fetchArtistInfoAC | ||
}; | ||
|
||
|
||
export default connect( | ||
mapStateToProps | ||
)(SimilarArtistsList); | ||
mapStateToProps, | ||
mapDispatchToProps | ||
)(withRouter(SimilarArtistsList)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters