(ui): Add redux action/reducer for aggregating tasks

This commit is contained in:
Ken Hibino
2022-03-26 07:04:22 -07:00
parent f6d84b1dc2
commit a479098bd6
4 changed files with 148 additions and 1 deletions

View File

@@ -129,6 +129,9 @@ import {
BATCH_DELETE_COMPLETED_TASKS_BEGIN,
BATCH_DELETE_COMPLETED_TASKS_ERROR,
BATCH_DELETE_COMPLETED_TASKS_SUCCESS,
LIST_AGGREGATING_TASKS_BEGIN,
LIST_AGGREGATING_TASKS_SUCCESS,
LIST_AGGREGATING_TASKS_ERROR,
} from "../actions/tasksActions";
import { TaskInfo } from "../api";
@@ -191,6 +194,13 @@ interface TasksState {
error: string;
data: TaskInfoExtended[];
};
aggregatingTasks: {
loading: boolean;
batchActionPending: boolean;
allActionPending: boolean;
error: string;
data: TaskInfoExtended[];
};
taskInfo: {
loading: boolean;
error: string;
@@ -241,6 +251,13 @@ const initialState: TasksState = {
error: "",
data: [],
},
aggregatingTasks: {
loading: false,
batchActionPending: false,
allActionPending: false,
error: "",
data: [],
},
taskInfo: {
loading: false,
error: "",
@@ -485,6 +502,40 @@ function tasksReducer(
},
};
case LIST_AGGREGATING_TASKS_BEGIN:
return {
...state,
aggregatingTasks: {
...state.aggregatingTasks,
loading: true,
},
};
case LIST_AGGREGATING_TASKS_SUCCESS:
return {
...state,
aggregatingTasks: {
...state.aggregatingTasks,
loading: false,
error: "",
data: action.payload.tasks.map((task) => ({
...task,
requestPending: false,
})),
},
};
case LIST_AGGREGATING_TASKS_ERROR:
return {
...state,
aggregatingTasks: {
...state.aggregatingTasks,
loading: false,
error: action.error,
data: [],
},
};
case DELETE_COMPLETED_TASK_BEGIN:
return {
...state,