-
Notifications
You must be signed in to change notification settings - Fork 910
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(wallet): Backed Up Transactions Warning
- Loading branch information
1 parent
d03c7da
commit 208fc96
Showing
11 changed files
with
343 additions
and
22 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
102 changes: 102 additions & 0 deletions
102
components/brave_wallet_ui/components/extension/transactions-backed-up-warning/index.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,102 @@ | ||
import * as React from 'react' | ||
|
||
// Components | ||
import { NavButton } from '../' | ||
import { Checkbox } from 'brave-ui' | ||
import { getLocale } from '../../../../common/locale' | ||
|
||
// Styled Components | ||
import { | ||
StyledWrapper, | ||
Title, | ||
Description, | ||
LearnMoreButton, | ||
CheckboxRow, | ||
ClearButton, | ||
ClearButtonText, | ||
LoadIcon, | ||
CheckboxText | ||
} from './style' | ||
|
||
export interface Props { | ||
onContinue: (clearTransactions: boolean) => void | ||
duplicateNonceTranscations: boolean | ||
} | ||
|
||
function TransactionsBackedUpWarning (props: Props) { | ||
const { onContinue, duplicateNonceTranscations } = props | ||
const [clearTransactions, setClearTransactions] = React.useState<boolean>(false) | ||
const [isClearing, setIsClearing] = React.useState<boolean>(false) | ||
|
||
const onCheckClearTransactions = (key: string, selected: boolean) => { | ||
if (key === 'clearTransactions') { | ||
setClearTransactions(selected) | ||
} | ||
} | ||
|
||
const onClickContinue = () => { | ||
if (clearTransactions) { | ||
setIsClearing(true) | ||
} | ||
onContinue(clearTransactions) | ||
} | ||
|
||
const onClickLearnMore = () => { | ||
chrome.tabs.create({ url: 'https://support.brave.com/hc/en-us/articles/4537540021389' }, () => { | ||
if (chrome.runtime.lastError) { | ||
console.error('tabs.create failed: ' + chrome.runtime.lastError.message) | ||
} | ||
}) | ||
} | ||
|
||
return ( | ||
<StyledWrapper> | ||
<Title>{getLocale('braveWalletBackedUpTransactionsTitle')}</Title> | ||
<Description>{getLocale('braveWalletBackedUpTransactionsDescription')}</Description> | ||
<LearnMoreButton | ||
needsMargin={duplicateNonceTranscations} | ||
onClick={onClickLearnMore} | ||
> | ||
{getLocale('braveWalletWelcomePanelButton')} | ||
</LearnMoreButton> | ||
{!duplicateNonceTranscations && | ||
<CheckboxRow> | ||
<Checkbox | ||
children={<CheckboxText data-key='clearTransactions'>{getLocale('braveWalletBackedUpTransactionsCheckbox')}</CheckboxText>} | ||
size='small' | ||
value={{ clearTransactions: clearTransactions }} | ||
onChange={onCheckClearTransactions} | ||
/> | ||
</CheckboxRow> | ||
} | ||
{isClearing ? ( | ||
<ClearButton> | ||
<ClearButtonText> | ||
{getLocale('braveWalletBackedUpTransactionsClearingButton')} | ||
</ClearButtonText> | ||
<LoadIcon /> | ||
</ClearButton> | ||
) : ( | ||
<NavButton | ||
disabled={isClearing} | ||
buttonType={ | ||
clearTransactions | ||
? 'danger' | ||
: 'primary' | ||
} | ||
text={ | ||
duplicateNonceTranscations | ||
? getLocale('braveWalletBackedUpTransactionsOKButton') | ||
: clearTransactions | ||
? getLocale('braveWalletBackedUpTransactionsClearButton') | ||
: getLocale('braveWalletButtonContinue') | ||
} | ||
onSubmit={onClickContinue} | ||
/> | ||
) | ||
} | ||
</StyledWrapper > | ||
) | ||
} | ||
|
||
export default TransactionsBackedUpWarning |
Oops, something went wrong.