mirror of
https://github.com/astuto/astuto.git
synced 2025-12-16 11:47:56 +01:00
Add Boards management to sitesettings (#107)
This commit is contained in:
committed by
GitHub
parent
7b8a4d6709
commit
6be2394dc5
93
app/javascript/reducers/SiteSettings/boardsReducer.ts
Normal file
93
app/javascript/reducers/SiteSettings/boardsReducer.ts
Normal file
@@ -0,0 +1,93 @@
|
||||
import {
|
||||
BoardsRequestActionTypes,
|
||||
BOARDS_REQUEST_START,
|
||||
BOARDS_REQUEST_SUCCESS,
|
||||
BOARDS_REQUEST_FAILURE,
|
||||
} from '../../actions/Board/requestBoards';
|
||||
|
||||
import {
|
||||
BoardSubmitActionTypes,
|
||||
BOARD_SUBMIT_START,
|
||||
BOARD_SUBMIT_SUCCESS,
|
||||
BOARD_SUBMIT_FAILURE,
|
||||
} from '../../actions/Board/submitBoard';
|
||||
|
||||
import {
|
||||
BoardUpdateActionTypes,
|
||||
BOARD_UPDATE_START,
|
||||
BOARD_UPDATE_SUCCESS,
|
||||
BOARD_UPDATE_FAILURE,
|
||||
} from '../../actions/Board/updateBoard';
|
||||
|
||||
import {
|
||||
BoardOrderUpdateActionTypes,
|
||||
BOARD_ORDER_UPDATE_START,
|
||||
BOARD_ORDER_UPDATE_SUCCESS,
|
||||
BOARD_ORDER_UPDATE_FAILURE,
|
||||
} from '../../actions/Board/updateBoardOrder';
|
||||
|
||||
import {
|
||||
BoardDeleteActionTypes,
|
||||
BOARD_DELETE_START,
|
||||
BOARD_DELETE_SUCCESS,
|
||||
BOARD_DELETE_FAILURE,
|
||||
} from '../../actions/Board/deleteBoard';
|
||||
|
||||
export interface SiteSettingsBoardsState {
|
||||
areUpdating: boolean;
|
||||
error: string;
|
||||
}
|
||||
|
||||
const initialState: SiteSettingsBoardsState = {
|
||||
areUpdating: false,
|
||||
error: '',
|
||||
};
|
||||
|
||||
const siteSettingsBoardsReducer = (
|
||||
state = initialState,
|
||||
action:
|
||||
BoardsRequestActionTypes |
|
||||
BoardSubmitActionTypes |
|
||||
BoardUpdateActionTypes |
|
||||
BoardOrderUpdateActionTypes |
|
||||
BoardDeleteActionTypes
|
||||
): SiteSettingsBoardsState => {
|
||||
switch (action.type) {
|
||||
case BOARDS_REQUEST_START:
|
||||
case BOARD_SUBMIT_START:
|
||||
case BOARD_UPDATE_START:
|
||||
case BOARD_ORDER_UPDATE_START:
|
||||
case BOARD_DELETE_START:
|
||||
return {
|
||||
...state,
|
||||
areUpdating: true,
|
||||
};
|
||||
|
||||
case BOARDS_REQUEST_SUCCESS:
|
||||
case BOARD_SUBMIT_SUCCESS:
|
||||
case BOARD_UPDATE_SUCCESS:
|
||||
case BOARD_ORDER_UPDATE_SUCCESS:
|
||||
case BOARD_DELETE_SUCCESS:
|
||||
return {
|
||||
...state,
|
||||
areUpdating: false,
|
||||
error: '',
|
||||
};
|
||||
|
||||
case BOARDS_REQUEST_FAILURE:
|
||||
case BOARD_SUBMIT_FAILURE:
|
||||
case BOARD_UPDATE_FAILURE:
|
||||
case BOARD_ORDER_UPDATE_FAILURE:
|
||||
case BOARD_DELETE_FAILURE:
|
||||
return {
|
||||
...state,
|
||||
areUpdating: false,
|
||||
error: action.error,
|
||||
};
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
export default siteSettingsBoardsReducer;
|
||||
Reference in New Issue
Block a user