From e2410001e8e703f18cf4b36436d7b0c8271dadce Mon Sep 17 00:00:00 2001 From: NejcZdovc Date: Tue, 9 Apr 2019 12:02:44 +0200 Subject: [PATCH] Adds option to not display grant expiry date Partial for https://github.com/brave/brave-browser/issues/4042 --- .../grantComplete/__snapshots__/spec.tsx.snap | 8 -------- src/features/rewards/grantComplete/index.tsx | 10 ++++++++-- src/features/rewards/walletWrapper/index.tsx | 18 ++++++++++++++---- src/features/rewards/walletWrapper/style.ts | 1 + 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/features/rewards/grantComplete/__snapshots__/spec.tsx.snap b/src/features/rewards/grantComplete/__snapshots__/spec.tsx.snap index be96f5931..7db15de65 100644 --- a/src/features/rewards/grantComplete/__snapshots__/spec.tsx.snap +++ b/src/features/rewards/grantComplete/__snapshots__/spec.tsx.snap @@ -132,14 +132,6 @@ exports[`Grant complete tests basic tests matches the snapshot 1`] = ` > BAT -
- MISSING: grantExpire -
-
{ {getLocale('newTokenGrant')} {amount} BAT - {getLocale('grantExpire')} - {date} + { + date && date.length > 0 + ? <> + {getLocale('grantExpire')} + {date} + + : null + } { !isMobile diff --git a/src/features/rewards/walletWrapper/index.tsx b/src/features/rewards/walletWrapper/index.tsx index 8198fa8d2..71790bfe5 100644 --- a/src/features/rewards/walletWrapper/index.tsx +++ b/src/features/rewards/walletWrapper/index.tsx @@ -411,10 +411,15 @@ export default class WalletWrapper extends React.PureComponent { const hasGrants = this.hasGrants(grants) let tokens = '0.0' + let date = '' if (grant && grant.probi && convertProbiToFixed) { tokens = convertProbiToFixed(grant.probi, 1) } + if (grant && grant.expiryTime !== 0) { + date = new Date(grant.expiryTime).toLocaleDateString() + } + return ( <> { notification={notification} > { - grant && !grant.expiryTime + grant && !grant.probi ? this.grantCaptcha() : null } { - grant && grant.expiryTime + grant && grant.probi ? - + : null } @@ -498,7 +503,12 @@ export default class WalletWrapper extends React.PureComponent { { grants && grants.map((grant: Grant, i: number) => { return - {grant.tokens} BAT {getLocale('expiresOn')} {grant.expireDate} + {grant.tokens} BAT + { + grant.expireDate.length > 0 + ? {getLocale('expiresOn')} {grant.expireDate} + : null + } }) } diff --git a/src/features/rewards/walletWrapper/style.ts b/src/features/rewards/walletWrapper/style.ts index 14c34bce5..b6e45cec7 100644 --- a/src/features/rewards/walletWrapper/style.ts +++ b/src/features/rewards/walletWrapper/style.ts @@ -164,6 +164,7 @@ export const StyledGrant = styled<{}, 'div'>('div')` min-width: 81px; text-align: right; display: inline-block; + padding-right: 5px; } span {