Skip to content

Commit

Permalink
Show error text to users that are not in allowed regions
Browse files Browse the repository at this point in the history
  • Loading branch information
NejcZdovc committed Aug 30, 2019
1 parent c23d0c9 commit dfa9f58
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 66 deletions.
5 changes: 4 additions & 1 deletion browser/ui/webui/brave_webui_source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,10 @@ void CustomizeWebUIHTMLSource(const std::string &name,
{ "walletCorrupted", IDS_BRAVE_REWARDS_LOCAL_WALLET_CORRUPTED },
{ "walletCorruptedNow", IDS_BRAVE_REWARDS_LOCAL_WALLET_CORRUPTED_NOW },
{ "grantAlreadyClaimedText", IDS_BRAVE_REWARDS_LOCAL_GRANT_ALREADY_CLAIMED_TEXT }, // NOLINT
{ "redirectModalError", IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_ERROR }, // NOLINT
{ "redirectModalError", IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_ERROR },
{ "redirectModalNotAllowed", IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_NOT_ALLOWED }, // NOLINT
{ "redirectModalClose", IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_CLOSE },
{ "redirectModalErrorWallet", IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_ERROR_WALLET }, // NOLINT

{ "click", IDS_BRAVE_REWARDS_LOCAL_ADS_CONFIRMATION_TYPE_CLICK },
{ "dismiss", IDS_BRAVE_REWARDS_LOCAL_ADS_CONFIRMATION_TYPE_DISMISS },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,27 @@ class SettingsPage extends React.Component<Props, State> {
const { ui } = this.props.rewardsData

if (ui.modalRedirect === 'show') {
return <ModalRedirect />
return <ModalRedirect
titleText={getLocale('processingRequest')}
/>
}

if (ui.modalRedirect === 'notAllowed') {
return (
<ModalRedirect
errorText={getLocale('redirectModalNotAllowed', 'https://uphold.com/en/brave/support')}
buttonText={getLocale('redirectModalClose')}
onClick={this.actions.hideRedirectModal}
/>
)
}

if (ui.modalRedirect === 'error') {
return (
<ModalRedirect
errorText={getLocale('redirectModalError')}
buttonText={getLocale('processingRequestButton')}
titleText={getLocale('processingRequest')}
onClick={this.onRedirectError}
/>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,11 @@ const rewardsReducer: Reducer<Rewards.State | undefined> = (state: Rewards.State
break
}

if (data.result === 25) {
ui.modalRedirect = 'notAllowed'
break
}

if (data.result !== 0) {
ui.modalRedirect = 'error'
break
Expand Down
2 changes: 1 addition & 1 deletion components/definitions/rewards.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ declare namespace Rewards {
ui: {
emptyWallet: boolean
modalBackup: boolean
modalRedirect: 'show' | 'hide' | 'error'
modalRedirect: 'show' | 'hide' | 'error' | 'notAllowed'
paymentIdCheck: boolean
walletRecoverySuccess: boolean | null
walletServerProblem: boolean
Expand Down
3 changes: 3 additions & 0 deletions components/resources/brave_components_strings.grd
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@
<message name="IDS_BRAVE_REWARDS_LOCAL_ADS_CONFIRMATION_TYPE_DISMISS" desc="">Dismissed</message>
<message name="IDS_BRAVE_REWARDS_LOCAL_ADS_CONFIRMATION_TYPE_LANDED" desc="">Clicked</message>
<message name="IDS_BRAVE_REWARDS_LOCAL_ADS_CONFIRMATION_TYPE_VIEW" desc="">Viewed</message>
<message name="IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_NOT_ALLOWED" desc="">BAT is not currently supported in your region. Please refer <ph name="BEGIN_LINK_REGION_TEXT">&lt;a target="_blank" href="$1"&gt;</ph>Here<ph name="END_LINK_REGION_TEXT">&lt;/a&gt;</ph> for updates.</message>
<message name="IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_CLOSE" desc="">Close</message>
<message name="IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_ERROR_WALLET" desc="">Error creating Brave Browser BAT card</message>

<!-- WebUI rewards internals resources -->
<message name="IDS_BRAVE_REWARDS_INTERNALS_AMOUNT" desc="Amount">Amount:</message>
Expand Down

0 comments on commit dfa9f58

Please sign in to comment.