Files
planka/client/src/sagas/login/services/router.js

39 lines
721 B
JavaScript
Raw Normal View History

2019-08-31 04:07:25 +05:00
import { call, put, select } from 'redux-saga/effects';
import { push } from 'connected-react-router';
2022-08-04 13:31:14 +02:00
import selectors from '../../../selectors';
2019-08-31 04:07:25 +05:00
import Paths from '../../../constants/Paths';
2022-08-04 13:31:14 +02:00
export function* goToLogin() {
2019-08-31 04:07:25 +05:00
yield put(push(Paths.LOGIN));
}
2022-08-04 13:31:14 +02:00
export function* goToRoot() {
2019-08-31 04:07:25 +05:00
yield put(push(Paths.ROOT));
}
2022-08-04 13:31:14 +02:00
export function* handleLocationChange() {
const pathsMatch = yield select(selectors.selectPathsMatch);
2019-08-31 04:07:25 +05:00
if (!pathsMatch) {
return;
}
switch (pathsMatch.path) {
case Paths.ROOT:
case Paths.PROJECTS:
case Paths.BOARDS:
case Paths.CARDS:
2022-08-04 13:31:14 +02:00
yield call(goToLogin);
2019-08-31 04:07:25 +05:00
break;
default:
}
}
2022-08-04 13:31:14 +02:00
export default {
goToLogin,
goToRoot,
handleLocationChange,
};