Browse Source

Simple spread

dev
sipp11 6 years ago
parent
commit
65b5c9398e
  1. 8
      src/components/StopTimeForm.js
  2. 2
      src/components/TripForm.js
  3. 7
      src/utils/ApiClient.js

8
src/components/StopTimeForm.js

@ -93,8 +93,9 @@ class StopTimeForm extends Component {
})
apiClient(`/stop/?search=${inputValue}`, { cancelToken })
.then((resp) => {
callback(resp.data.results.map(ele => Object.assign(ele, {
value: ele.id, label: ele.name
callback(resp.data.results.map(i => ({
...i,
label: i.name
})))
})
}
@ -115,8 +116,7 @@ class StopTimeForm extends Component {
<AsyncSelect
cacheOptions={true}
defaultOptions
defaultValue={item.stop && Object.assign(item.stop, {
label: item.stop.name})}
defaultValue={item.stop && {...item.stop, label: item.stop.name}}
loadOptions={this.getStops}
components={{ Option }}
onChange={(item, evt) => {

2
src/components/TripForm.js

@ -140,7 +140,7 @@ class TripForm extends Component {
label="Service"
type="text"
fieldName="service"
value={one.service && Object.assign(one.service, {label: one.service.service_id})}
value={one.service && {...one.service, label: one.service.service_id}}
handleChange={this.handleChange}
choices={calendar.results.map(ele => ({ value: ele.id, label: ele.service_id }))} />}

7
src/utils/ApiClient.js

@ -4,10 +4,11 @@ import { URL, API_PREFIX } from '../constants/Api'
export const apiClient = function(url, extra) {
const token = store.getState().auth.token
const params = Object.assign({
const params = {
url: `${URL}${API_PREFIX}${url}`,
headers: {'Authorization': 'Bearer ' + token}
}, extra || {})
headers: { 'Authorization': 'Bearer ' + token },
...(extra || {}),
}
return axios.request(params)
}

Loading…
Cancel
Save