Skip to content
This repository has been archived by the owner on Apr 29, 2022. It is now read-only.

Commit

Permalink
added pagination buttons, removed unused imports
Browse files Browse the repository at this point in the history
  • Loading branch information
harumhelmy committed Jul 29, 2020
1 parent cd1607e commit 6b4400a
Showing 1 changed file with 45 additions and 6 deletions.
51 changes: 45 additions & 6 deletions src/components/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@
import React, { useEffect, useState, useCallback, useMemo } from 'react';
import { Helmet } from 'react-helmet-async';
import omit from 'lodash/omit';
import { ORG } from '../constants';
import { subDays } from 'date-fns'
import { MdChevronRight, MdFirstPage } from 'react-icons/md';
import { useHistory, useLocation } from 'react-router-dom';

import { ORG } from '../constants';
import Org from './org';

// hooks
import { useActionsSearchResults, usePreprintActions, usePreprintSearchResults } from '../hooks/api-hooks';
import { usePreprintSearchResults } from '../hooks/api-hooks';

// utils
import { checkIfIsModerated } from '../utils/actions';
import { getTags, getUsersRank, isYes } from '../utils/stats';
import { createActivityQs, createPreprintQs, apifyPreprintQs } from '../utils/search';
import { getId, arrayify } from '../utils/jsonld'
import { getUsersRank, isYes } from '../utils/stats';
import { createPreprintQs, apifyPreprintQs } from '../utils/search';
import { getId } from '../utils/jsonld'


// contexts
Expand All @@ -22,6 +25,8 @@ import { useUser } from '../contexts/user-context';
// modules
import AddButton from './add-button';
import Banner from "./banner.js";
import Button from './button';

import Checkbox from './checkbox';
import SortOptions from './sort-options';
import HeaderBar from './header-bar';
Expand All @@ -31,7 +36,6 @@ import XLink from './xlink';
import RecentActivity from './recent-activity'
import ActiveUser from './active-user'

import { subDays } from 'date-fns'

export default function Dashboard() {
const history = useHistory();
Expand Down Expand Up @@ -370,6 +374,41 @@ export default function Dashboard() {
</ul>
)}
</div>

<div className="home__pagination">
{!!(location.state && location.state.bookmark) && (
<Button
onClick={() => {
history.push({
pathname: location.pathname,
search: createPreprintQs({ text: params.get('q') }, location.search)
});
}}
>
<MdFirstPage /> First page
</Button>
)}
{/* Cloudant returns the same bookmark when it hits the end of the list */}
{!!(
preprints.rows.length < preprints.total_rows &&
preprints.bookmark !== (location.state && location.state.bookmark)
) && (
<Button
className="home__next-page-button"
onClick={() => {
history.push({
pathname: location.pathname,
search: createPreprintQs({ text: params.get('q') }, location.search),
state: { bookmark: preprints.bookmark }
});
}}
>
Next Page <MdChevronRight />
</Button>
)}
</div>


<div className="dashboard__flex_item">
<div>
<AddButton
Expand Down

0 comments on commit 6b4400a

Please sign in to comment.