Browse Source

Merge pull request #428 from NastiaS/polish

adding pagination for operation details
master
Gaëtan Renaudeau 7 years ago
committed by GitHub
parent
commit
c2f4ca1828
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/components/AccountPage/index.js
  2. 39
      src/components/OperationsList/index.js
  3. 10
      src/components/modals/AccountSettingRenderBody.js

2
src/components/AccountPage/index.js

@ -178,7 +178,7 @@ class AccountPage extends PureComponent<Props, State> {
)} )}
/> />
</Box> </Box>
<OperationsList account={account} title={t('account:lastOperations')} /> <OperationsList canShowMore account={account} title={t('account:lastOperations')} />
</Fragment> </Fragment>
) : ( ) : (
<EmptyStateAccount account={account} /> <EmptyStateAccount account={account} />

39
src/components/OperationsList/index.js

@ -66,31 +66,39 @@ type Props = {
openModal: Function, openModal: Function,
t: T, t: T,
withAccount?: boolean, withAccount?: boolean,
nbToShow: number,
title?: string, title?: string,
} }
export class OperationsList extends PureComponent<Props> { type State = {
nbToShow: number,
}
const initialState = {
nbToShow: 20,
}
export class OperationsList extends PureComponent<Props, State> {
static defaultProps = { static defaultProps = {
onAccountClick: noop, onAccountClick: noop,
withAccount: false, withAccount: false,
canShowMore: false, canShowMore: false,
nbToShow: 20,
} }
state = initialState
handleClickOperation = (data: Object) => this.props.openModal(MODAL_OPERATION_DETAILS, data) handleClickOperation = (data: Object) => this.props.openModal(MODAL_OPERATION_DETAILS, data)
// TODO: convert of async/await if fetching with the api
fetchMoreOperations = () => {
this.setState({ nbToShow: this.state.nbToShow + 20 })
}
render() { render() {
const { const { account, accounts, canShowMore, onAccountClick, t, title, withAccount } = this.props
account, const { nbToShow } = this.state
accounts,
canShowMore, const totalOperations = accounts
nbToShow, ? accounts.reduce((a, b) => +a + +b.operations.length, 0)
onAccountClick, : account.operations.length
t,
title,
withAccount,
} = this.props
if (!account && !accounts) { if (!account && !accounts) {
console.warn('Preventing render OperationsList because not received account or accounts') // eslint-disable-line no-console console.warn('Preventing render OperationsList because not received account or accounts') // eslint-disable-line no-console
@ -139,8 +147,9 @@ export class OperationsList extends PureComponent<Props> {
</Box> </Box>
) )
})} })}
{canShowMore && ( {canShowMore &&
<ShowMore> totalOperations > nbToShow && (
<ShowMore onClick={this.fetchMoreOperations}>
<span>{t('operationsList:showMore')}</span> <span>{t('operationsList:showMore')}</span>
<IconAngleDown size={12} /> <IconAngleDown size={12} />
</ShowMore> </ShowMore>

10
src/components/modals/AccountSettingRenderBody.js

@ -37,10 +37,6 @@ type Props = {
data: any, data: any,
} }
function onClickSelectAll(e) {
e.target.select()
}
const mapDispatchToProps = { const mapDispatchToProps = {
setDataModal, setDataModal,
updateAccount, updateAccount,
@ -173,14 +169,16 @@ class HelperComp extends PureComponent<Props, State> {
<textarea <textarea
style={{ style={{
userSelect: 'text', userSelect: 'text',
backgroundColor: '#eee', border: '1px dashed #f9f9f9',
marginTop: '20px',
backgroundColor: '#f9f9f9',
color: '#000', color: '#000',
fontFamily: 'monospace', fontFamily: 'monospace',
fontSize: '10px', fontSize: '10px',
height: 200, height: 200,
outline: 'none', outline: 'none',
padding: '20px',
}} }}
onClick={onClickSelectAll}
value={JSON.stringify(usefulData, null, 2)} value={JSON.stringify(usefulData, null, 2)}
/> />
</Spoiler> </Spoiler>

Loading…
Cancel
Save