2020-02-07 07:45:56 -09:00
|
|
|
import React from 'react'
|
2020-04-09 14:31:37 -08:00
|
|
|
import { useGetOne } from 'react-admin'
|
2020-02-07 11:04:45 -09:00
|
|
|
import AlbumDetails from './AlbumDetails'
|
2020-04-09 14:28:47 -08:00
|
|
|
import { Title } from '../common'
|
2020-02-12 16:35:35 -09:00
|
|
|
import { useStyles } from './styles'
|
2020-02-14 05:02:32 -09:00
|
|
|
import { AlbumSongBulkActions } from './AlbumSongBulkActions'
|
2020-05-15 09:48:33 -08:00
|
|
|
import AlbumActions from './AlbumActions'
|
2020-04-09 14:28:47 -08:00
|
|
|
import AlbumSongs from './AlbumSongs'
|
2020-02-07 07:45:56 -09:00
|
|
|
|
2020-02-12 16:35:35 -09:00
|
|
|
const AlbumShow = (props) => {
|
|
|
|
|
const classes = useStyles()
|
|
|
|
|
const { data: record, loading, error } = useGetOne('album', props.id)
|
2020-02-07 07:45:56 -09:00
|
|
|
|
2020-02-12 16:35:35 -09:00
|
|
|
if (loading) {
|
2020-04-09 14:28:47 -08:00
|
|
|
return null
|
2020-02-12 16:35:35 -09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
|
return <p>ERROR: {error}</p>
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-07 07:45:56 -09:00
|
|
|
return (
|
|
|
|
|
<>
|
2020-02-12 16:35:35 -09:00
|
|
|
<AlbumDetails {...props} classes={classes} record={record} />
|
2020-04-09 14:28:47 -08:00
|
|
|
<AlbumSongs
|
2020-02-12 16:35:35 -09:00
|
|
|
{...props}
|
2020-04-09 14:53:44 -08:00
|
|
|
albumId={props.id}
|
2020-02-12 16:35:35 -09:00
|
|
|
title={<Title subTitle={record.name} />}
|
2020-08-05 10:57:59 -08:00
|
|
|
actions={<AlbumActions albumId={props.id} />}
|
2020-02-12 16:35:35 -09:00
|
|
|
filter={{ album_id: props.id }}
|
2020-02-14 05:02:32 -09:00
|
|
|
resource={'albumSong'}
|
2020-02-12 16:35:35 -09:00
|
|
|
exporter={false}
|
2020-04-03 18:35:55 -08:00
|
|
|
perPage={-1}
|
2020-02-12 16:35:35 -09:00
|
|
|
pagination={null}
|
|
|
|
|
sort={{ field: 'discNumber asc, trackNumber asc', order: 'ASC' }}
|
2020-02-14 05:02:32 -09:00
|
|
|
bulkActionButtons={<AlbumSongBulkActions />}
|
2020-04-09 14:28:47 -08:00
|
|
|
/>
|
2020-02-07 07:45:56 -09:00
|
|
|
</>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default AlbumShow
|