Adapt components with API response
This commit is contained in:
@@ -50,8 +50,8 @@ export default function FilesList({files}) {
|
||||
const theme = useTheme()
|
||||
const {mode} = useColorScheme()
|
||||
|
||||
const musicFiles = files.filter(file => file.attributes.mime.startsWith('audio'))
|
||||
const pdfFiles = files.filter(file => file.attributes.mime === 'application/pdf')
|
||||
const musicFiles = files.filter(file => file.mime.startsWith('audio'))
|
||||
const pdfFiles = files.filter(file => file.mime === 'application/pdf')
|
||||
|
||||
const sortedMusicFiles = musicFiles.sort((a, b) => {
|
||||
const extensionOrder = {
|
||||
@@ -60,7 +60,7 @@ export default function FilesList({files}) {
|
||||
'.aac': 2,
|
||||
'.mp3': 3
|
||||
}
|
||||
return extensionOrder[a.attributes.ext.toLowerCase()] - extensionOrder[b.attributes.ext.toLowerCase()]
|
||||
return extensionOrder[a.ext.toLowerCase()] - extensionOrder[b.ext.toLowerCase()]
|
||||
})
|
||||
|
||||
const handleClick = (e, url, fileName) => {
|
||||
@@ -170,7 +170,7 @@ export default function FilesList({files}) {
|
||||
{sortedMusicFiles.map(file => (
|
||||
<StyledTableRow key={file.id}>
|
||||
<StyledTableCell>
|
||||
{getQuality(file.attributes.ext.toLowerCase(), file?.attributes?.caption?.toUpperCase())}
|
||||
{getQuality(file.ext.toLowerCase(), file?.caption?.toUpperCase())}
|
||||
</StyledTableCell>
|
||||
<StyledTableCell align='left'>
|
||||
<Link
|
||||
@@ -178,11 +178,11 @@ export default function FilesList({files}) {
|
||||
underline='hover'
|
||||
sx={{fontWeight: 'bold'}}
|
||||
aria-label='download'
|
||||
onClick={e => handleClick(e, `${apiUrl}${file.attributes.url}`, file.attributes.name)}
|
||||
onClick={e => handleClick(e, `${apiUrl}${file.url}`, file.name)}
|
||||
>
|
||||
{file.attributes.name}
|
||||
{file.name}
|
||||
</Link>
|
||||
<small style={{marginLeft: 3}}>({formatSize(file.attributes.size)})</small>
|
||||
<small style={{marginLeft: 3}}>({formatSize(file.size)})</small>
|
||||
</StyledTableCell>
|
||||
</StyledTableRow>
|
||||
))}
|
||||
@@ -217,7 +217,7 @@ export default function FilesList({files}) {
|
||||
<StyledTableRow key={file.id}>
|
||||
<StyledTableCell>
|
||||
<strong>
|
||||
{file.attributes.caption}
|
||||
{file.caption}
|
||||
</strong>
|
||||
</StyledTableCell>
|
||||
<StyledTableCell align='left'>
|
||||
@@ -226,11 +226,11 @@ export default function FilesList({files}) {
|
||||
underline='hover'
|
||||
sx={{fontWeight: 'bold'}}
|
||||
aria-label='download'
|
||||
onClick={e => handleClick(e, `${apiUrl}${file.attributes.url}`, file.attributes.name)}
|
||||
onClick={e => handleClick(e, `${apiUrl}${file.url}`, file.name)}
|
||||
>
|
||||
{file.attributes.name}
|
||||
{file.name}
|
||||
</Link>
|
||||
<small style={{marginLeft: 3}}>({formatSize(file.attributes.size)})</small>
|
||||
<small style={{marginLeft: 3}}>({formatSize(file.size)})</small>
|
||||
</StyledTableCell>
|
||||
</StyledTableRow>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user