-
Notifications
You must be signed in to change notification settings - Fork 920
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds promotions info in internals page
Resolves brave/brave-browser#9527
- Loading branch information
Showing
22 changed files
with
316 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
components/brave_rewards/resources/internals/components/promotion.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
import * as React from 'react' | ||
|
||
interface Props { | ||
promotion: RewardsInternals.Promotion | ||
} | ||
|
||
// Utils | ||
import { getLocale } from '../../../../common/locale' | ||
|
||
const getType = (type: number) => { | ||
switch (type) { | ||
case 0: | ||
return getLocale('promotionUGP') | ||
case 1: | ||
return getLocale('promotionAds') | ||
} | ||
|
||
return 'Missing type' | ||
} | ||
const getStatus = (status: number) => { | ||
switch (status) { | ||
case 0: | ||
return getLocale('promotionStatusActive') | ||
case 1: | ||
return getLocale('promotionStatusAttested') | ||
case 4: | ||
return getLocale('promotionStatusFinished') | ||
case 5: | ||
return getLocale('promotionStatusOver') | ||
} | ||
|
||
return 'Missing status' | ||
} | ||
|
||
const getLegacyClaimed = (legacy: boolean) => { | ||
return legacy | ||
? getLocale('promotionLegacyYes') | ||
: getLocale('promotionLegacyNo') | ||
} | ||
|
||
const getClaimData = (claimedAt: number, claimId: string) => { | ||
if (claimedAt === 0) { | ||
return null | ||
} | ||
|
||
return ( | ||
<> | ||
{getLocale('promotionClaimedAt')}: {new Date(claimedAt * 1000).toLocaleDateString()} | ||
<br/> | ||
{getLocale('promotionClaimId')}: {claimId} | ||
</> | ||
) | ||
} | ||
|
||
export const Promotion = (props: Props) => ( | ||
<div> | ||
{getLocale('promotionId')}: {props.promotion.promotionId} | ||
<br/> | ||
{getLocale('promotionStatus')}: {getStatus(props.promotion.status)} | ||
<br/> | ||
{getLocale('promotionAmount')}: {props.promotion.amount} {getLocale('bat')} | ||
<br/> | ||
{getLocale('promotionType')}: {getType(props.promotion.type)} | ||
<br/> | ||
{getLocale('promotionExpiresAt')}: {new Date(props.promotion.expiresAt * 1000).toLocaleDateString()} | ||
<br/> | ||
{getLocale('promotionLegacyClaimed')}: {getLegacyClaimed(props.promotion.legacyClaimed)} | ||
<br/> | ||
{getLocale('promotionVersion')}: {props.promotion.version} | ||
<br/> | ||
{getClaimData(props.promotion.claimedAt, props.promotion.claimId)} | ||
</div> | ||
) |
32 changes: 32 additions & 0 deletions
32
components/brave_rewards/resources/internals/components/promotions.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
import * as React from 'react' | ||
|
||
import { Promotion } from './promotion' | ||
|
||
interface Props { | ||
items: RewardsInternals.Promotion[] | ||
} | ||
|
||
// Utils | ||
import { getLocale } from '../../../../common/locale' | ||
|
||
export const Promotions = (props: Props) => { | ||
if (!props.items || props.items.length === 0) { | ||
return null | ||
} | ||
|
||
return ( | ||
<> | ||
<h3>{getLocale('promotions')}</h3> | ||
{props.items.map((item, index) => ( | ||
<div key={item.promotionId}> | ||
<Promotion promotion={item} /> | ||
{(index !== props.items.length - 1) ? <hr/> : null} | ||
</div> | ||
))} | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.