replace city_id with carrier_id into /carrier route
				
					
				
			This commit is contained in:
		| @@ -14,11 +14,11 @@ export const VehicleCreate = () => { | ||||
|     formState: {errors}, | ||||
|   } = useForm({}) | ||||
|  | ||||
|   const {autocompleteProps: cityAutocompleteProps} = useAutocomplete({ | ||||
|     resource: 'city', | ||||
|   const {autocompleteProps: carrierAutocompleteProps} = useAutocomplete({ | ||||
|     resource: 'carrier', | ||||
|     onSearch: (value) => [ | ||||
|       { | ||||
|         field: 'name', | ||||
|         field: 'short_name', | ||||
|         operator: 'contains', | ||||
|         value, | ||||
|       }, | ||||
| @@ -70,26 +70,26 @@ export const VehicleCreate = () => { | ||||
|  | ||||
|         <Controller | ||||
|           control={control} | ||||
|           name="city_id" | ||||
|           name="carrier_id" | ||||
|           rules={{required: 'Это поле является обязательным'}} | ||||
|           defaultValue={null} | ||||
|           render={({field}) => ( | ||||
|             <Autocomplete | ||||
|               {...cityAutocompleteProps} | ||||
|               value={cityAutocompleteProps.options.find((option) => option.id === field.value) || null} | ||||
|               {...carrierAutocompleteProps} | ||||
|               value={carrierAutocompleteProps.options.find((option) => option.id === field.value) || null} | ||||
|               onChange={(_, value) => { | ||||
|                 field.onChange(value?.id || '') | ||||
|               }} | ||||
|               getOptionLabel={(item) => { | ||||
|                 return item ? item.name : '' | ||||
|                 return item ? item.short_name : '' | ||||
|               }} | ||||
|               isOptionEqualToValue={(option, value) => { | ||||
|                 return option.id === value?.id | ||||
|               }} | ||||
|               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}, | ||||
|   } = useForm<VehicleFormValues>({}) | ||||
|  | ||||
|   const {autocompleteProps: cityAutocompleteProps} = useAutocomplete({ | ||||
|     resource: 'city', | ||||
|   const {autocompleteProps: carrierAutocompleteProps} = useAutocomplete({ | ||||
|     resource: 'carrier', | ||||
|     onSearch: (value) => [ | ||||
|       { | ||||
|         field: 'name', | ||||
|         field: 'short_name', | ||||
|         operator: 'contains', | ||||
|         value, | ||||
|       }, | ||||
| @@ -75,26 +75,26 @@ export const VehicleEdit = () => { | ||||
|  | ||||
|         <Controller | ||||
|           control={control} | ||||
|           name="city_id" | ||||
|           name="carrier_id" | ||||
|           rules={{required: 'Это поле является обязательным'}} | ||||
|           defaultValue={null} | ||||
|           render={({field}) => ( | ||||
|             <Autocomplete | ||||
|               {...cityAutocompleteProps} | ||||
|               value={cityAutocompleteProps.options.find((option) => option.id === field.value) || null} | ||||
|               {...carrierAutocompleteProps} | ||||
|               value={carrierAutocompleteProps.options.find((option) => option.id === field.value) || null} | ||||
|               onChange={(_, value) => { | ||||
|                 field.onChange(value?.id || '') | ||||
|               }} | ||||
|               getOptionLabel={(item) => { | ||||
|                 return item ? item.name : '' | ||||
|                 return item ? item.short_name : '' | ||||
|               }} | ||||
|               isOptionEqualToValue={(option, value) => { | ||||
|                 return option.id === value?.id | ||||
|               }} | ||||
|               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', | ||||
|       }, | ||||
|       { | ||||
|         field: 'city_id', | ||||
|         headerName: 'ID города', | ||||
|         field: 'carrier_id', | ||||
|         headerName: 'ID перевозчика', | ||||
|         type: 'string', | ||||
|         minWidth: 150, | ||||
|         display: 'flex', | ||||
|   | ||||
		Reference in New Issue
	
	Block a user