Skip to content

Commit

Permalink
Merge pull request #8438 from brave/ksmith-fix-report-dropdown
Browse files Browse the repository at this point in the history
Fix edge cases for Rewards monthly report drop-down
  • Loading branch information
zenparsing authored Apr 7, 2021
2 parents 850198c + 26ec296 commit 4c41e40
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -676,8 +676,8 @@ class PageWallet extends React.Component<Props, State> {
const { monthlyReportIds } = this.props.rewardsData

const ids = [
...monthlyReportIds || [],
`${new Date().getFullYear()}_${new Date().getMonth() + 1}`
`${new Date().getFullYear()}_${new Date().getMonth() + 1}`,
...monthlyReportIds || []
]

let result: Record<string, string> = {}
Expand All @@ -695,6 +695,11 @@ class PageWallet extends React.Component<Props, State> {
return
}

// Don't show drop-down items for a future month
if (new Date(year, month).getTime() > Date.now()) {
return
}

const date = new Date(Date.UTC(year, month, 10))
result[id] = new Intl.DateTimeFormat('default', { month: 'long', year: 'numeric' }).format(date)
})
Expand Down

0 comments on commit 4c41e40

Please sign in to comment.