mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-08-03 09:32:06 +00:00
Implemented loading of short URLs
This commit is contained in:
21
src/short-urls/reducers/shortUrlsList.js
Normal file
21
src/short-urls/reducers/shortUrlsList.js
Normal 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() });
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user