Deal with initially having no work items
This commit is contained in:
@@ -92,36 +92,66 @@ export class Activity extends React.Component {
|
||||
}
|
||||
|
||||
const { search } = this.props.location
|
||||
const params = search ? new URLSearchParams(search) : { get: () => null }
|
||||
const id = params.get("id")
|
||||
const workItemId = params.get("workItemId")
|
||||
|
||||
if (search) {
|
||||
const id = new URLSearchParams(search).get("id")
|
||||
const getWorkItem = (id) => {
|
||||
api
|
||||
.getWorkItem(id)
|
||||
.then((workitem) => {
|
||||
if (workItem) {
|
||||
const [lng, lat] = workItem.location.coordinates
|
||||
|
||||
if (id) {
|
||||
api
|
||||
.getActivity(id)
|
||||
.then((activity) => {
|
||||
if (activity) {
|
||||
this.setState({
|
||||
binder: new FormBinder(activity, Activity.bindings),
|
||||
// region: {
|
||||
// latitude: lat,
|
||||
// longitude: lng,
|
||||
// latitudeDelta: 0.01,
|
||||
// longitudeDelta: 0.01,
|
||||
// },
|
||||
})
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
this.setState({
|
||||
messageModal: {
|
||||
icon: "hand",
|
||||
message: "Unable to get activity details",
|
||||
detail: err.message,
|
||||
back: true,
|
||||
region: {
|
||||
latitude: lat,
|
||||
longitude: lng,
|
||||
latitudeDelta: 0.01,
|
||||
longitudeDelta: 0.01,
|
||||
},
|
||||
})
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
this.setState({
|
||||
messageModal: {
|
||||
icon: "hand",
|
||||
message: "Unable to get work item details",
|
||||
detail: err.message,
|
||||
back: true,
|
||||
},
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
if (id) {
|
||||
api
|
||||
.getActivity(id)
|
||||
.then((activity) => {
|
||||
if (activity) {
|
||||
this.setState({
|
||||
binder: new FormBinder(activity, Activity.bindings),
|
||||
})
|
||||
|
||||
getWorkItem(activity.workItemId)
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
this.setState({
|
||||
messageModal: {
|
||||
icon: "hand",
|
||||
message: "Unable to get activity details",
|
||||
detail: err.message,
|
||||
back: true,
|
||||
},
|
||||
})
|
||||
})
|
||||
} else {
|
||||
if (workItemId) {
|
||||
getWorkItem(workItemId)
|
||||
} else {
|
||||
this.handleBackPress()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user