Implemented importing servers from CSV file

This commit is contained in:
Alejandro Celaya
2018-08-21 20:33:12 +02:00
parent ac52f55c5e
commit 9b063a4616
7 changed files with 140 additions and 67 deletions

View File

@@ -2,17 +2,11 @@ import ServersService from '../services/ServersService';
import { curry } from 'ramda';
export const FETCH_SERVERS = 'shlink/servers/FETCH_SERVERS';
export const CREATE_SERVER = 'shlink/servers/CREATE_SERVER';
export const DELETE_SERVER = 'shlink/servers/DELETE_SERVER';
export default function reducer(state = {}, action) {
switch (action.type) {
case FETCH_SERVERS:
case DELETE_SERVER:
return action.servers;
case CREATE_SERVER:
const server = action.server;
return { ...state, [server.id]: server };
default:
return state;
}
@@ -35,3 +29,9 @@ export const _deleteServer = (ServersService, server) => {
return _listServers(ServersService);
};
export const deleteServer = curry(_deleteServer)(ServersService);
export const _createServers = (ServersService, servers) => {
ServersService.createServers(servers);
return _listServers(ServersService);
};
export const createServers = curry(_createServers)(ServersService);