mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-14 19:43:49 +00:00
Linked CreateServer component with redux
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
import Storage from '../../utils/Storage';
|
||||
import { assoc } from 'ramda';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
|
||||
const SERVERS_STORAGE_KEY = 'servers';
|
||||
|
||||
export class ServersService {
|
||||
constructor(storage) {
|
||||
@@ -6,13 +10,20 @@ export class ServersService {
|
||||
}
|
||||
|
||||
listServers = () => {
|
||||
return this.storage.get('servers');
|
||||
return this.storage.get(SERVERS_STORAGE_KEY);
|
||||
};
|
||||
|
||||
findServerById = serverId => {
|
||||
const servers = this.listServers();
|
||||
return servers[serverId];
|
||||
}
|
||||
};
|
||||
|
||||
createServer = server => {
|
||||
const servers = this.listServers();
|
||||
server = assoc('id', uuid(), server);
|
||||
servers[server.id] = server;
|
||||
this.storage.set(SERVERS_STORAGE_KEY, servers);
|
||||
};
|
||||
}
|
||||
|
||||
export default new ServersService(Storage);
|
||||
|
||||
Reference in New Issue
Block a user