diff --git a/frontend/src/app.js b/frontend/src/app.js index ac29f8871d..22e2f5aa93 100644 --- a/frontend/src/app.js +++ b/frontend/src/app.js @@ -35,11 +35,19 @@ class App extends Component { draftCounts: 0, draftList:[], isLoadingDraft: true, + currentTab: 'dashboard', }; } componentDidMount() { + // e.g. from http://127.0.0.1:8000/drafts/reviews/ + // get reviews + // TODO: need refactor later + let href = window.location.href.split('/'); this.getDrafts(); + this.setState({ + currentTab: href[href.length - 2] + }); } getDrafts = () => { @@ -71,19 +79,23 @@ class App extends Component { }); } - render() { + tabItemClick = (param) => { + this.setState({ + currentTab: param + }); + } - let href = window.location.href.split('/'); - let currentTab = href[href.length - 2]; + render() { + let { currentTab } = this.state; return (
- + - + { - this.setState({ - currentTab: param - }); + this.props.tabItemClick(param); } renderSharedGroups() { @@ -65,7 +63,7 @@ class MainSideNav extends React.Component { } return (