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

39 lines
726 B
JavaScript
Raw Normal View History

2019-08-31 04:07:25 +05:00
import { call, put, select } from 'redux-saga/effects';
2022-11-21 00:54:05 +01:00
import { push } from 'redux-first-history';
2019-08-31 04:07:25 +05:00
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;
}
2022-11-21 00:54:05 +01:00
switch (pathsMatch.pattern.path) {
2019-08-31 04:07:25 +05:00
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,
};