Total Complexity | 8 |
Complexity/F | 1.33 |
Lines of Code | 37 |
Function Count | 6 |
Duplicated Lines | 0 |
Ratio | 0 % |
Coverage | 100% |
Changes | 0 |
1 | import serversService from '../services/ServersService'; |
||
2 | import { curry } from 'ramda'; |
||
3 | |||
4 | 6 | export const FETCH_SERVERS = 'shlink/servers/FETCH_SERVERS'; |
|
5 | |||
6 | export default function reducer(state = {}, action) { |
||
7 | 2 | switch (action.type) { |
|
8 | case FETCH_SERVERS: |
||
9 | 1 | return action.servers; |
|
10 | default: |
||
11 | 1 | return state; |
|
12 | } |
||
13 | } |
||
14 | |||
15 | 6 | export const _listServers = serversService => ({ |
|
16 | type: FETCH_SERVERS, |
||
17 | servers: serversService.listServers(), |
||
18 | }); |
||
19 | 6 | export const listServers = () => _listServers(serversService); |
|
20 | |||
21 | 6 | export const _createServer = (serversService, server) => { |
|
22 | 1 | serversService.createServer(server); |
|
23 | 1 | return _listServers(serversService); |
|
24 | }; |
||
25 | 6 | export const createServer = curry(_createServer)(serversService); |
|
26 | |||
27 | 6 | export const _deleteServer = (serversService, server) => { |
|
28 | 1 | serversService.deleteServer(server); |
|
29 | 1 | return _listServers(serversService); |
|
30 | }; |
||
31 | 6 | export const deleteServer = curry(_deleteServer)(serversService); |
|
32 | |||
33 | 6 | export const _createServers = (serversService, servers) => { |
|
34 | 1 | serversService.createServers(servers); |
|
35 | 1 | return _listServers(serversService); |
|
36 | }; |
||
37 | export const createServers = curry(_createServers)(serversService); |
||
38 |