Passed
Pull Request — master (#81)
by Alejandro
02:56
created

server.js ➔ ... ➔ ???   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 4
ccs 1
cts 1
cp 1
crap 1
rs 10
c 0
b 0
f 0
1 1
export const FETCH_SERVERS = 'shlink/servers/FETCH_SERVERS';
2
3
export default function reducer(state = {}, action) {
4 2
  switch (action.type) {
5
    case FETCH_SERVERS:
6 1
      return action.servers;
7
    default:
8 1
      return state;
9
  }
10
}
11
12 4
export const listServers = (serversService) => () => ({
13
  type: FETCH_SERVERS,
14
  servers: serversService.listServers(),
15
});
16
17 1
export const createServer = (serversService) => (server) => {
18 1
  serversService.createServer(server);
19
20 1
  return listServers(serversService)();
21
};
22
23 1
export const deleteServer = (serversService) => (server) => {
24 1
  serversService.deleteServer(server);
25
26 1
  return listServers(serversService)();
27
};
28
29 1
export const createServers = (serversService) => (servers) => {
30 1
  serversService.createServers(servers);
31
32 1
  return listServers(serversService)();
33
};
34