Handle inactive/no-building view/edit combinations

This commit is contained in:
Tom Russell 2019-10-02 15:15:13 +01:00
parent b1941ae358
commit bc53605f3f

View File

@ -213,7 +213,7 @@ const withCopyEdit = (WrappedComponent) => {
onSubmit={this.handleSubmit}> onSubmit={this.handleSubmit}>
<ErrorBox msg={this.state.error} /> <ErrorBox msg={this.state.error} />
{ {
(this.props.mode === 'edit' && this.props.inactive) ? (this.props.inactive) ?
<InfoBox <InfoBox
msg={`We're not collecting data on ${this.props.title.toLowerCase()} yet - check back soon.`} msg={`We're not collecting data on ${this.props.title.toLowerCase()} yet - check back soon.`}
/> />
@ -247,7 +247,29 @@ const withCopyEdit = (WrappedComponent) => {
: null : null
} }
</form> </form>
: <InfoBox msg="Select a building to view data"></InfoBox> :
<form>
{
(this.props.inactive)?
<Fragment>
<InfoBox
msg={`We're not collecting data on ${this.props.title.toLowerCase()} yet - check back soon.`}
/>
<WrappedComponent
building={undefined}
building_like={undefined}
mode={this.props.mode}
copy={copy}
onChange={this.handleChange}
onCheck={this.handleCheck}
onLike={this.handleLike}
onUpdate={this.handleUpdate}
/>
</Fragment>
:
<InfoBox msg="Select a building to view data"></InfoBox>
}
</form>
} }
</section> </section>
); );