fix preview
url for media
entity
This commit is contained in:
@ -1,14 +1,16 @@
|
||||
import {Stack, Typography} from '@mui/material'
|
||||
import {Stack, Typography, Box, Button} from '@mui/material'
|
||||
import {useShow} from '@refinedev/core'
|
||||
import {Show, TextFieldComponent as TextField} from '@refinedev/mui'
|
||||
|
||||
import {MEDIA_TYPES} from '../../lib/constants'
|
||||
import {TOKEN_KEY} from '../../authProvider'
|
||||
|
||||
export const MediaShow = () => {
|
||||
const {query} = useShow({})
|
||||
const {data, isLoading} = query
|
||||
|
||||
const record = data?.data
|
||||
const token = localStorage.getItem(TOKEN_KEY)
|
||||
|
||||
const fields = [
|
||||
// {label: 'Название файла', data: 'filename'},
|
||||
@ -24,7 +26,43 @@ export const MediaShow = () => {
|
||||
return (
|
||||
<Show isLoading={isLoading}>
|
||||
<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}} />}
|
||||
{record && record.media_type === 1 && (
|
||||
<img
|
||||
src={`https://wn.krbl.ru/media/${record?.id}/download?token=${token}`}
|
||||
alt={record?.filename}
|
||||
style={{
|
||||
maxWidth: '100%',
|
||||
height: '40vh',
|
||||
objectFit: 'contain',
|
||||
borderRadius: 8,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
{record && record.media_type === 2 && (
|
||||
<Box
|
||||
sx={{
|
||||
p: 2,
|
||||
border: '1px solid text.pimary',
|
||||
borderRadius: 2,
|
||||
bgcolor: 'primary.light',
|
||||
width: 'fit-content',
|
||||
}}
|
||||
>
|
||||
<Typography
|
||||
variant="body1"
|
||||
gutterBottom
|
||||
sx={{
|
||||
color: '#FFFFFF',
|
||||
}}
|
||||
>
|
||||
Видео доступно для скачивания по ссылке:
|
||||
</Typography>
|
||||
<Button variant="contained" href={`https://wn.krbl.ru/media/${record?.id}/download?token=${token}`} target="_blank" sx={{mt: 1, width: '100%'}}>
|
||||
Скачать видео
|
||||
</Button>
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{fields.map(({label, data, render}) => (
|
||||
<Stack key={data} gap={1}>
|
||||
|
Reference in New Issue
Block a user