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-02-07 08:36:26 -09:00
|
|
|
import { subsonicUrl } from '../subsonic'
|
2020-02-14 05:14:50 -09:00
|
|
|
import { DurationField } 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 16:01:08 -08:00
|
|
|
if (record.maxYear) {
|
|
|
|
|
genreDateLine.push(record.maxYear)
|
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-02-15 10:20:04 -09:00
|
|
|
image={subsonicUrl('getCoverArt', record.coverArtId || 'not_found', {
|
|
|
|
|
size: 500
|
|
|
|
|
})}
|
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-02-12 16:35:35 -09:00
|
|
|
{record.albumArtist || record.artist}
|
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
|