Fix error occurring when navigating back from settings section

This commit is contained in:
Lisa
2020-12-20 10:48:56 +00:00
committed by Sofiya Tepikin
parent 08e01346f3
commit 9e907dad0b
+2 -10
View File
@@ -7,23 +7,15 @@ const navigationSlice = createSlice({
currentPage: 'Home', currentPage: 'Home',
}, },
reducers: { reducers: {
navigate: (state, action) => { navigate: (_state, action) => {
return { return {
currentPage: action.payload, currentPage: action.payload,
previousPage: state.currentPage,
} }
}, },
goBack: ({ currentPage, previousPage }) => { goBack: ({ currentPage }) => {
if (currentPage === 'CycleDay' && !!previousPage) {
return {
currentPage: previousPage,
}
}
const page = pages.find((p) => p.component === currentPage) const page = pages.find((p) => p.component === currentPage)
return { return {
currentPage: page.parent, currentPage: page.parent,
previousPage: currentPage,
} }
}, },
}, },