1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 10:30:04 +01:00
metamask-extension/ui/pages/onboarding-flow/privacy-settings/privacy-settings.js
Alex Donesky f733857388
Onboarding V2 Cleanups (#12417)
* remove the onboarding V2 feature flags used for dev, some remain until we're ready to make the switch

* update route

* add setCompletedOnboarding dispatch to submission on privacy-settings view

* update privacy-settings test
2021-10-20 13:55:59 -05:00

116 lines
3.7 KiB
JavaScript

import React, { useState } from 'react';
import { useHistory } from 'react-router-dom';
import { useDispatch } from 'react-redux';
import Button from '../../../components/ui/button';
import Typography from '../../../components/ui/typography';
import {
FONT_WEIGHT,
TYPOGRAPHY,
} from '../../../helpers/constants/design-system';
import { useI18nContext } from '../../../hooks/useI18nContext';
import {
setCompletedOnboarding,
setFeatureFlag,
setUsePhishDetect,
setUseTokenDetection,
} from '../../../store/actions';
import { ONBOARDING_PIN_EXTENSION_ROUTE } from '../../../helpers/constants/routes';
import { Setting } from './setting';
export default function PrivacySettings() {
const t = useI18nContext();
const dispatch = useDispatch();
const history = useHistory();
const [usePhishingDetection, setUsePhishingDetection] = useState(true);
const [turnOnTokenDetection, setTurnOnTokenDetection] = useState(true);
const [showIncomingTransactions, setShowIncomingTransactions] = useState(
true,
);
const handleSubmit = () => {
dispatch(
setFeatureFlag('showIncomingTransactions', showIncomingTransactions),
);
dispatch(setUsePhishDetect(usePhishingDetection));
dispatch(setUseTokenDetection(turnOnTokenDetection));
dispatch(setCompletedOnboarding());
history.push(ONBOARDING_PIN_EXTENSION_ROUTE);
};
return (
<>
<div className="privacy-settings">
<div className="privacy-settings__header">
<Typography variant={TYPOGRAPHY.H2} fontWeight={FONT_WEIGHT.BOLD}>
{t('setAdvancedPrivacySettings')}
</Typography>
<Typography variant={TYPOGRAPHY.H4}>
{t('setAdvancedPrivacySettingsDetails')}
</Typography>
</div>
<div
className="privacy-settings__settings"
data-testid="privacy-settings-settings"
>
<Setting
value={showIncomingTransactions}
setValue={setShowIncomingTransactions}
title={t('showIncomingTransactions')}
description={t('onboardingShowIncomingTransactionsDescription', [
<a
key="etherscan"
href="https://etherscan.io/"
target="_blank"
rel="noreferrer"
>
{t('etherscan')}
</a>,
<a
href="https://cn.etherscan.com/privacyPolicy"
target="_blank"
rel="noreferrer"
key="privacyMsg"
>
{t('privacyMsg')}
</a>,
])}
/>
<Setting
value={usePhishingDetection}
setValue={setUsePhishingDetection}
title={t('usePhishingDetection')}
description={t('onboardingUsePhishingDetectionDescription', [
<a
href="https://www.jsdelivr.com"
target="_blank"
rel="noreferrer"
key="jsDeliver"
>
{t('jsDeliver')}
</a>,
<a
href="https://www.jsdelivr.com/terms/privacy-policy-jsdelivr-com"
target="_blank"
rel="noreferrer"
key="privacyMsg"
>
{t('privacyMsg')}
</a>,
])}
/>
<Setting
value={turnOnTokenDetection}
setValue={setTurnOnTokenDetection}
title={t('turnOnTokenDetection')}
description={t('useTokenDetectionDescription')}
/>
</div>
<Button type="primary" rounded onClick={handleSubmit}>
{t('done')}
</Button>
</div>
</>
);
}