Add StarButton to player

This commit is contained in:
Deluan
2020-08-24 19:38:29 -04:00
committed by Deluan Quintão
parent 4d60f72b7e
commit b18e3289fb
3 changed files with 35 additions and 1 deletions
+30
View File
@@ -0,0 +1,30 @@
import React from 'react'
import { useLocation } from 'react-router-dom'
import { useGetOne } from 'react-admin'
import IconButton from '@material-ui/core/IconButton'
import StarBorderIcon from '@material-ui/icons/StarBorder'
import { StarButton } from '../common'
const Placeholder = () => (
<IconButton>
<StarBorderIcon disabled={true} />
</IconButton>
)
const Toolbar = ({ id }) => {
const location = useLocation()
const resource = location.pathname.startsWith('/song') ? 'song' : 'albumSong'
const { data, loading } = useGetOne(resource, id)
if (loading) {
return <Placeholder />
}
return <StarButton record={data} resource={resource} />
}
const PlayerToolbar = ({ id }) => (
<>{id ? <Toolbar id={id} /> : <Placeholder />} </>
)
export default PlayerToolbar