Created
March 7, 2018 12:52
-
-
Save abel-masila/5db550cd3b7b4eafddb8d917a57ce119 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import loading_icon from '../images/ellipsis.gif'; | |
export default class BlankState extends Component { | |
constructor(props){ | |
super(props); | |
let { data = [], dataName = 'Info', isDataLoading, customMessage } = this.props; | |
this.state = { | |
dataName, | |
data, | |
isDataLoading, | |
customMessage | |
} | |
} | |
componentWillReceiveProps(nextProps){ | |
this.setState({ | |
...this.state, | |
...nextProps | |
}); | |
} | |
render(){ | |
const { customMessage, dataName, data, isDataLoading, className='' } = this.state; | |
return( | |
<div className="clearfix"> | |
{ isDataLoading === true ? | |
<div className={ "alert alert-warning alert-loading" + className }> | |
<img | |
src={ loading_icon } | |
className="img-responsive loading-icon" | |
alt="Loading..." /> | |
{ customMessage || "Loading " + dataName.toLocaleLowerCase() } | |
</div> | |
: | |
<div className="clearfix"> | |
{ data.length === 0 && data !== false ? | |
<div className={ "alert alert-warning " + className }> | |
No { dataName.toLocaleLowerCase() } found | |
</div> | |
: | |
null | |
} | |
</div> | |
} | |
</div> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment