ref: Refactoring

This commit is contained in:
Maksim Eltyshev
2022-08-04 13:31:14 +02:00
parent 1f569bdb61
commit 3714bbc06f
189 changed files with 3781 additions and 3486 deletions
+7 -2
View File
@@ -1,2 +1,7 @@
export * from './router';
export * from './login';
import router from './router';
import login from './login';
export default {
...router,
...login,
};
+12 -7
View File
@@ -1,22 +1,27 @@
import { call, put } from 'redux-saga/effects';
import { authenticate, clearAuthenticateError } from '../../../actions';
import actions from '../../../actions';
import api from '../../../api';
export function* authenticateService(data) {
yield put(authenticate(data));
export function* authenticate(data) {
yield put(actions.authenticate(data));
let accessToken;
try {
({ item: accessToken } = yield call(api.createAccessToken, data));
} catch (error) {
yield put(authenticate.failure(error));
yield put(actions.authenticate.failure(error));
return;
}
yield put(authenticate.success(accessToken));
yield put(actions.authenticate.success(accessToken));
}
export function* clearAuthenticateErrorService() {
yield put(clearAuthenticateError());
export function* clearAuthenticateError() {
yield put(actions.clearAuthenticateError());
}
export default {
authenticate,
clearAuthenticateError,
};
+12 -6
View File
@@ -1,19 +1,19 @@
import { call, put, select } from 'redux-saga/effects';
import { push } from 'connected-react-router';
import { pathsMatchSelector } from '../../../selectors';
import selectors from '../../../selectors';
import Paths from '../../../constants/Paths';
export function* goToLoginService() {
export function* goToLogin() {
yield put(push(Paths.LOGIN));
}
export function* goToRootService() {
export function* goToRoot() {
yield put(push(Paths.ROOT));
}
export function* handleLocationChangeService() {
const pathsMatch = yield select(pathsMatchSelector);
export function* handleLocationChange() {
const pathsMatch = yield select(selectors.selectPathsMatch);
if (!pathsMatch) {
return;
@@ -24,9 +24,15 @@ export function* handleLocationChangeService() {
case Paths.PROJECTS:
case Paths.BOARDS:
case Paths.CARDS:
yield call(goToLoginService);
yield call(goToLogin);
break;
default:
}
}
export default {
goToLogin,
goToRoot,
handleLocationChange,
};