@ -12,4 +12,12 @@ export const SAVE_BOARD_FAILURE = "SAVE_BOARD_FAILURE";
|
||||
|
||||
export function saveBoard(board) {
|
||||
return { type: SAVE_BOARD_REQUEST, board };
|
||||
};
|
||||
|
||||
export const DELETE_BOARD_REQUEST = "DELETE_BOARD_REQUEST";
|
||||
export const DELETE_BOARD_SUCCESS = "DELETE_BOARD_SUCCESS";
|
||||
export const DELETE_BOARD_FAILURE = "DELETE_BOARD_FAILURE";
|
||||
|
||||
export function deleteBoard(id) {
|
||||
return { type: DELETE_BOARD_REQUEST, id };
|
||||
};
|
@ -16,12 +16,13 @@ export function boardsReducer(state = defaultState, action) {
|
||||
}
|
||||
|
||||
function handleSaveBoardSuccess(state, action) {
|
||||
const { board } = action;
|
||||
return {
|
||||
...state,
|
||||
byID: {
|
||||
...state.byID,
|
||||
[action.board.id.toString()]: {
|
||||
...action.board,
|
||||
[board.id]: {
|
||||
...board,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { put, call } from 'redux-saga/effects';
|
||||
import { FETCH_BOARDS_SUCCESS, SAVE_BOARD_SUCCESS, SAVE_BOARD_FAILURE, FETCH_BOARDS_FAILURE } from '../actions/boards';
|
||||
import { FETCH_BOARDS_SUCCESS, SAVE_BOARD_SUCCESS, SAVE_BOARD_FAILURE, FETCH_BOARDS_FAILURE, DELETE_BOARD_FAILURE, DELETE_BOARD_SUCCESS } from '../actions/boards';
|
||||
import { api } from '../../util/api';
|
||||
|
||||
export function* fetchBoardsSaga() {
|
||||
@ -27,3 +27,17 @@ export function* saveBoardSaga(action) {
|
||||
|
||||
yield put({ type: SAVE_BOARD_SUCCESS, board });
|
||||
}
|
||||
|
||||
|
||||
export function* deleteBoardSaga(action) {
|
||||
let { id } = action;
|
||||
|
||||
try {
|
||||
board = yield call(api.deleteBoard, id)
|
||||
} catch(error) {
|
||||
yield put({ type: DELETE_BOARD_FAILURE, error });
|
||||
return
|
||||
}
|
||||
|
||||
yield put({ type: DELETE_BOARD_SUCCESS, id });
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
import { all, takeEvery, takeLatest } from 'redux-saga/effects';
|
||||
import { failuresSaga } from './failure';
|
||||
import { FETCH_BOARDS_REQUEST, SAVE_BOARD_REQUEST } from '../actions/boards';
|
||||
import { fetchBoardsSaga, saveBoardSaga } from './boards';
|
||||
import { FETCH_BOARDS_REQUEST, SAVE_BOARD_REQUEST, DELETE_BOARD_REQUEST } from '../actions/boards';
|
||||
import { fetchBoardsSaga, saveBoardSaga, deleteBoardSaga } from './boards';
|
||||
import { FETCH_ISSUES_REQUEST, ADD_LABEL_REQUEST, REMOVE_LABEL_REQUEST, CREATE_ISSUE_REQUEST, CREATE_ISSUE_SUCCESS } from '../actions/issues';
|
||||
import { fetchIssuesSaga, addLabelSaga, removeLabelSaga, createIssueSaga } from './issues';
|
||||
import { FETCH_PROJECTS_REQUEST } from '../actions/projects';
|
||||
@ -17,6 +17,7 @@ export function* rootSaga() {
|
||||
takeLatest(FETCH_BOARDS_REQUEST, fetchBoardsSaga),
|
||||
takeLatest(BUILD_KANBOARD_REQUEST, buildKanboardSaga),
|
||||
takeLatest(SAVE_BOARD_REQUEST, saveBoardSaga),
|
||||
takeLatest(DELETE_BOARD_REQUEST, deleteBoardSaga),
|
||||
takeLatest(FETCH_ISSUES_REQUEST, fetchIssuesSaga),
|
||||
takeLatest(FETCH_PROJECTS_REQUEST, fetchProjectsSaga),
|
||||
takeEvery(MOVE_CARD, moveCardSaga),
|
||||
|
Reference in New Issue
Block a user