Skip to content

Commit

Permalink
Added warning message when json goes bad.
Browse files Browse the repository at this point in the history
  • Loading branch information
Stardog committed Nov 10, 2017
1 parent 28daccf commit 753139f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion javascript/RoommateList/RoommateList.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict'
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import RoommateRow from './RoommateRow.jsx'
import Waiting from '../Mixin/Html/Waiting.jsx'
import SearchBar from './SearchBar.jsx'
Expand All @@ -12,6 +11,7 @@ import {profileLabel} from '../Mixin/Objects/ProfileData.js'
export default class RoommateList extends Component {
constructor(props) {
super(props)
this.error = false
this.state = {
roommates: null,
labels: {
Expand Down Expand Up @@ -84,12 +84,20 @@ export default class RoommateList extends Component {
} else {
this.setState({roommates: []})
}
}.bind(this)).fail(function(){
this.error = true
this.setState({roommates: []})
}.bind(this))
}

render() {
let rows

let message
if (this.error) {
message = <div className="alert alert-warning">An error occurred when trying to access the roommate list. Please contact the site administrators.</div>
}

if (this.state.roommates === null) {
return <Waiting label="Roommates"/>
} else if (this.state.roommates.length === 0) {
Expand All @@ -105,6 +113,7 @@ export default class RoommateList extends Component {
return (
<div>
<h2>Roommate listing</h2>
{message}
<SearchBar
updateSearchVars={this.updateSearchVars}
searchVars={this.state.searchVars}
Expand Down

0 comments on commit 753139f

Please sign in to comment.