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

Commit

Permalink
Adds option to not display grant expiry date
Browse files Browse the repository at this point in the history
  • Loading branch information
NejcZdovc committed Apr 9, 2019
1 parent 1b1ee01 commit e241000
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,6 @@ exports[`Grant complete tests basic tests matches the snapshot 1`] = `
>
BAT
</div>
<div
className="c2"
>
MISSING: grantExpire
</div>
<div
className="c3"
/>
</div>
<div
className="c4"
Expand Down
10 changes: 8 additions & 2 deletions src/features/rewards/grantComplete/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,14 @@ export default class GrantComplete extends React.PureComponent<Props, {}> {
<StyledBox>
<StyledTitle>{getLocale('newTokenGrant')}</StyledTitle>
<StyledValue>{amount} BAT</StyledValue>
<StyledTitle>{getLocale('grantExpire')}</StyledTitle>
<StyledValue>{date}</StyledValue>
{
date && date.length > 0
? <>
<StyledTitle>{getLocale('grantExpire')}</StyledTitle>
<StyledValue>{date}</StyledValue>
</>
: null
}
</StyledBox>
{
!isMobile
Expand Down
18 changes: 14 additions & 4 deletions src/features/rewards/walletWrapper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -411,10 +411,15 @@ export default class WalletWrapper extends React.PureComponent<Props, State> {
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 (
<>
<StyledWrapper
Expand All @@ -424,19 +429,19 @@ export default class WalletWrapper extends React.PureComponent<Props, State> {
notification={notification}
>
{
grant && !grant.expiryTime
grant && !grant.probi
? this.grantCaptcha()
: null
}
{
grant && grant.expiryTime
grant && grant.probi
? <GrantWrapper
isPanel={true}
onClose={this.onFinish}
title={getLocale('captchaLuckyDay')}
text={getLocale('captchaOnTheWay')}
>
<GrantComplete isMobile={true} onClose={this.onFinish} amount={tokens} date={new Date(grant.expiryTime).toLocaleDateString()} />
<GrantComplete isMobile={true} onClose={this.onFinish} amount={tokens} date={date} />
</GrantWrapper>
: null
}
Expand Down Expand Up @@ -498,7 +503,12 @@ export default class WalletWrapper extends React.PureComponent<Props, State> {
{
grants && grants.map((grant: Grant, i: number) => {
return <StyledGrant key={`${id}-grant-${i}`}>
<b>{grant.tokens} BAT</b> <span>{getLocale('expiresOn')} {grant.expireDate}</span>
<b>{grant.tokens} BAT</b>
{
grant.expireDate.length > 0
? <span>{getLocale('expiresOn')} {grant.expireDate}</span>
: null
}
</StyledGrant>
})
}
Expand Down
1 change: 1 addition & 0 deletions src/features/rewards/walletWrapper/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export const StyledGrant = styled<{}, 'div'>('div')`
min-width: 81px;
text-align: right;
display: inline-block;
padding-right: 5px;
}
span {
Expand Down

0 comments on commit e241000

Please sign in to comment.