Skip to content
Snippets Groups Projects
Commit 0414eb35 authored by Julia Friesel's avatar Julia Friesel
Browse files

When navigating to cycle day, remember origin

parent 54a3db40
No related branches found
No related tags found
No related merge requests found
......@@ -29,6 +29,10 @@ export default class App extends Component {
}
navigate = (pageName, props) => {
const curr = this.state.currentPage
if (navigatingToCycleDayFromMainMenuEntry(pageName, curr)) {
this.cycleDayOrigin = curr
}
this.setState({currentPage: pageName, currentProps: props})
}
......@@ -36,6 +40,9 @@ export default class App extends Component {
if (this.state.currentPage === 'Home') return false
if (isSymptomView(this.state.currentPage)) {
this.navigate('CycleDay', { cycleDay: this.state.currentProps.cycleDay })
} else if(this.state.currentPage === 'CycleDay') {
this.navigate(this.cycleDayOrigin || 'Home')
this.cycleDayOrigin = null
} else {
this.navigate('Home')
}
......@@ -63,3 +70,7 @@ export default class App extends Component {
)
}
}
function navigatingToCycleDayFromMainMenuEntry(target, curr) {
return target === 'CycleDay' && ['Home', 'Calendar', 'Chart'].indexOf(curr) > -1
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment