Skip to content

Commit 2590b13

Browse files
committed
show pagination above and below results
1 parent f2b7fcc commit 2590b13

File tree

1 file changed

+28
-23
lines changed

1 file changed

+28
-23
lines changed

frontend/src/components/ResultList.js

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -147,34 +147,39 @@ const ResultListCard = compose(
147147
)
148148
)(RawResultListCard);
149149

150+
const ResultListContainer = ({
151+
hideLoading,
152+
isFetching,
153+
classes,
154+
children = null
155+
}) => (
156+
<div className={classes.root}>
157+
<Pagination />
158+
{!hideLoading && (
159+
<div className={classes.loadingContainer}>
160+
{isFetching && <LinearProgress />}
161+
</div>
162+
)}
163+
{children}
164+
<Pagination />
165+
</div>
166+
);
167+
150168
export class ResultList extends Component {
151169
render() {
152-
const { items, isFetching, hideLoading, classes } = this.props;
153-
if (isFetching && hideLoading) return null;
154-
if (isFetching && (!items || isEmpty(items))) {
155-
return (
156-
<div className={classes.loadingContainer}>
157-
<LinearProgress />
158-
</div>
159-
);
160-
}
161-
if (!items || !Array.isArray(items)) return null;
170+
const { items } = this.props;
171+
172+
if (!items || !Array.isArray(items) || isEmpty(items))
173+
return <ResultListContainer {...this.props} />;
174+
162175
return (
163-
<div className={classes.root}>
164-
{!hideLoading && (
165-
<div className={classes.loadingContainer}>
166-
{isFetching && <LinearProgress />}
167-
</div>
168-
)}
176+
<ResultListContainer {...this.props}>
169177
<div>
170-
{items
171-
.slice(0, 1)
172-
.map((item, index) => (
173-
<ResultListCard key={item.id || index} item={item} />
174-
))}
178+
{items.map((item, index) => (
179+
<ResultListCard key={item.id || index} item={item} />
180+
))}
175181
</div>
176-
<Pagination />
177-
</div>
182+
</ResultListContainer>
178183
);
179184
}
180185
}

0 commit comments

Comments
 (0)