diff --git a/src/components/LinkedItems.tsx b/src/components/LinkedItems.tsx index dde4cc1..17fb220 100644 --- a/src/components/LinkedItems.tsx +++ b/src/components/LinkedItems.tsx @@ -3,6 +3,7 @@ import {Stack, Typography, Button, FormControl, Grid, Box, Accordion, AccordionS import ExpandMoreIcon from '@mui/icons-material/ExpandMore' import axios from 'axios' import {BACKEND_URL} from '../lib/constants' +import {Link} from 'react-router' type Field = { label: string @@ -142,22 +143,53 @@ export const LinkedItems = ({parentI ) : linkedItems.length > 0 ? ( linkedItems.map((item, index) => ( + {childResource === 'media' && item.id && ( + {String(item.filename)} + )} {fields.map(({label, data}) => ( {label}: {item[data]} ))} {type === 'edit' && ( - )} @@ -165,7 +197,7 @@ export const LinkedItems = ({parentI )) ) : ( - {title} не найдены + {title} не найдены )} @@ -181,7 +213,15 @@ export const LinkedItems = ({parentI renderInput={(params) => } isOptionEqualToValue={(option, value) => option.id === value?.id} filterOptions={(options, {inputValue}) => { - return options.filter((option) => String(option[fields[0].data]).toLowerCase().startsWith(inputValue.toLowerCase())) + // return options.filter((option) => String(option[fields[0].data]).toLowerCase().includes(inputValue.toLowerCase())) + const searchWords = inputValue + .toLowerCase() + .split(' ') + .filter((word) => word.length > 0) + return options.filter((option) => { + const optionWords = String(option[fields[0].data]).toLowerCase().split(' ') + return searchWords.every((searchWord) => optionWords.some((word) => word.startsWith(searchWord))) + }) }} /> diff --git a/src/pages/route/edit.tsx b/src/pages/route/edit.tsx index 0e03a62..00cde89 100644 --- a/src/pages/route/edit.tsx +++ b/src/pages/route/edit.tsx @@ -111,13 +111,16 @@ export const RouteEdit = () => { } }} error={!!error} - helperText={error?.message || 'Формат: [[lat1,lon1], [lat2,lon2], ...]'} + helperText={error?.message} // 'Формат: [[lat1,lon1], [lat2,lon2], ...]' margin="normal" fullWidth InputLabelProps={{shrink: true}} type="text" label={'Координаты маршрута'} placeholder="[[1.1, 2.2], [2.1, 4.5]]" + sx={{ + marginBottom: 2, + }} /> )} />