|
@@ -7,76 +7,75 @@ import {CPlaylistDropZone} from "../tools";
|
|
|
import {CPreloaded} from "../preloader";
|
|
|
import {actionFullUploadPlaylists} from "../../actions";
|
|
|
|
|
|
-const SortableItem = SortableElement(CTrack);
|
|
|
-
|
|
|
-
|
|
|
-const SortableList = SortableContainer(({items}) => {
|
|
|
- return (
|
|
|
- <div>
|
|
|
- {items.map((value, index) =>
|
|
|
- <SortableItem key={`item-${value}`} index={index} trackIndex={index} track={value}/>)}
|
|
|
- </div>
|
|
|
- )
|
|
|
-});
|
|
|
-
|
|
|
-function SortableComponent({playlist:{name, tracks=[]}={},onLoad}) {
|
|
|
+// const SortableItem = SortableElement(CTrack);
|
|
|
+//
|
|
|
+//
|
|
|
+// const SortableList = SortableContainer(({items}) => {
|
|
|
+// return (
|
|
|
+// <div>
|
|
|
+// {items.map((value, index) =>
|
|
|
+// <SortableItem key={`item-${value}`} index={index} trackIndex={index} track={value}/>)}
|
|
|
+// </div>
|
|
|
+// )
|
|
|
+// });
|
|
|
+//
|
|
|
+// function SortableComponent({playlist:{name, tracks=[]}={},onLoad}) {
|
|
|
+//
|
|
|
+// const [state, setState] = useState(tracks || [])
|
|
|
+//
|
|
|
+// useEffect(() => {
|
|
|
+// setState (tracks || [])
|
|
|
+// },[tracks])
|
|
|
+// const onSortEnd = ({oldIndex, newIndex}) => {
|
|
|
+// setState((state) => (arrayMoveImmutable(state, oldIndex, newIndex)));
|
|
|
+// };
|
|
|
+// onLoad(state)
|
|
|
+// return (
|
|
|
+// <div>
|
|
|
+// <h2>{name}</h2>
|
|
|
+// <SortableList axis={'y'} items={state} onSortEnd={onSortEnd}/>
|
|
|
+// </div>
|
|
|
+// )
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// const CSortableComponent = connect(state => ({ playlist: state?.promise?.playlistById?.payload || {}}),
|
|
|
+// {onLoad:actionFullUploadPlaylists})
|
|
|
+// (SortableComponent)
|
|
|
+//
|
|
|
+//
|
|
|
+// export const MyPlaylistTracks = ({match:{params:{_id}}}) =>
|
|
|
+// <>
|
|
|
+// <CPlaylistDropZone >
|
|
|
+// <CPreloaded promiseName='playlistById'>
|
|
|
+// <CSortableComponent />
|
|
|
+// </CPreloaded>
|
|
|
+// </CPlaylistDropZone >
|
|
|
+// </>
|
|
|
|
|
|
- const [state, setState] = useState(tracks || [])
|
|
|
|
|
|
- useEffect(() => {
|
|
|
- setState (tracks || [])
|
|
|
- },[tracks])
|
|
|
- const onSortEnd = ({oldIndex, newIndex}) => {
|
|
|
- setState((state) => (arrayMoveImmutable(state, oldIndex, newIndex)));
|
|
|
- };
|
|
|
- onLoad(state)
|
|
|
|
|
|
+const MyTracks = ({playlist={}}) => {
|
|
|
+ const{name, tracks=[]} = playlist
|
|
|
return (
|
|
|
- <div>
|
|
|
+ <div className='Category'>
|
|
|
<h2>{name}</h2>
|
|
|
- <SortableList axis={'y'} items={state} onSortEnd={onSortEnd}/>
|
|
|
+ <CPreloaded promiseName='playlistById'>
|
|
|
+ {(tracks || []).map((track,index) => <CTrack key={index} trackIndex={index} track={track}/>)}
|
|
|
+ </CPreloaded>
|
|
|
</div>
|
|
|
)
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-const CSortableComponent = connect(state => ({ playlist: state?.promise?.playlistById?.payload || {}}),
|
|
|
- {onLoad:actionFullUploadPlaylists})
|
|
|
-(SortableComponent)
|
|
|
+const CMyTracks = connect(state => ({playlist: state.promise.playlistById?.payload || {}}),)(MyTracks)
|
|
|
|
|
|
|
|
|
export const MyPlaylistTracks = ({match:{params:{_id}}}) =>
|
|
|
<>
|
|
|
<CPlaylistDropZone >
|
|
|
- <CPreloaded promiseName='playlistById'>
|
|
|
- <CSortableComponent />
|
|
|
- </CPreloaded>
|
|
|
- </CPlaylistDropZone >
|
|
|
+ <CMyTracks />
|
|
|
+ </CPlaylistDropZone >
|
|
|
</>
|
|
|
|
|
|
|
|
|
-//
|
|
|
-// const MyTracks = ({playlist={}}) => {
|
|
|
-// const{name, tracks=[]} = playlist
|
|
|
-// return (
|
|
|
-// <div className='Category'>
|
|
|
-// <h2>{name}</h2>
|
|
|
-// <CPreloaded promiseName='playlistById'>
|
|
|
-// {(tracks || []).map((track,index) => <CTrack trackIndex={index} track={track}/>)}
|
|
|
-// </CPreloaded>
|
|
|
-// </div>
|
|
|
-// )
|
|
|
-// }
|
|
|
-//
|
|
|
-// const CMyTracks = connect(state => ({playlist: state.promise.playlistById?.payload || {}}),)(MyTracks)
|
|
|
-//
|
|
|
-//
|
|
|
-// export const MyPlaylistTracks = ({match:{params:{_id}}}) =>
|
|
|
-// <>
|
|
|
-// <CPlaylistDropZone >
|
|
|
-// <CMyTracks />
|
|
|
-// </CPlaylistDropZone >
|
|
|
-// </>
|
|
|
-//
|
|
|
-//
|