mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
1304ec7af5
We want to convert NetworkController to TypeScript in order to be able to compare differences in the controller between in this repo and the core repo. To do this, however, we need to convert the dependencies of the controller to TypeScript. As a part of this effort, this commit converts `shared/constants/metametrics` to TypeScript. Note that simple objects have been largely replaced with enums. There are some cases where I even split up some of these objects into multiple enums. Co-authored-by: Mark Stacey <markjstacey@gmail.com>
210 lines
6.4 KiB
JavaScript
210 lines
6.4 KiB
JavaScript
import React, { useState, useContext } from 'react';
|
|
import { useHistory, useLocation } from 'react-router-dom';
|
|
import { useSelector } from 'react-redux';
|
|
import Box from '../../../components/ui/box';
|
|
import Button from '../../../components/ui/button';
|
|
import Typography from '../../../components/ui/typography';
|
|
import {
|
|
TEXT_ALIGN,
|
|
TypographyVariant,
|
|
JustifyContent,
|
|
FONT_WEIGHT,
|
|
DISPLAY,
|
|
} from '../../../helpers/constants/design-system';
|
|
import {
|
|
ThreeStepProgressBar,
|
|
threeStepStages,
|
|
} from '../../../components/app/step-progress-bar';
|
|
import { useI18nContext } from '../../../hooks/useI18nContext';
|
|
import { MetaMetricsContext } from '../../../contexts/metametrics';
|
|
import { ONBOARDING_REVIEW_SRP_ROUTE } from '../../../helpers/constants/routes';
|
|
import { getCurrentLocale } from '../../../ducks/locale/locale';
|
|
import {
|
|
MetaMetricsEventCategory,
|
|
MetaMetricsEventName,
|
|
} from '../../../../shared/constants/metametrics';
|
|
import SkipSRPBackup from './skip-srp-backup-popover';
|
|
|
|
export default function SecureYourWallet() {
|
|
const history = useHistory();
|
|
const t = useI18nContext();
|
|
const { search } = useLocation();
|
|
const currentLocale = useSelector(getCurrentLocale);
|
|
const [showSkipSRPBackupPopover, setShowSkipSRPBackupPopover] =
|
|
useState(false);
|
|
const searchParams = new URLSearchParams(search);
|
|
const isFromReminderParam = searchParams.get('isFromReminder')
|
|
? '/?isFromReminder=true'
|
|
: '';
|
|
|
|
const trackEvent = useContext(MetaMetricsContext);
|
|
|
|
const handleClickRecommended = () => {
|
|
trackEvent({
|
|
category: MetaMetricsEventCategory.Onboarding,
|
|
event: MetaMetricsEventName.OnboardingWalletSecurityStarted,
|
|
});
|
|
history.push(`${ONBOARDING_REVIEW_SRP_ROUTE}${isFromReminderParam}`);
|
|
};
|
|
|
|
const handleClickNotRecommended = () => {
|
|
trackEvent({
|
|
category: MetaMetricsEventCategory.Onboarding,
|
|
event: MetaMetricsEventName.OnboardingWalletSecuritySkipInitiated,
|
|
});
|
|
setShowSkipSRPBackupPopover(true);
|
|
};
|
|
|
|
const subtitles = {
|
|
en: 'English',
|
|
es: 'Spanish',
|
|
hi: 'Hindi',
|
|
id: 'Indonesian',
|
|
ja: 'Japanese',
|
|
ko: 'Korean',
|
|
pt: 'Portuguese',
|
|
ru: 'Russian',
|
|
tl: 'Tagalog',
|
|
vi: 'Vietnamese',
|
|
de: 'German',
|
|
el: 'Greek',
|
|
fr: 'French',
|
|
tr: 'Turkish',
|
|
zh: 'Chinese - China',
|
|
};
|
|
|
|
const defaultLang = subtitles[currentLocale] ? currentLocale : 'en';
|
|
return (
|
|
<div className="secure-your-wallet" data-testid="secure-your-wallet">
|
|
{showSkipSRPBackupPopover && (
|
|
<SkipSRPBackup handleClose={() => setShowSkipSRPBackupPopover(false)} />
|
|
)}
|
|
<ThreeStepProgressBar
|
|
stage={threeStepStages.RECOVERY_PHRASE_VIDEO}
|
|
marginBottom={4}
|
|
/>
|
|
<Box
|
|
justifyContent={JustifyContent.center}
|
|
textAlign={TEXT_ALIGN.CENTER}
|
|
marginBottom={4}
|
|
>
|
|
<Typography
|
|
variant={TypographyVariant.H2}
|
|
fontWeight={FONT_WEIGHT.BOLD}
|
|
>
|
|
{t('seedPhraseIntroTitle')}
|
|
</Typography>
|
|
</Box>
|
|
<Box justifyContent={JustifyContent.center} marginBottom={6}>
|
|
<Typography
|
|
variant={TypographyVariant.H4}
|
|
className="secure-your-wallet__details"
|
|
>
|
|
{t('seedPhraseIntroTitleCopy')}
|
|
</Typography>
|
|
</Box>
|
|
<Box>
|
|
<video
|
|
className="secure-your-wallet__video"
|
|
onPlay={() => {
|
|
trackEvent({
|
|
category: MetaMetricsEventCategory.Onboarding,
|
|
event: MetaMetricsEventName.OnboardingWalletVideoPlay,
|
|
});
|
|
}}
|
|
controls
|
|
>
|
|
<source
|
|
type="video/webm"
|
|
src="./images/videos/recovery-onboarding/video.webm"
|
|
/>
|
|
{Object.keys(subtitles).map((key) => {
|
|
return (
|
|
<track
|
|
default={Boolean(key === defaultLang)}
|
|
srcLang={key}
|
|
label={subtitles[key]}
|
|
key={`${key}-subtitles`}
|
|
kind="subtitles"
|
|
src={`./images/videos/recovery-onboarding/subtitles/${key}.vtt`}
|
|
/>
|
|
);
|
|
})}
|
|
</video>
|
|
</Box>
|
|
<Box
|
|
margin={8}
|
|
justifyContent={JustifyContent.spaceBetween}
|
|
className="secure-your-wallet__actions"
|
|
>
|
|
<Button
|
|
data-testid="secure-wallet-later"
|
|
type="secondary"
|
|
rounded
|
|
large
|
|
onClick={handleClickNotRecommended}
|
|
>
|
|
{t('seedPhraseIntroNotRecommendedButtonCopy')}
|
|
</Button>
|
|
<Button
|
|
data-testid="secure-wallet-recommended"
|
|
type="primary"
|
|
rounded
|
|
large
|
|
onClick={handleClickRecommended}
|
|
>
|
|
{t('seedPhraseIntroRecommendedButtonCopy')}
|
|
</Button>
|
|
</Box>
|
|
<Box className="secure-your-wallet__desc">
|
|
<Box marginBottom={4}>
|
|
<Typography
|
|
as="p"
|
|
variant={TypographyVariant.H4}
|
|
fontWeight={FONT_WEIGHT.BOLD}
|
|
boxProps={{ display: DISPLAY.BLOCK }}
|
|
>
|
|
{t('seedPhraseIntroSidebarTitleOne')}
|
|
</Typography>
|
|
<Typography as="p" variant={TypographyVariant.H4}>
|
|
{t('seedPhraseIntroSidebarCopyOne')}
|
|
</Typography>
|
|
</Box>
|
|
<Box marginBottom={4}>
|
|
<Typography
|
|
as="p"
|
|
variant={TypographyVariant.H4}
|
|
fontWeight={FONT_WEIGHT.BOLD}
|
|
boxProps={{ display: DISPLAY.BLOCK }}
|
|
>
|
|
{t('seedPhraseIntroSidebarTitleTwo')}
|
|
</Typography>
|
|
<ul className="secure-your-wallet__list">
|
|
<li>{t('seedPhraseIntroSidebarBulletOne')}</li>
|
|
<li>{t('seedPhraseIntroSidebarBulletThree')}</li>
|
|
<li>{t('seedPhraseIntroSidebarBulletFour')}</li>
|
|
</ul>
|
|
</Box>
|
|
<Box marginBottom={6}>
|
|
<Typography
|
|
as="p"
|
|
variant={TypographyVariant.H4}
|
|
fontWeight={FONT_WEIGHT.BOLD}
|
|
boxProps={{ display: DISPLAY.BLOCK }}
|
|
>
|
|
{t('seedPhraseIntroSidebarTitleThree')}
|
|
</Typography>
|
|
<Typography as="p" variant={TypographyVariant.H4}>
|
|
{t('seedPhraseIntroSidebarCopyTwo')}
|
|
</Typography>
|
|
</Box>
|
|
<Box className="secure-your-wallet__highlighted" marginBottom={2}>
|
|
<Typography as="p" variant={TypographyVariant.H4}>
|
|
{t('seedPhraseIntroSidebarCopyThree')}
|
|
</Typography>
|
|
</Box>
|
|
</Box>
|
|
</div>
|
|
);
|
|
}
|