2020-05-14 16:42:21 -08:00
|
|
|
import React from 'react'
|
|
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
|
import { Link } from 'react-admin'
|
2020-06-09 16:29:12 -08:00
|
|
|
import { withWidth } from '@material-ui/core'
|
2024-09-28 07:54:36 -08:00
|
|
|
import { useGetHandleArtistClick } from './useGetHandleArtistClick'
|
2020-05-14 16:42:21 -08:00
|
|
|
|
2023-12-18 10:56:03 -09:00
|
|
|
export const ArtistLinkField = withWidth()(({
|
|
|
|
|
record,
|
|
|
|
|
className,
|
|
|
|
|
width,
|
|
|
|
|
source,
|
|
|
|
|
}) => {
|
|
|
|
|
const artistLink = useGetHandleArtistClick(width)
|
2021-09-26 11:32:40 -08:00
|
|
|
|
2023-12-18 10:56:03 -09:00
|
|
|
const id = record[source + 'Id']
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
{id ? (
|
|
|
|
|
<Link
|
|
|
|
|
to={artistLink(id)}
|
|
|
|
|
onClick={(e) => e.stopPropagation()}
|
|
|
|
|
className={className}
|
|
|
|
|
>
|
|
|
|
|
{record[source]}
|
|
|
|
|
</Link>
|
|
|
|
|
) : (
|
|
|
|
|
record[source]
|
|
|
|
|
)}
|
|
|
|
|
</>
|
|
|
|
|
)
|
|
|
|
|
})
|
2020-05-14 16:42:21 -08:00
|
|
|
|
|
|
|
|
ArtistLinkField.propTypes = {
|
2020-06-12 13:02:04 -08:00
|
|
|
record: PropTypes.object,
|
2020-05-14 16:42:21 -08:00
|
|
|
className: PropTypes.string,
|
2021-11-05 16:25:12 -08:00
|
|
|
source: PropTypes.string,
|
2020-05-14 16:42:21 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ArtistLinkField.defaultProps = {
|
|
|
|
|
addLabel: true,
|
2021-11-05 16:25:12 -08:00
|
|
|
source: 'albumArtist',
|
2020-05-14 16:42:21 -08:00
|
|
|
}
|