update create
for /media
route
This commit is contained in:
parent
9d590c994f
commit
550299f1a8
@ -1 +1,6 @@
|
||||
export const BACKEND_URL = 'https://wn.krbl.ru'
|
||||
|
||||
export const MEDIA_TYPES = [
|
||||
{label: 'Фото', value: 1},
|
||||
{label: 'Видео', value: 2},
|
||||
]
|
||||
|
@ -1,8 +1,10 @@
|
||||
import {Box, TextField, Button, Typography} from '@mui/material'
|
||||
import {Box, TextField, Button, Typography, FormControl, InputLabel, Select, MenuItem} from '@mui/material'
|
||||
import {Create} from '@refinedev/mui'
|
||||
import {useForm} from '@refinedev/react-hook-form'
|
||||
import {useState} from 'react'
|
||||
|
||||
import {MEDIA_TYPES} from '../../lib/constants'
|
||||
|
||||
export const MediaCreate = () => {
|
||||
const {
|
||||
saveButtonProps,
|
||||
@ -88,20 +90,28 @@ export const MediaCreate = () => {
|
||||
name="filename"
|
||||
/>
|
||||
|
||||
<TextField
|
||||
<FormControl fullWidth margin="normal" error={!!errors.media_type}>
|
||||
<InputLabel id="media-type-label">Тип</InputLabel>
|
||||
<Select
|
||||
labelId="media-type-label"
|
||||
label="Тип"
|
||||
{...register('media_type', {
|
||||
required: 'Это поле является обязательным',
|
||||
valueAsNumber: true,
|
||||
})}
|
||||
error={!!(errors as any)?.media_type}
|
||||
helperText={(errors as any)?.media_type?.message}
|
||||
margin="normal"
|
||||
fullWidth
|
||||
InputLabelProps={{shrink: true}}
|
||||
type="number"
|
||||
label="Тип"
|
||||
name="media_type"
|
||||
/>
|
||||
>
|
||||
{MEDIA_TYPES.map((type) => (
|
||||
<MenuItem key={type.value} value={type.value}>
|
||||
{type.label}
|
||||
</MenuItem>
|
||||
))}
|
||||
</Select>
|
||||
{errors.media_type && (
|
||||
<Typography variant="caption" color="error">
|
||||
{!!(errors as any)?.message}
|
||||
</Typography>
|
||||
)}
|
||||
</FormControl>
|
||||
</Box>
|
||||
</Create>
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user