add path key for /route route

This commit is contained in:
maxim 2025-02-21 17:31:35 +03:00
parent dea0ed1c2c
commit 6e29b8c4a9
4 changed files with 38 additions and 1 deletions

View File

@ -53,6 +53,20 @@ export const RouteCreate = () => {
defaultValue={false}
render={({field}: {field: any}) => <FormControlLabel control={<Checkbox {...field} checked={field.value} onChange={(e) => field.onChange(e.target.checked)} />} label="Направление маршрута" />}
/>
<TextField
{...register('path', {
required: 'Это поле является обязательным',
setValueAs: (value) => String(value),
})}
error={!!(errors as any)?.path}
helperText={(errors as any)?.path?.message}
margin="normal"
fullWidth
InputLabelProps={{shrink: true}}
type="text"
label={'Путь'}
name="path"
/>
</Box>
</Create>
)

View File

@ -48,6 +48,20 @@ export const RouteEdit = () => {
defaultValue={false}
render={({field}: {field: any}) => <FormControlLabel control={<Checkbox {...field} checked={field.value} onChange={(e) => field.onChange(e.target.checked)} />} label="Направление маршрута" />}
/>
<TextField
{...register('path', {
required: 'Это поле является обязательным',
setValueAs: (value) => String(value),
})}
error={!!(errors as any)?.path}
helperText={(errors as any)?.path?.message}
margin="normal"
fullWidth
InputLabelProps={{shrink: true}}
type="text"
label={'Путь'}
name="path"
/>
</Box>
</Edit>
)

View File

@ -1,5 +1,6 @@
import {DataGrid, type GridColDef} from '@mui/x-data-grid'
import {DeleteButton, EditButton, List, ShowButton, useDataGrid} from '@refinedev/mui'
import {Typography} from '@mui/material'
import React from 'react'
export const RouteList = () => {
@ -44,6 +45,7 @@ export const RouteList = () => {
align: 'left',
headerAlign: 'left',
flex: 1,
renderCell: ({value}) => <Typography style={{color: value ? '#48989f' : '#7f6b58'}}>{value ? 'прямое' : 'обратное'}</Typography>,
},
{
field: 'actions',

View File

@ -12,7 +12,7 @@ export const RouteShow = () => {
// {label: 'ID', data: 'id'},
{label: 'ID перевозчика', data: 'carrier_id'},
{label: 'Номер маршрута', data: 'route_number'},
{label: 'Направление маршрута', data: 'route_direction'},
{label: 'Путь', data: 'path'},
]
return (
@ -26,6 +26,13 @@ export const RouteShow = () => {
<TextField value={record?.[data]} />
</Stack>
))}
<Stack gap={1}>
<Typography variant="body1" fontWeight="bold">
Направление маршрута
</Typography>
<TextField value={record?.route_direction ? 'ДА' : 'НЕТ'} />
</Stack>
</Stack>
</Show>
)