123456789101112131415161718192021222324252627282930 |
- import {useCallback} from "react";
- import {store} from "../reducers";
- import {actionSetTrackToPlaylist, actionUploadTrack} from "../actions";
- import {useDropzone} from "react-dropzone";
- import {connect} from "react-redux";
- function TrackDropZone({ onLoad }) {
- const onDrop = useCallback((acceptedFiles) => {
- // Do something with the files
- onLoad(acceptedFiles[0]);
- store.dispatch(actionSetTrackToPlaylist(acceptedFiles[0]))
- }, []);
- const { getRootProps, getInputProps, isDragActive } = useDropzone({ onDrop });
- return (
- <div {...getRootProps()}>
- <input {...getInputProps()} />
- {isDragActive ? (
- <p>Перетащите файл сюда ...</p>
- ) : (
- <p>Для добавления трэка перетащите файлы в плейлист</p>
- )}
- </div>
- );
- }
- export const CTrackDropZone = connect (null, {onLoad: actionUploadTrack}) (TrackDropZone)
|