Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,42 +1,22 @@
import PropTypes from 'prop-types';
import React, {useMemo} from 'react';
import {ScrollView, View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import _ from 'underscore';
import * as Expensicons from '@components/Icon/Expensicons';
import IllustratedHeaderPageLayout from '@components/IllustratedHeaderPageLayout';
import LottieAnimations from '@components/LottieAnimations';
import MenuItemList from '@components/MenuItemList';
import withLocalize, {withLocalizePropTypes} from '@components/withLocalize';
import useLocalize from '@hooks/useLocalize';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import useWaitForNavigation from '@hooks/useWaitForNavigation';
import compose from '@libs/compose';
import Navigation from '@libs/Navigation/Navigation';
import ONYXKEYS from '@src/ONYXKEYS';
import type {TranslationPaths} from '@src/languages/types';
import ROUTES from '@src/ROUTES';
import SCREENS from '@src/SCREENS';

const propTypes = {
...withLocalizePropTypes,

/* Onyx Props */

/** Holds information about the users account that is logging in */
account: PropTypes.shape({
/** Whether this account has 2FA enabled or not */
requiresTwoFactorAuth: PropTypes.bool,
}),
};

const defaultProps = {
account: {},
};

function SecuritySettingsPage(props) {
function SecuritySettingsPage() {
const theme = useTheme();
const styles = useThemeStyles();
const {translate} = props;
const {translate} = useLocalize();
const waitForNavigate = useWaitForNavigation();

const menuItems = useMemo(() => {
Expand All @@ -53,13 +33,13 @@ function SecuritySettingsPage(props) {
},
];

return _.map(baseMenuItems, (item) => ({
return baseMenuItems.map((item) => ({
key: item.translationKey,
title: translate(item.translationKey),
title: translate(item.translationKey as TranslationPaths),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you create a follow up PR to fix this assertion?

here is a code snippet that should work @tienifr:

    const menuItems: MenuItemWithLink[] = useMemo(() => {
        const baseMenuItems = [
            {
                translationKey: 'twoFactorAuth.headerTitle',
                icon: Expensicons.Shield,
                action: waitForNavigate(() => Navigation.navigate(ROUTES.SETTINGS_2FA.getRoute())),
            },
            {
                translationKey: 'closeAccountPage.closeAccount',
                icon: Expensicons.ClosedSign,
                action: waitForNavigate(() => Navigation.navigate(ROUTES.SETTINGS_CLOSE)),
            },
        ] as const;

        return baseMenuItems.map((item) => ({
            key: item.translationKey,
            title: translate(item.translationKey),
            icon: item.icon,
            onPress: item.action,
            shouldShowRightIcon: true,
            link: '',
        }));
    }, [translate, waitForNavigate]);

icon: item.icon,
iconRight: item.iconRight,
onPress: item.action,
shouldShowRightIcon: true,
link: '',
}));
}, [translate, waitForNavigate]);

Expand All @@ -83,13 +63,6 @@ function SecuritySettingsPage(props) {
);
}

SecuritySettingsPage.propTypes = propTypes;
SecuritySettingsPage.defaultProps = defaultProps;
SecuritySettingsPage.displayName = 'SettingSecurityPage';

export default compose(
withLocalize,
withOnyx({
account: {key: ONYXKEYS.ACCOUNT},
}),
)(SecuritySettingsPage);
export default SecuritySettingsPage;