mirror of
https://github.com/plankanban/planka.git
synced 2025-07-19 13:19:44 +02:00
Initial commit
This commit is contained in:
commit
36fe34e8e1
583 changed files with 91539 additions and 0 deletions
135
client/src/sagas/app/requests/board.js
Normal file
135
client/src/sagas/app/requests/board.js
Normal file
|
@ -0,0 +1,135 @@
|
|||
import { call, put } from 'redux-saga/effects';
|
||||
|
||||
import request from './request';
|
||||
import {
|
||||
createBoardFailed,
|
||||
createBoardRequested,
|
||||
createBoardSucceeded,
|
||||
deleteBoardFailed,
|
||||
deleteBoardRequested,
|
||||
deleteBoardSucceeded,
|
||||
fetchBoardFailed,
|
||||
fetchBoardRequested,
|
||||
fetchBoardSucceeded,
|
||||
updateBoardFailed,
|
||||
updateBoardRequested,
|
||||
updateBoardSucceeded,
|
||||
} from '../../../actions';
|
||||
import api from '../../../api';
|
||||
|
||||
export function* createBoardRequest(projectId, localId, data) {
|
||||
yield put(
|
||||
createBoardRequested(localId, {
|
||||
...data,
|
||||
projectId,
|
||||
}),
|
||||
);
|
||||
|
||||
try {
|
||||
const {
|
||||
item,
|
||||
included: { lists, labels },
|
||||
} = yield call(request, api.createBoard, projectId, data);
|
||||
|
||||
const action = createBoardSucceeded(localId, item, lists, labels);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = createBoardFailed(localId, error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* fetchBoardRequest(id) {
|
||||
yield put(fetchBoardRequested(id));
|
||||
|
||||
try {
|
||||
const {
|
||||
item,
|
||||
included: {
|
||||
lists, labels, cards, cardMemberships, cardLabels, tasks,
|
||||
},
|
||||
} = yield call(request, api.getBoard, id);
|
||||
|
||||
const action = fetchBoardSucceeded(
|
||||
item,
|
||||
lists,
|
||||
labels,
|
||||
cards,
|
||||
cardMemberships,
|
||||
cardLabels,
|
||||
tasks,
|
||||
);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = fetchBoardFailed(id, error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* updateBoardRequest(id, data) {
|
||||
yield put(updateBoardRequested(id, data));
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.updateBoard, id, data);
|
||||
|
||||
const action = updateBoardSucceeded(item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = updateBoardFailed(error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* deleteBoardRequest(id) {
|
||||
yield put(deleteBoardRequested(id));
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.deleteBoard, id);
|
||||
|
||||
const action = deleteBoardSucceeded(item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = deleteBoardFailed(error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue