Fix error occurring when navigating back from settings section

This commit is contained in:
Lisa Hillebrand
2020-12-13 16:16:11 +01:00
committed by emelko
parent c00e3f2bef
commit 8145619f28
+7 -10
View File
@@ -1,5 +1,5 @@
import { createSlice } from 'redux-starter-kit'
import { pages, isSymptomView } from '../components/pages'
import { pages } from '../components/pages'
const navigationSlice = createSlice({
slice: 'navigation',
@@ -14,22 +14,19 @@ const navigationSlice = createSlice({
}
},
goBack: ({ currentPage, previousPage }) => {
if (currentPage === 'CycleDay' || isSymptomView(currentPage)) {
if (previousPage) {
return {
currentPage: previousPage
}
if (currentPage === 'CycleDay' && !!previousPage) {
return {
currentPage: previousPage,
}
}
const page = pages.find(p => p.component === currentPage)
const page = pages.find((p) => p.component === currentPage)
return {
currentPage: page.parent,
previousPage: currentPage,
}
}
}
},
},
})
// Extract the action creators object and the reducer