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