Linked CreateServer component with redux

This commit is contained in:
Alejandro Celaya
2018-07-16 18:25:37 +02:00
parent 554248c376
commit ebb94a17ab
5 changed files with 74 additions and 31 deletions

View File

@@ -8,7 +8,8 @@ export default function reducer(state = {}, action) {
case FETCH_SERVERS:
return action.servers;
case CREATE_SERVER:
return [ ...state, action.server ];
const server = action.server;
return { ...state, [server.id]: server };
default:
return state;
}
@@ -20,3 +21,8 @@ export const listServers = () => {
servers: ServersService.listServers(),
};
};
export const createServer = server => {
ServersService.createServer(server);
return listServers();
};