Fix bugs when adding activity
This commit is contained in:
@@ -88,41 +88,39 @@ export class WorkItem extends React.Component {
|
||||
}
|
||||
|
||||
const { search } = this.props.location
|
||||
const params = search ? new URLSearchParams(search) : { get: () => null }
|
||||
const id = params.get("id")
|
||||
|
||||
if (search) {
|
||||
const id = new URLSearchParams(search).get("id")
|
||||
|
||||
if (id) {
|
||||
api
|
||||
.getWorkItem(id)
|
||||
.then((workItem) => {
|
||||
if (workItem) {
|
||||
const [lng, lat] = workItem.location.coordinates
|
||||
const region = {
|
||||
latitude: lat,
|
||||
longitude: lng,
|
||||
latitudeDelta: 0.01,
|
||||
longitudeDelta: 0.01,
|
||||
}
|
||||
|
||||
workItem.location = formatLatLng(lat, lng)
|
||||
this.setState({
|
||||
binder: new FormBinder(workItem, WorkItem.bindings),
|
||||
region,
|
||||
})
|
||||
if (id) {
|
||||
api
|
||||
.getWorkItem(id)
|
||||
.then((workItem) => {
|
||||
if (workItem) {
|
||||
const [lng, lat] = workItem.location.coordinates
|
||||
const region = {
|
||||
latitude: lat,
|
||||
longitude: lng,
|
||||
latitudeDelta: 0.01,
|
||||
longitudeDelta: 0.01,
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
|
||||
workItem.location = formatLatLng(lat, lng)
|
||||
this.setState({
|
||||
messageModal: {
|
||||
icon: "hand",
|
||||
message: "Unable to get work item details",
|
||||
detail: err.message,
|
||||
back: true,
|
||||
},
|
||||
binder: new FormBinder(workItem, WorkItem.bindings),
|
||||
region,
|
||||
})
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
this.setState({
|
||||
messageModal: {
|
||||
icon: "hand",
|
||||
message: "Unable to get work item details",
|
||||
detail: err.message,
|
||||
back: true,
|
||||
},
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,6 +217,7 @@ export class WorkItem extends React.Component {
|
||||
if (this.addressInput) {
|
||||
this.addressInput.handleChangeText(address)
|
||||
}
|
||||
this.setState({ region: ref.mapView.region })
|
||||
})
|
||||
.catch(() => {
|
||||
if (this.addressInput) {
|
||||
|
||||
Reference in New Issue
Block a user