Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/screens/Proposals.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import BigNumber from 'bignumber.js'
import React, { useCallback, useMemo } from 'react'
import {
Box,
DropDown,
Button,
DataView,
Link,
Expand All @@ -26,7 +27,7 @@ import {

import { addressesEqualNoSum as addressesEqual } from '../lib/web3-utils'

const ENTRIES_PER_PAGE = 5
const ENTRIES_PER_PAGE = [5,10,25,50]

const Proposals = React.memo(
({
Expand Down Expand Up @@ -118,6 +119,13 @@ const Proposals = React.memo(
[history]
)

let current_entries_per_page = ENTRIES_PER_PAGE[0]
let selected_entries_per_page = 1
const updateProposalsPerPage = useCallback((selected, value) => {
current_entries_per_page = ENTRIES_PER_PAGE[selected]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that using a variable to store state is probably not the best option in React, considering it's lifecycle. Maybe using useState() to keep track/change this variable would be better!

selected_entries_per_page = selected
}, [])

return (
<div>
{!compactMode && (
Expand All @@ -138,6 +146,14 @@ const Proposals = React.memo(
display={compactMode ? 'icon' : 'label'}
/>
)}
<div>
<DropDown
id="perpage"
items={ENTRIES_PER_PAGE}
selected={selected_entries_per_page}
onChange={updateProposalsPerPage}
/>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a text inside the dropdown would be nice, to be more intuitive for the user!

</div>
<FilterBar
proposalsSize={filteredProposals.length}
proposalExecutionStatusFilter={proposalExecutionStatusFilter}
Expand Down Expand Up @@ -273,7 +289,7 @@ const Proposals = React.memo(
return entriesElements
}}
tableRowHeight={14 * GU}
entriesPerPage={ENTRIES_PER_PAGE}
entriesPerPage={current_entries_per_page}
page={currentPage}
onPageChange={handleProposalPageChange}
/>
Expand Down