artistPage.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { connect } from "react-redux"
  2. import { store } from "../store/store";
  3. import { useEffect } from "react";
  4. import { PlaylistsAll } from "../components/Playlist";
  5. import { TracksAll } from "../components/Tracks";
  6. import { actionArtistById } from "../store/promiseReducer";
  7. import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
  8. import {faCompactDisc, faHeadphonesSimple} from "@fortawesome/free-solid-svg-icons";
  9. const ArtistPage = ({artist}) => {
  10. let id = window.location.href.split('/')[4];
  11. const getAnswer = () => {
  12. store.dispatch(actionArtistById(id));
  13. };
  14. useEffect(() => {
  15. getAnswer();
  16. }, []);
  17. return(<>
  18. <div className="d-flex justify-content-center flex-column align-items-center">
  19. <div className="playlist-img-box rounded-circle position-relative"
  20. style={{backgroundImage: `url(${artist.photo ?? "https://www.pngitem.com/pimgs/m/427-4279206_title-detail-mexican-musician-logo-hd-png-download.png"})`, backgroundSize: "cover", backgroundRepeat: "no-repeat", backgroundPosition: "center", width:250, height:250}}
  21. ></div>
  22. <h1>{artist.name}</h1>
  23. <p className='text-white-50 mb-2'><FontAwesomeIcon className='me-2' icon={faHeadphonesSimple} />{artist?.tracks?.length} Tracks</p>
  24. <p className='text-white-50 mb-2'><FontAwesomeIcon className='me-2' icon={faCompactDisc} />{artist?.albums?.length} Albums</p>
  25. </div>
  26. <div className="d-flex justify-content-between align-items-center py-3">
  27. <h3 className="text-uppercase"> <FontAwesomeIcon icon={faCompactDisc} className="me-2"/>Albums</h3>
  28. </div>
  29. <CArtistPlaylists/>
  30. <CArtistTracks/>
  31. </>)
  32. }
  33. export const CArtistPage = connect(state => ({artist: state.promise.artistById?.payload || {}} ), )(ArtistPage);
  34. const CArtistPlaylists = connect(state => ({playlists: state.promise.artistById?.payload?.albums || []} ), )(PlaylistsAll);
  35. const CArtistTracks = connect(state => ({tracks: state.promise.artistById?.payload?.tracks || [],
  36. playlist: state.promise.artistById?.payload || {},} ), )(TracksAll);