You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
726 B
JavaScript
39 lines
726 B
JavaScript
import { call, put, select } from 'redux-saga/effects';
|
|
import { push } from 'redux-first-history';
|
|
|
|
import selectors from '../../../selectors';
|
|
import Paths from '../../../constants/Paths';
|
|
|
|
export function* goToLogin() {
|
|
yield put(push(Paths.LOGIN));
|
|
}
|
|
|
|
export function* goToRoot() {
|
|
yield put(push(Paths.ROOT));
|
|
}
|
|
|
|
export function* handleLocationChange() {
|
|
const pathsMatch = yield select(selectors.selectPathsMatch);
|
|
|
|
if (!pathsMatch) {
|
|
return;
|
|
}
|
|
|
|
switch (pathsMatch.pattern.path) {
|
|
case Paths.ROOT:
|
|
case Paths.PROJECTS:
|
|
case Paths.BOARDS:
|
|
case Paths.CARDS:
|
|
yield call(goToLogin);
|
|
|
|
break;
|
|
default:
|
|
}
|
|
}
|
|
|
|
export default {
|
|
goToLogin,
|
|
goToRoot,
|
|
handleLocationChange,
|
|
};
|