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