From 66a81d7e58453eeffa749ef2ea20854f91e28c03 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 17 Jun 2018 17:21:47 +0200 Subject: [PATCH] Updated ApiClient to return pagination data when listing short URLs --- src/api/ShlinkApiClient.js | 2 +- src/short-urls/ShortUrls.js | 12 +++++++++--- src/short-urls/ShortUrlsList.js | 5 ----- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/api/ShlinkApiClient.js b/src/api/ShlinkApiClient.js index 7630c322..494bcc89 100644 --- a/src/api/ShlinkApiClient.js +++ b/src/api/ShlinkApiClient.js @@ -26,7 +26,7 @@ export class ShlinkApiClient { */ listShortUrls = (params = {}) => { return this._performRequest('/rest/short-codes', 'GET', params) - .then(resp => resp.data.shortUrls.data) + .then(resp => resp.data.shortUrls) .catch(e => this._handleAuthError(e, this.listShortUrls, [params])); }; diff --git a/src/short-urls/ShortUrls.js b/src/short-urls/ShortUrls.js index fe892434..f6e16523 100644 --- a/src/short-urls/ShortUrls.js +++ b/src/short-urls/ShortUrls.js @@ -1,13 +1,19 @@ import React from 'react'; +import { connect } from 'react-redux'; import SearchBar from './SearchBar'; -import ShortUrlsList from './ShortUrlsList'; import './ShortUrls.scss'; +import ShortUrlsList from './ShortUrlsList'; -export default function ShortUrls(props) { +export function ShortUrls(props) { return (
- + + {/* Pagination */}
); } + +export default connect(state => ({ + shortUrlsList: state.shortUrlsList +}))(ShortUrls); diff --git a/src/short-urls/ShortUrlsList.js b/src/short-urls/ShortUrlsList.js index e2b8ef32..738a49c2 100644 --- a/src/short-urls/ShortUrlsList.js +++ b/src/short-urls/ShortUrlsList.js @@ -16,10 +16,6 @@ import './ShortUrlsList.scss'; export class ShortUrlsList extends React.Component { componentDidMount() { const { match } = this.props; - console.log(this.props.shortUrlsListParams, match.params, { - ...this.props.shortUrlsListParams, - page: match.params.page - }); this.props.listShortUrls(match.params.serverId, { ...this.props.shortUrlsListParams, page: match.params.page @@ -134,7 +130,6 @@ class RowMenu extends React.Component { } export default connect(state => ({ - shortUrlsList: state.shortUrlsList, selectedServer: state.selectedServer, shortUrlsListParams: state.shortUrlsListParams, }), { listShortUrls })(ShortUrlsList);