tracklist.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { faPlay, faXmark } from "@fortawesome/free-solid-svg-icons";
  2. import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
  3. import { Button } from "react-bootstrap";
  4. import { connect } from "react-redux";
  5. import { Link } from "react-router-dom";
  6. import { actionRemoveTrackFromQueue } from "../store/playerReducer";
  7. import { store } from "../store/store";
  8. import { sendForm } from "./SendForm";
  9. const Track = ({track}) =>
  10. <>
  11. <tr>
  12. <td width={30} data-id={track.id}>
  13. <div className="col">
  14. <Button variant="outline-light" className='rounded-5' title='Play' onClick={async () => {
  15. // console.log(playlist.tracks, playlist?.tracks[playlist?.tracks.indexOf(track)]);
  16. // store.dispatch(actionFullSetPlaylist(playlist?.tracks));
  17. // playlist.tracks ? store.dispatch(actionFullSetTrack(playlist?.tracks[playlist?.tracks.indexOf(track)])) : store.dispatch(actionFullSetTrack(track))
  18. // store.dispatch(actionFullPlay());
  19. }}>
  20. <FontAwesomeIcon className='' icon={faPlay}/>
  21. </Button>
  22. </div>
  23. </td>
  24. <td>
  25. <Link className="link-light" to='#'> {track.name}</Link>
  26. </td>
  27. <td align={"right"}>
  28. <FontAwesomeIcon icon={faXmark} onClick={() => store.dispatch(actionRemoveTrackFromQueue(track))}/>
  29. </td>
  30. </tr>
  31. </>
  32. const TrackList = ({tracks}) => {
  33. return(
  34. <>
  35. <table className="table table-dark table-hover align-middle">
  36. <thead>
  37. <tr>
  38. <th scope="col" width={30}></th>
  39. <th scope="col">Track name</th>
  40. <th scope='col'>Action</th>
  41. </tr>
  42. </thead>
  43. <tbody>
  44. {tracks.map((track, i) => <Track key={i} track={track}/>)}
  45. </tbody>
  46. </table>
  47. </>
  48. )
  49. }
  50. export const CTrackList = connect(state => ({tracks: state.player?.playlist || []} ), )(TrackList);