Skip to content

Commit 2a36d08

Browse files
committed
fixed broken context access and moved mission state button #33
1 parent c1f43d8 commit 2a36d08

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

client/components/Mission.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@ export default React.createClass({
121121
const area = mission.area ? mission.area.name : '';
122122
const position = this.state.position;
123123
const right = { float: 'right' };
124-
let headOfMission = this.context.volunteers[this.props.mission.headOfMission] || {};
125-
headOfMission = headOfMission.name ? `${headOfMission.name.first} ${headOfMission.name.last}` : 'none yet';
124+
125+
let headOfMission = this.context.volunteers ? this.context.volunteers[this.props.mission.headOfMission] : {};
126+
headOfMission = headOfMission.name ? `${headOfMission.name.first} ${headOfMission.name.last}` : '';
126127

127128
const isMyMission = this.context.volunteer && !!mission.crew.find(a => a.volunteer.id === this.context.volunteer.id);
128129

@@ -131,15 +132,17 @@ export default React.createClass({
131132
{this.state.message &&
132133
<Alert type={this.state.message.type}>{this.state.message.text}</Alert>
133134
}
135+
134136
{this.props.isEditable
135137
? <Button onClick={this.toggleEdit} style={right}>Edit</Button>
136138
: <Pill label={mission.status} type="info" style={right} />
137139
}
138-
<h2>{mission.name} in {area} from {formatDate(mission.start)} till {formatDate(mission.end)}</h2>
139140

140-
<h4>Head of Mission: {headOfMission}</h4>
141+
<h2>{mission.name} {area && `in ${area}`} from {formatDate(mission.start)} till {formatDate(mission.end)}</h2>
141142

142-
{this.renderCrew(mission.crew)}
143+
{headOfMission &&
144+
<h4>Head of Mission: {headOfMission}</h4>
145+
}
143146

144147
{isMyMission &&
145148
<div style={{ textAlign: 'right', marginBottom: '1em' }}>
@@ -152,6 +155,8 @@ export default React.createClass({
152155
</div>
153156
}
154157

158+
{this.renderCrew(mission.crew)}
159+
155160
{position &&
156161
<Map center={position} zoom={this.state.zoom}>
157162
<TileLayer url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" />

0 commit comments

Comments
 (0)