Total Complexity | 8 |
Complexity/F | 1.33 |
Lines of Code | 44 |
Function Count | 6 |
Duplicated Lines | 0 |
Ratio | 0 % |
Coverage | 100% |
Changes | 0 |
1 | import { curry } from 'ramda'; |
||
2 | import serversService from '../services/ServersService'; |
||
3 | |||
4 | 7 | 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 | 7 | export const _listServers = (serversService) => ({ |
|
16 | type: FETCH_SERVERS, |
||
17 | servers: serversService.listServers(), |
||
18 | }); |
||
19 | |||
20 | 7 | export const listServers = () => _listServers(serversService); |
|
21 | |||
22 | 7 | export const _createServer = (serversService, server) => { |
|
23 | 1 | serversService.createServer(server); |
|
24 | |||
25 | 1 | return _listServers(serversService); |
|
26 | }; |
||
27 | |||
28 | 7 | export const createServer = curry(_createServer)(serversService); |
|
29 | |||
30 | 7 | export const _deleteServer = (serversService, server) => { |
|
31 | 1 | serversService.deleteServer(server); |
|
32 | |||
33 | 1 | return _listServers(serversService); |
|
34 | }; |
||
35 | |||
36 | 7 | export const deleteServer = curry(_deleteServer)(serversService); |
|
37 | |||
38 | 7 | export const _createServers = (serversService, servers) => { |
|
39 | 1 | serversService.createServers(servers); |
|
40 | |||
41 | 1 | return _listServers(serversService); |
|
42 | }; |
||
43 | |||
44 | export const createServers = curry(_createServers)(serversService); |
||
45 |