Show artist link in Songs lists

This commit is contained in:
Deluan
2021-11-05 20:25:12 -04:00
parent 1c82bf5179
commit 91b470c93b
4 changed files with 37 additions and 17 deletions
+22 -12
View File
@@ -14,25 +14,35 @@ export const useGetHandleArtistClick = (width) => {
}
}
export const ArtistLinkField = withWidth()(({ record, className, width }) => {
const artistLink = useGetHandleArtistClick(width)
const songsFilteredByArtist = (artist) => {
return `/song?filter={"artist":"${artist}"}`
}
return (
<Link
to={artistLink(record.albumArtistId)}
onClick={(e) => e.stopPropagation()}
className={className}
>
{record.albumArtist}
</Link>
)
})
export const ArtistLinkField = withWidth()(
({ record, className, width, source }) => {
const artistLink = useGetHandleArtistClick(width)
const id = record[source + 'Id']
const link = id ? artistLink(id) : songsFilteredByArtist(record[source])
return (
<Link
to={link}
onClick={(e) => e.stopPropagation()}
className={className}
>
{record[source]}
</Link>
)
}
)
ArtistLinkField.propTypes = {
record: PropTypes.object,
className: PropTypes.string,
source: PropTypes.string,
}
ArtistLinkField.defaultProps = {
addLabel: true,
source: 'albumArtist',
}