-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
191 additions
and
158 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
123 changes: 0 additions & 123 deletions
123
apps/desktop-wallet/src/components/Inputs/WalletPassphrase.tsx
This file was deleted.
Oops, something went wrong.
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
81 changes: 81 additions & 0 deletions
81
apps/desktop-wallet/src/features/passphrase/WalletPassphraseDisclaimerModal.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,81 @@ | ||
import { t } from 'i18next' | ||
import { memo, useState } from 'react' | ||
import { Trans } from 'react-i18next' | ||
import styled from 'styled-components' | ||
|
||
import ActionLink from '@/components/ActionLink' | ||
import FooterButton from '@/components/Buttons/FooterButton' | ||
import InfoBox from '@/components/InfoBox' | ||
import { closeModal } from '@/features/modals/modalActions' | ||
import { ModalBaseProp } from '@/features/modals/modalTypes' | ||
import { useAppDispatch } from '@/hooks/redux' | ||
import CenteredModal from '@/modals/CenteredModal' | ||
import { links } from '@/utils/links' | ||
import { openInWebBrowser } from '@/utils/misc' | ||
|
||
export interface WalletPassphraseDisclaimerModalProps { | ||
onConsentChange: (consent: boolean) => void | ||
} | ||
|
||
const WalletPassphraseDisclaimerModal = memo( | ||
({ id, onConsentChange }: WalletPassphraseDisclaimerModalProps & ModalBaseProp) => { | ||
const dispatch = useAppDispatch() | ||
const [isConsentActive, setIsConsentActive] = useState(false) | ||
|
||
const handleClose = () => { | ||
onConsentChange(isConsentActive) | ||
dispatch(closeModal({ id })) | ||
} | ||
|
||
return ( | ||
<CenteredModal id={id} title={t('Passphrase warning')} dynamicContent> | ||
<InfoBox importance="alert"> | ||
<p> | ||
<Trans t={t} i18nKey="passphraseWarningMessage"> | ||
<WarningEmphasis>This is an advanced feature!</WarningEmphasis> | ||
<br /> | ||
Use it only if you know what you are doing. | ||
<br /> | ||
Please, read our <ActionLink onClick={() => openInWebBrowser(links.passphrase)}>documentation</ActionLink> | ||
to learn about it. | ||
</Trans> | ||
</p> | ||
</InfoBox> | ||
<ConsentCheckbox> | ||
<input | ||
type="checkbox" | ||
id="passphrase-consent" | ||
checked={isConsentActive} | ||
onChange={() => setIsConsentActive(!isConsentActive)} | ||
/> | ||
<label htmlFor="passphrase-consent">{t('I have read and understood the documentation')}</label> | ||
</ConsentCheckbox> | ||
|
||
<FooterButton disabled={!isConsentActive} onClick={handleClose} role="primary" tall> | ||
{t('Continue')} | ||
</FooterButton> | ||
</CenteredModal> | ||
) | ||
} | ||
) | ||
|
||
export default WalletPassphraseDisclaimerModal | ||
|
||
const WarningEmphasis = styled.strong` | ||
color: ${({ theme }) => theme.global.alert}; | ||
` | ||
|
||
const CenteredContent = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
` | ||
|
||
const ConsentCheckbox = styled.div` | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
gap: 5px; | ||
margin-bottom: 16px; | ||
text-align: left; | ||
` |
61 changes: 61 additions & 0 deletions
61
apps/desktop-wallet/src/features/passphrase/WalletPassphraseForm.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,61 @@ | ||
import { useEffect, useState } from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
import styled from 'styled-components' | ||
|
||
import Input from '@/components/Inputs/Input' | ||
|
||
interface WalletPassphraseFormProps { | ||
onPassphraseConfirmed: (passphrase: string) => void | ||
className?: string | ||
} | ||
|
||
const WalletPassphraseForm = ({ onPassphraseConfirmed, className }: WalletPassphraseFormProps) => { | ||
const { t } = useTranslation() | ||
const [value, setValue] = useState('') | ||
const [confirmValue, setConfirmValue] = useState('') | ||
|
||
const passphraseIsNotUsed = !value && !confirmValue | ||
const showConfirmError = confirmValue.length >= value.length && value !== confirmValue | ||
|
||
useEffect(() => { | ||
const isPassphraseConfirmed = value === confirmValue || passphraseIsNotUsed | ||
onPassphraseConfirmed(isPassphraseConfirmed ? confirmValue : '') | ||
}, [onPassphraseConfirmed, confirmValue, value, passphraseIsNotUsed]) | ||
|
||
useEffect(() => { | ||
if (!value && !!confirmValue) setConfirmValue('') | ||
}, [confirmValue, value]) | ||
|
||
return ( | ||
<Container className={className}> | ||
<Input | ||
id="optional-passphrase" | ||
value={value} | ||
label={t('Optional passphrase')} | ||
type="password" | ||
onChange={(e) => setValue(e.target.value)} | ||
heightSize="big" | ||
/> | ||
<Input | ||
id="optional-passphrase-confirm" | ||
value={confirmValue} | ||
label={t('Confirm passphrase')} | ||
type="password" | ||
onChange={(e) => setConfirmValue(e.target.value)} | ||
error={showConfirmError && t("Passphrases don't match")} | ||
heightSize="big" | ||
/> | ||
</Container> | ||
) | ||
} | ||
|
||
export default WalletPassphraseForm | ||
|
||
const Container = styled.div` | ||
width: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
margin-top: 10px; | ||
padding-top: 10px; | ||
border-top: 1px solid ${({ theme }) => theme.border.primary}; | ||
` |
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
Oops, something went wrong.