Updated ApiClient to return pagination data when listing short URLs

This commit is contained in:
Alejandro Celaya 2018-06-17 17:21:47 +02:00
parent 1f157a015b
commit 66a81d7e58
3 changed files with 10 additions and 9 deletions

View file

@ -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]));
};

View file

@ -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 (
<div className="short-urls-container">
<div className="form-group"><SearchBar /></div>
<ShortUrlsList {...props} />
<ShortUrlsList {...props} shortUrlsList={props.shortUrlsList.data || []} />
{/* Pagination */}
</div>
);
}
export default connect(state => ({
shortUrlsList: state.shortUrlsList
}))(ShortUrls);

View file

@ -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);