Wrote a badge list page

This commit is contained in:
2019-06-08 17:10:33 +10:00
parent 9a42ef54f3
commit 562fae3871
12 changed files with 152 additions and 16 deletions
+50
View File
@@ -0,0 +1,50 @@
import React from 'react';
//panels
import CommonLinks from '../panels/common_links.jsx';
import BadgeListPanel from '../panels/badge_list.jsx';
class BadgeList 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'>Badges</h1>
<BadgeListPanel setWarning={this.setWarning.bind(this)} getFetch={ (fn) => this.setState({ fetch: fn }) } />
</div>
</div>
</div>
);
}
setWarning(s) {
this.setState({ warning: s });
}
};
export default BadgeList;
+3 -2
View File
@@ -1,4 +1,5 @@
import React from 'react';
import { withRouter, Link } from 'react-router-dom';
import { connect } from 'react-redux';
//panels
@@ -42,7 +43,7 @@ class BadgeSelect extends React.Component {
</div>
<h1 className='centered'>Badge Select</h1>
<p className='centered'>Click on your favourite badge!</p>
<p className='centered'>Click on your favourite badge! <Link to='/badges/list'>Full list here</Link>.</p>
<BadgeSelectPanel setWarning={this.setWarning.bind(this)} getFetch={ (fn) => this.setState({ fetch: fn }) } />
</div>
</div>
@@ -70,4 +71,4 @@ const mapDispatchToProps = (dispatch) => {
BadgeSelect = connect(mapStoreToProps, mapDispatchToProps)(BadgeSelect);
export default BadgeSelect;
export default withRouter(BadgeSelect);