UNPKG

@wenn/onb

Version:

onb-core

32 lines (28 loc) 617 B
import { CURRENT_PAGE } from '../constants'; function saveNextPageRedux(current) { return { type: CURRENT_PAGE, current }; } export function saveNextPage(current) { return dispatch => { dispatch(saveNextPageRedux(current)); }; } export function goBack(back) { return (dispatch, getState) => { const { currentPage, settings: { config: { pages } } } = getState(); const index = pages.map(x => x.url).indexOf(currentPage); if (index > 0) { const url = pages[index - 1].url; dispatch(saveNextPage(url)); back && back(url); } }; }