mirror of
https://github.com/hibiken/asynqmon.git
synced 2025-09-16 19:51:38 +08:00
Fetch servers info and show in ServersTable
This commit is contained in:
45
ui/src/reducers/serversReducer.ts
Normal file
45
ui/src/reducers/serversReducer.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import {
|
||||
LIST_SERVERS_BEGIN,
|
||||
LIST_SERVERS_ERROR,
|
||||
LIST_SERVERS_SUCCESS,
|
||||
ServersActionTypes,
|
||||
} from "../actions/serversActions";
|
||||
import { ServerInfo } from "../api";
|
||||
|
||||
interface ServersState {
|
||||
loading: boolean;
|
||||
data: ServerInfo[];
|
||||
}
|
||||
|
||||
const initialState: ServersState = {
|
||||
loading: false,
|
||||
data: [],
|
||||
};
|
||||
|
||||
export default function serversReducer(
|
||||
state = initialState,
|
||||
action: ServersActionTypes
|
||||
): ServersState {
|
||||
switch (action.type) {
|
||||
case LIST_SERVERS_BEGIN:
|
||||
return {
|
||||
...state,
|
||||
loading: true,
|
||||
};
|
||||
|
||||
case LIST_SERVERS_SUCCESS:
|
||||
return {
|
||||
loading: false,
|
||||
data: action.payload.servers,
|
||||
};
|
||||
|
||||
case LIST_SERVERS_ERROR:
|
||||
return {
|
||||
...state,
|
||||
loading: false,
|
||||
};
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user