Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Reverting #147 #151

Merged
merged 1 commit into from
Sep 18, 2018
Merged
Show file tree
Hide file tree
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
7 changes: 1 addition & 6 deletions src/features/rewards/modalContribute/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,10 @@ export interface Props {
onClose: () => void
onRestore: () => void
id?: string
sortByAttentionDesc?: boolean
numExcludedSites?: number
}

export default class ModalContribute extends React.PureComponent<Props, {}> {
static defaultProps = {
sortByAttentionDesc: true
}

get headers () {
return [
Expand All @@ -45,7 +41,7 @@ export default class ModalContribute extends React.PureComponent<Props, {}> {
}

render () {
const { id, onClose, onRestore, sortByAttentionDesc, rows, numExcludedSites } = this.props
const { id, onClose, onRestore, rows, numExcludedSites } = this.props
const numSites = rows && rows.length || 0

return (
Expand All @@ -72,7 +68,6 @@ export default class ModalContribute extends React.PureComponent<Props, {}> {
allSites={true}
showRowAmount={true}
showRemove={true}
sortByAttentionDesc={sortByAttentionDesc}
/>
</StyledWrapper>
</Modal>
Expand Down
17 changes: 4 additions & 13 deletions src/features/rewards/tableContribute/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,10 @@ export interface Props {
rows?: DetailRow[]
numSites?: number
allSites?: boolean
sortByAttentionDesc?: boolean
onShowAll?: () => void
}

export default class TableContribute extends React.PureComponent<Props, {}> {
static defaultProps = {
sortByAttentionDesc: true
}

getHeader = (header: string[]) => {
if (!header) {
Expand Down Expand Up @@ -84,17 +80,12 @@ export default class TableContribute extends React.PureComponent<Props, {}> {
})
}

getRows = (rows?: DetailRow[], sortByAttentionDesc?: boolean): Row[] | undefined => {
getRows = (rows?: DetailRow[]): Row[] | undefined => {
if (!rows) {
return
}

return rows.sort((cur: DetailRow, prev: DetailRow) => {
return sortByAttentionDesc
? prev.attention - cur.attention
: cur.attention - prev.attention
})
.map((row: DetailRow): Row => {
return rows.map((row: DetailRow): Row => {
const cell: Row = {
content: [
{
Expand Down Expand Up @@ -177,15 +168,15 @@ export default class TableContribute extends React.PureComponent<Props, {}> {
}

render () {
const { id, header, children, sortByAttentionDesc, rows, allSites, onShowAll } = this.props
const { id, header, children, rows, allSites, onShowAll } = this.props
const numSites = this.props.numSites || 0

return (
<div id={id}>
<Table
header={this.getHeader(header)}
children={children}
rows={this.getRows(rows, sortByAttentionDesc)}
rows={this.getRows(rows)}
/>
{
!allSites && numSites > 0
Expand Down
3 changes: 1 addition & 2 deletions stories/features/rewards/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import * as React from 'react'
import { withState } from '@dump247/storybook-state'
import { storiesOf } from '@storybook/react'
import { boolean, withKnobs, text } from '@storybook/addon-knobs'
import { withKnobs, text } from '@storybook/addon-knobs'

// Components
import { TabsType } from '../../../src/features/rewards/modalBackupRestore'
Expand Down Expand Up @@ -109,7 +109,6 @@ storiesOf('Feature Components/Rewards/Modal', module)
onClose={doNothing}
numExcludedSites={25}
onRestore={doNothing}
sortByAttentionDesc={boolean('Sort DESC', true)}
/>
)
})
Expand Down
1 change: 0 additions & 1 deletion stories/features/rewards/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ storiesOf('Feature Components/Rewards/Table', module)
showRowAmount={boolean('Show row amount', false)}
showRemove={boolean('Show remove action', true)}
headerColor={boolean('Colored header', true)}
sortByAttentionDesc={boolean('Sort DESC', true)}
>
Please visit some sites
</TableContribute>
Expand Down