Fetch servers info and show in ServersTable

This commit is contained in:
Ken Hibino
2020-12-31 07:02:54 -08:00
parent d78abcf584
commit 3f9e8820d9
6 changed files with 178 additions and 5 deletions

View 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;
}
}