36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { put, call } from 'redux-saga/effects';
|
|
import { FETCH_PROJECTS_SUCCESS, FETCH_PROJECTS_FAILURE, FETCH_PROJECT_MILESTONES_FAILURE, FETCH_PROJECT_MILESTONES_SUCCESS } from '../actions/projects';
|
|
import { gitea } from '../../util/gitea';
|
|
|
|
export function* fetchProjectsSaga() {
|
|
|
|
let projects;
|
|
try {
|
|
projects = yield call(gitea.fetchUserProjects.bind(gitea))
|
|
} catch (error) {
|
|
yield put({ type: FETCH_PROJECTS_FAILURE, error });
|
|
return;
|
|
}
|
|
|
|
yield put({ type: FETCH_PROJECTS_SUCCESS, projects });
|
|
}
|
|
|
|
export function* fetchProjectsMilestonesSaga(action: any) {
|
|
const { projects } = action;
|
|
let milestones = [];
|
|
try {
|
|
for (var i = 0; i < projects.length; i++) {
|
|
console.log("PROJECT ", projects[i])
|
|
milestones.push({
|
|
project: projects[i],
|
|
milestones: yield call(gitea.fetchMilestones.bind(gitea), projects[i])
|
|
})
|
|
}
|
|
console.log("MILESTONES", milestones)
|
|
} catch (error) {
|
|
yield put({ type: FETCH_PROJECT_MILESTONES_FAILURE, error });
|
|
return;
|
|
}
|
|
|
|
yield put({ type: FETCH_PROJECT_MILESTONES_SUCCESS, milestones });
|
|
} |