Total Complexity | 11 |
Complexity/F | 1.22 |
Lines of Code | 33 |
Function Count | 9 |
Duplicated Lines | 0 |
Ratio | 0 % |
Coverage | 100% |
Changes | 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 |