added grid play button

This commit is contained in:
Srihari Chandana
2020-04-26 11:56:35 -04:00
committed by Deluan Quintão
parent 7ad9c385b5
commit 00666da9c1
2 changed files with 47 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
import React, { useCallback } from 'react'
import { useDispatch } from 'react-redux'
import { playAlbum } from '../audioplayer'
import { Loading, useGetList} from 'react-admin'
import IconButton from '@material-ui/core/IconButton'
import PlayIcon from '@material-ui/icons/PlayCircleFilled'
const GridButton = (props) => {
const dispatch = useDispatch()
const { ids, data, loading, error } = useGetList(
'albumSong',
{ },
{ field: 'trackNumber', order: 'ASC' },
{ album_id: props.id},
)
if (loading) {
return (
<IconButton>
<PlayIcon/>
</IconButton>
)
}
if (error) {
return (
<IconButton>
<PlayIcon/>
</IconButton>
)
}
return (
<IconButton onClick={(e) => {
e.preventDefault()
e.stopPropagation()
dispatch(playAlbum(ids[0], data))
}}>
<PlayIcon/>
</IconButton>
)
}
export default GridButton