mirror of
https://github.com/hibiken/asynqmon.git
synced 2025-01-19 19:25:52 +08:00
50 lines
1.1 KiB
TypeScript
50 lines
1.1 KiB
TypeScript
|
import {
|
||
|
LIST_SCHEDULER_ENTRIES_BEGIN,
|
||
|
LIST_SCHEDULER_ENTRIES_ERROR,
|
||
|
LIST_SCHEDULER_ENTRIES_SUCCESS,
|
||
|
SchedulerEntriesActionTypes,
|
||
|
} from "../actions/schedulerEntriesActions";
|
||
|
import { SchedulerEntry } from "../api";
|
||
|
|
||
|
interface SchedulerEntriesState {
|
||
|
loading: boolean;
|
||
|
data: SchedulerEntry[];
|
||
|
error: string; // error description
|
||
|
}
|
||
|
|
||
|
const initialState: SchedulerEntriesState = {
|
||
|
loading: false,
|
||
|
data: [],
|
||
|
error: "",
|
||
|
};
|
||
|
|
||
|
function schedulerEntriesReducer(
|
||
|
state = initialState,
|
||
|
action: SchedulerEntriesActionTypes
|
||
|
): SchedulerEntriesState {
|
||
|
switch (action.type) {
|
||
|
case LIST_SCHEDULER_ENTRIES_BEGIN:
|
||
|
return {
|
||
|
...state,
|
||
|
loading: true,
|
||
|
};
|
||
|
case LIST_SCHEDULER_ENTRIES_SUCCESS:
|
||
|
return {
|
||
|
error: "",
|
||
|
loading: false,
|
||
|
data: action.payload.entries,
|
||
|
};
|
||
|
case LIST_SCHEDULER_ENTRIES_ERROR:
|
||
|
// TODO: set error state
|
||
|
return {
|
||
|
...state,
|
||
|
loading: false,
|
||
|
error: action.error,
|
||
|
};
|
||
|
default:
|
||
|
return state;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export default schedulerEntriesReducer;
|