2020-02-07 12:38:01 -09:00
|
|
|
import React from 'react'
|
2020-02-07 08:36:26 -09:00
|
|
|
import { Card, CardContent, CardMedia, Typography } from '@material-ui/core'
|
2020-02-14 05:14:50 -09:00
|
|
|
import { useTranslate } from 'react-admin'
|
2020-03-31 10:27:39 -08:00
|
|
|
import subsonic from '../subsonic'
|
2020-03-27 17:06:02 -08:00
|
|
|
import { DurationField, formatRange } from '../common'
|
2020-05-14 16:42:21 -08:00
|
|
|
import { ArtistLinkField } from '../common'
|
2020-02-07 08:36:26 -09:00
|
|
|
|
2020-02-12 16:35:35 -09:00
|
|
|
const AlbumDetails = ({ classes, record }) => {
|
2020-02-14 05:14:50 -09:00
|
|
|
const translate = useTranslate()
|
2020-02-12 16:35:35 -09:00
|
|
|
const genreYear = (record) => {
|
2020-02-07 08:36:26 -09:00
|
|
|
let genreDateLine = []
|
2020-02-12 16:35:35 -09:00
|
|
|
if (record.genre) {
|
|
|
|
|
genreDateLine.push(record.genre)
|
2020-02-07 08:36:26 -09:00
|
|
|
}
|
2020-03-27 17:06:02 -08:00
|
|
|
const year = formatRange(record, 'year')
|
|
|
|
|
if (year) {
|
|
|
|
|
genreDateLine.push(year)
|
2020-02-07 08:36:26 -09:00
|
|
|
}
|
2020-02-14 05:14:50 -09:00
|
|
|
return genreDateLine.join(' · ')
|
2020-02-07 08:36:26 -09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Card className={classes.container}>
|
|
|
|
|
<CardMedia
|
2020-04-01 05:09:51 -08:00
|
|
|
image={subsonic.url('getCoverArt', record.coverArtId || 'not_found')}
|
2020-02-07 08:36:26 -09:00
|
|
|
className={classes.albumCover}
|
|
|
|
|
/>
|
|
|
|
|
<CardContent className={classes.albumDetails}>
|
|
|
|
|
<Typography variant="h5" className={classes.albumTitle}>
|
2020-02-12 16:35:35 -09:00
|
|
|
{record.name}
|
2020-02-07 08:36:26 -09:00
|
|
|
</Typography>
|
|
|
|
|
<Typography component="h6">
|
2020-04-03 16:51:15 -08:00
|
|
|
<ArtistLinkField record={record} />
|
2020-02-07 08:36:26 -09:00
|
|
|
</Typography>
|
2020-02-12 16:35:35 -09:00
|
|
|
<Typography component="p">{genreYear(record)}</Typography>
|
2020-02-14 05:14:50 -09:00
|
|
|
<Typography component="p">
|
|
|
|
|
{record.songCount}{' '}
|
|
|
|
|
{translate('resources.song.name', { smart_count: record.songCount })}{' '}
|
|
|
|
|
· <DurationField record={record} source={'duration'} />
|
|
|
|
|
</Typography>
|
2020-02-07 08:36:26 -09:00
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
)
|
|
|
|
|
}
|
2020-02-07 11:04:45 -09:00
|
|
|
|
|
|
|
|
export default AlbumDetails
|