2020-02-04 05:26:54 -09:00
|
|
|
import React from 'react'
|
|
|
|
|
import { Button, useDataProvider, useUnselectAll } from 'react-admin'
|
|
|
|
|
import { useDispatch } from 'react-redux'
|
|
|
|
|
import { addTrack } from '../player'
|
2020-02-06 08:54:27 -09:00
|
|
|
import AddToQueueIcon from '@material-ui/icons/AddToQueue'
|
|
|
|
|
|
|
|
|
|
import Tooltip from '@material-ui/core/Tooltip'
|
2020-02-04 05:26:54 -09:00
|
|
|
|
|
|
|
|
const AddToQueueButton = ({ selectedIds }) => {
|
|
|
|
|
const dispatch = useDispatch()
|
|
|
|
|
const dataProvider = useDataProvider()
|
|
|
|
|
const unselectAll = useUnselectAll()
|
|
|
|
|
const addToQueue = () => {
|
|
|
|
|
selectedIds.forEach((id) => {
|
|
|
|
|
dataProvider.getOne('song', { id }).then((response) => {
|
|
|
|
|
dispatch(addTrack(response.data))
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
unselectAll('song')
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-06 08:54:27 -09:00
|
|
|
return (
|
|
|
|
|
<Button
|
|
|
|
|
color="secondary"
|
|
|
|
|
label={
|
|
|
|
|
<Tooltip title={'Play Later'} placement="right">
|
|
|
|
|
<AddToQueueIcon />
|
|
|
|
|
</Tooltip>
|
|
|
|
|
}
|
|
|
|
|
onClick={addToQueue}
|
|
|
|
|
/>
|
|
|
|
|
)
|
2020-02-04 05:26:54 -09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default AddToQueueButton
|