Merge git://192.168.0.112

This commit is contained in:
2020-02-19 13:22:26 +01:00
18 changed files with 614 additions and 13 deletions

View File

@ -0,0 +1,53 @@
import { call, put } from 'redux-saga/effects';
import { projectUserListFailure, projectUserListSuccess, projectListFailure, projectListSuccess } from '../actions/project';
export function* projectUserListSaga() {
let result
try {
result = yield call(projectUserList);
} catch(err) {
yield put(projectUserListFailure(err));
return
}
if ('error' in result) {
yield put(projectUserListFailure(result.error));
return
}
yield put(projectUserListSuccess(result.data));
}
const projectUserList = () => {
return fetch('http://localhost:8001/api/v1/me', {
method: 'GET',
mode: 'cors',
credentials: 'include'
}).then(res => res.json())
}
export function* projectListSaga() {
let result
try {
result = yield call(projectList);
} catch(err) {
yield put(projectListFailure(err));
return
}
if ('error' in result) {
yield put(projectListFailure(result.error));
return
}
yield put(projectListSuccess(result.data));
}
const projectList = () => {
return fetch('http://localhost:8001/api/v1/projects', {
method: 'GET',
mode: 'cors',
credentials: 'include'
}).then(res => res.json())
}

View File

@ -1,9 +1,13 @@
import { all, takeLatest } from 'redux-saga/effects';
import { LOGIN_REQUEST } from '../actions/auth.actions';
import { loginSaga} from './auth.sagas';
import { PROJECT_USER_LIST, PROJECT_LIST } from '../actions/project';
import { projectUserListSaga, projectListSaga } from './project';
export default function* rootSaga() {
yield all([
takeLatest(LOGIN_REQUEST, loginSaga),
takeLatest(PROJECT_USER_LIST, projectUserListSaga),
takeLatest(PROJECT_LIST, projectListSaga),
]);
}