Total Complexity | 8 |
Complexity/F | 1.33 |
Lines of Code | 37 |
Function Count | 6 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import ServersService from '../services/ServersService'; |
||
2 | import { curry } from 'ramda'; |
||
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 | export const listServers = () => _listServers(ServersService); |
||
20 | |||
21 | export const _createServer = (ServersService, server) => { |
||
22 | ServersService.createServer(server); |
||
23 | return _listServers(ServersService); |
||
24 | }; |
||
25 | export const createServer = curry(_createServer)(ServersService); |
||
26 | |||
27 | export const _deleteServer = (ServersService, server) => { |
||
28 | ServersService.deleteServer(server); |
||
29 | return _listServers(ServersService); |
||
30 | }; |
||
31 | export const deleteServer = curry(_deleteServer)(ServersService); |
||
32 | |||
33 | export const _createServers = (ServersService, servers) => { |
||
34 | ServersService.createServers(servers); |
||
35 | return _listServers(ServersService); |
||
36 | }; |
||
37 | export const createServers = curry(_createServers)(ServersService); |
||
38 |