replace city_id
with carrier_id
into /carrier
route
This commit is contained in:
parent
739bbe4e28
commit
9c20c5661a
@ -14,11 +14,11 @@ export const VehicleCreate = () => {
|
|||||||
formState: {errors},
|
formState: {errors},
|
||||||
} = useForm({})
|
} = useForm({})
|
||||||
|
|
||||||
const {autocompleteProps: cityAutocompleteProps} = useAutocomplete({
|
const {autocompleteProps: carrierAutocompleteProps} = useAutocomplete({
|
||||||
resource: 'city',
|
resource: 'carrier',
|
||||||
onSearch: (value) => [
|
onSearch: (value) => [
|
||||||
{
|
{
|
||||||
field: 'name',
|
field: 'short_name',
|
||||||
operator: 'contains',
|
operator: 'contains',
|
||||||
value,
|
value,
|
||||||
},
|
},
|
||||||
@ -70,26 +70,26 @@ export const VehicleCreate = () => {
|
|||||||
|
|
||||||
<Controller
|
<Controller
|
||||||
control={control}
|
control={control}
|
||||||
name="city_id"
|
name="carrier_id"
|
||||||
rules={{required: 'Это поле является обязательным'}}
|
rules={{required: 'Это поле является обязательным'}}
|
||||||
defaultValue={null}
|
defaultValue={null}
|
||||||
render={({field}) => (
|
render={({field}) => (
|
||||||
<Autocomplete
|
<Autocomplete
|
||||||
{...cityAutocompleteProps}
|
{...carrierAutocompleteProps}
|
||||||
value={cityAutocompleteProps.options.find((option) => option.id === field.value) || null}
|
value={carrierAutocompleteProps.options.find((option) => option.id === field.value) || null}
|
||||||
onChange={(_, value) => {
|
onChange={(_, value) => {
|
||||||
field.onChange(value?.id || '')
|
field.onChange(value?.id || '')
|
||||||
}}
|
}}
|
||||||
getOptionLabel={(item) => {
|
getOptionLabel={(item) => {
|
||||||
return item ? item.name : ''
|
return item ? item.short_name : ''
|
||||||
}}
|
}}
|
||||||
isOptionEqualToValue={(option, value) => {
|
isOptionEqualToValue={(option, value) => {
|
||||||
return option.id === value?.id
|
return option.id === value?.id
|
||||||
}}
|
}}
|
||||||
filterOptions={(options, {inputValue}) => {
|
filterOptions={(options, {inputValue}) => {
|
||||||
return options.filter((option) => option.name.toLowerCase().includes(inputValue.toLowerCase()))
|
return options.filter((option) => option.short_name.toLowerCase().includes(inputValue.toLowerCase()))
|
||||||
}}
|
}}
|
||||||
renderInput={(params) => <TextField {...params} label="Выберите город" margin="normal" variant="outlined" error={!!errors.city_id} helperText={(errors as any)?.city_id?.message} required />}
|
renderInput={(params) => <TextField {...params} label="Выберите перевозчика" margin="normal" variant="outlined" error={!!errors.city_id} helperText={(errors as any)?.city_id?.message} required />}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
@ -19,11 +19,11 @@ export const VehicleEdit = () => {
|
|||||||
formState: {errors},
|
formState: {errors},
|
||||||
} = useForm<VehicleFormValues>({})
|
} = useForm<VehicleFormValues>({})
|
||||||
|
|
||||||
const {autocompleteProps: cityAutocompleteProps} = useAutocomplete({
|
const {autocompleteProps: carrierAutocompleteProps} = useAutocomplete({
|
||||||
resource: 'city',
|
resource: 'carrier',
|
||||||
onSearch: (value) => [
|
onSearch: (value) => [
|
||||||
{
|
{
|
||||||
field: 'name',
|
field: 'short_name',
|
||||||
operator: 'contains',
|
operator: 'contains',
|
||||||
value,
|
value,
|
||||||
},
|
},
|
||||||
@ -75,26 +75,26 @@ export const VehicleEdit = () => {
|
|||||||
|
|
||||||
<Controller
|
<Controller
|
||||||
control={control}
|
control={control}
|
||||||
name="city_id"
|
name="carrier_id"
|
||||||
rules={{required: 'Это поле является обязательным'}}
|
rules={{required: 'Это поле является обязательным'}}
|
||||||
defaultValue={null}
|
defaultValue={null}
|
||||||
render={({field}) => (
|
render={({field}) => (
|
||||||
<Autocomplete
|
<Autocomplete
|
||||||
{...cityAutocompleteProps}
|
{...carrierAutocompleteProps}
|
||||||
value={cityAutocompleteProps.options.find((option) => option.id === field.value) || null}
|
value={carrierAutocompleteProps.options.find((option) => option.id === field.value) || null}
|
||||||
onChange={(_, value) => {
|
onChange={(_, value) => {
|
||||||
field.onChange(value?.id || '')
|
field.onChange(value?.id || '')
|
||||||
}}
|
}}
|
||||||
getOptionLabel={(item) => {
|
getOptionLabel={(item) => {
|
||||||
return item ? item.name : ''
|
return item ? item.short_name : ''
|
||||||
}}
|
}}
|
||||||
isOptionEqualToValue={(option, value) => {
|
isOptionEqualToValue={(option, value) => {
|
||||||
return option.id === value?.id
|
return option.id === value?.id
|
||||||
}}
|
}}
|
||||||
filterOptions={(options, {inputValue}) => {
|
filterOptions={(options, {inputValue}) => {
|
||||||
return options.filter((option) => option.name.toLowerCase().includes(inputValue.toLowerCase()))
|
return options.filter((option) => option.short_name.toLowerCase().includes(inputValue.toLowerCase()))
|
||||||
}}
|
}}
|
||||||
renderInput={(params) => <TextField {...params} label="Выберите город" margin="normal" variant="outlined" error={!!errors.city_id} helperText={(errors as any)?.city_id?.message} required />}
|
renderInput={(params) => <TextField {...params} label="Выберите перевозчика" margin="normal" variant="outlined" error={!!errors.city_id} helperText={(errors as any)?.city_id?.message} required />}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
@ -21,8 +21,8 @@ export const VehicleList = () => {
|
|||||||
headerAlign: 'left',
|
headerAlign: 'left',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'city_id',
|
field: 'carrier_id',
|
||||||
headerName: 'ID города',
|
headerName: 'ID перевозчика',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
minWidth: 150,
|
minWidth: 150,
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
|
Loading…
Reference in New Issue
Block a user