Implemented loading of short URLs

This commit is contained in:
Alejandro Celaya
2018-06-15 21:49:25 +02:00
parent e4356720d7
commit c0203f1336
16 changed files with 191 additions and 33 deletions

View File

@@ -0,0 +1,21 @@
import { LIST_SHORT_URLS } from '../../reducers/types';
import ServersService from '../../servers/services';
import ShlinkApiClient from '../../api/ShlinkApiClient';
export default function shortUrlsListReducer(state = [], action) {
switch (action.type) {
case LIST_SHORT_URLS:
return action.shortUrls;
default:
return state;
}
}
export const listShortUrls = (serverId) => {
return async dispatch => {
const selectedServer = ServersService.findServerById(serverId);
ShlinkApiClient.setConfig(selectedServer);
dispatch({ type: LIST_SHORT_URLS, shortUrls: await ShlinkApiClient.listShortUrls() });
};
};