This repository has been archived on 2026-04-30. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
kingdombattles/src/components/pages/home.jsx
T
2019-06-09 12:35:33 +10:00

55 lines
1.2 KiB
React

import React from 'react';
import { withRouter, Link } from 'react-router-dom';
//panels
import CommonLinks from '../panels/common_links.jsx';
import Blurb from '../panels/blurb.jsx';
import News from '../panels/news.jsx';
class Home extends React.Component {
constructor(props) {
super(props);
this.state = {
warning: '', //TODO: unified warning?
fetch: null
};
}
componentDidUpdate(prevProps, prevState, snapshot) {
this.state.fetch();
}
render() {
let warningStyle = {
display: this.state.warning.length > 0 ? 'flex' : 'none'
};
return (
<div className='page'>
<div className='sidePanelPage'>
<div className='sidePanel'>
<CommonLinks />
</div>
<div className='mainPanel'>
<div className='warning' style={warningStyle}>
<p>{this.state.warning}</p>
</div>
<h1 className='centered'>About</h1>
<Blurb />
<h1 className='centered'>News</h1>
<News setWarning={this.setWarning.bind(this)} getFetch={ (fn) => this.setState({ fetch: fn }) } />
<p className='right'><Link to='/news'>See all news...</Link></p>
</div>
</div>
</div>
);
}
setWarning(s) {
this.setState({ warning: s });
}
};
export default withRouter(Home);