fix /media route

This commit is contained in:
maxim
2025-03-16 22:18:32 +03:00
parent 8cb64dd5ba
commit 34620d5a64
4 changed files with 112 additions and 100 deletions

View File

@ -1,6 +1,7 @@
import {Stack, Typography} from '@mui/material'
import {useShow} from '@refinedev/core'
import {Show, TextFieldComponent as TextField} from '@refinedev/mui'
import {MEDIA_TYPES} from '../../lib/constants'
export const MediaShow = () => {
const {query} = useShow({})
@ -10,8 +11,12 @@ export const MediaShow = () => {
const fields = [
{label: 'Название', data: 'filename'},
{label: 'Тип', data: 'media_type'},
{label: 'ID', data: 'id'},
{
label: 'Тип',
data: 'media_type',
render: (value: number) => MEDIA_TYPES.find((type) => type.value === value)?.label || value,
},
// {label: 'ID', data: 'id'},
]
return (
@ -19,12 +24,12 @@ export const MediaShow = () => {
<Stack gap={4}>
{record && <img src={`https://wn.krbl.ru/media/${record?.id}/download`} alt={record?.filename} style={{maxWidth: '100%', height: '40vh', objectFit: 'contain', borderRadius: 8}} />}
{fields.map(({label, data}) => (
{fields.map(({label, data, render}) => (
<Stack key={data} gap={1}>
<Typography variant="body1" fontWeight="bold">
{label}
</Typography>
<TextField value={record?.[data]} />
<TextField value={render ? render(record?.[data]) : record?.[data]} />
</Stack>
))}
</Stack>