Show error alert when data is not available

This commit is contained in:
Ken Hibino
2021-01-09 13:48:49 -08:00
parent 933127cc0e
commit 251b262798
13 changed files with 230 additions and 123 deletions

View File

@@ -8,11 +8,13 @@ import { ServerInfo } from "../api";
interface ServersState {
loading: boolean;
error: string;
data: ServerInfo[];
}
const initialState: ServersState = {
loading: false,
error: "",
data: [],
};
@@ -30,12 +32,14 @@ export default function serversReducer(
case LIST_SERVERS_SUCCESS:
return {
loading: false,
error: "",
data: action.payload.servers,
};
case LIST_SERVERS_ERROR:
return {
...state,
error: action.error,
loading: false,
};