<commit_before>import * as React from 'react';
import {
    UsernameSection,
    PasswordsSection,
    NewsSection,
    DeleteSection,
    RecoveryMethodsSection,
    TwoFactorSection,
    SettingsPropsShared,
} from 'react-components';
import { c } from 'ttag';
import { UserModel } from 'proton-shared/lib/interfaces';
import { PERMISSIONS } from 'proton-shared/lib/constants';

import PrivateMainSettingsAreaWithPermissions from '../components/PrivateMainSettingsAreaWithPermissions';

const { UPGRADER } = PERMISSIONS;

export const getAccountPage = (user: UserModel) => {
    return {
        text: c('Title').t`Account`,
        to: '/account',
        icon: 'account',
        subsections: [
            {
                text: user.Name ? c('Title').t`Username` : c('Title').t`Address`,
                id: 'username',
            },
            {
                text: c('Title').t`Passwords`,
                id: 'passwords',
            },
            {
                text: c('Title').t`Two factor authentication`,
                id: 'two-fa',
            },
            {
                text: c('Title').t`Recovery & notification`,
                id: 'email',
            },
            {
                text: c('Title').t`Email subscriptions`,
                id: 'news',
                permissions: [UPGRADER],
            },
            {
                text: c('Title').t`Delete account`,
                id: 'delete',
                permissions: [UPGRADER],
            },
        ],
    };
};

interface Props extends SettingsPropsShared {
    user: UserModel;
}

const AccountContainer = ({ location, setActiveSection, user }: Props) => {
    return (
        <PrivateMainSettingsAreaWithPermissions
            location={location}
            config={getAccountPage(user)}
            setActiveSection={setActiveSection}
        >
            <UsernameSection />
            <PasswordsSection />
            <TwoFactorSection />
            <RecoveryMethodsSection />
            <NewsSection />
            <DeleteSection />
        </PrivateMainSettingsAreaWithPermissions>
    );
};

export default AccountContainer;
<commit_msg>[CP-790] Add conditions in sidebar<commit_after>import * as React from 'react';
import {
    UsernameSection,
    PasswordsSection,
    NewsSection,
    DeleteSection,
    RecoveryMethodsSection,
    TwoFactorSection,
    SettingsPropsShared,
} from 'react-components';
import { c } from 'ttag';
import { UserModel } from 'proton-shared/lib/interfaces';
import isTruthy from 'proton-shared/lib/helpers/isTruthy';

import PrivateMainSettingsAreaWithPermissions from '../components/PrivateMainSettingsAreaWithPermissions';

export const getAccountPage = (user: UserModel) => {
    return {
        text: c('Title').t`Account`,
        to: '/account',
        icon: 'account',
        subsections: [
            {
                text: user.Name ? c('Title').t`Username` : c('Title').t`Address`,
                id: 'username',
            },
            {
                text: c('Title').t`Passwords`,
                id: 'passwords',
            },
            {
                text: c('Title').t`Two factor authentication`,
                id: 'two-fa',
            },
            {
                text: c('Title').t`Recovery & notification`,
                id: 'email',
            },
            user.canPay && {
                text: c('Title').t`Email subscriptions`,
                id: 'news',
            },
            user.canPay && {
                text: c('Title').t`Delete account`,
                id: 'delete',
            },
        ].filter(isTruthy),
    };
};

interface Props extends SettingsPropsShared {
    user: UserModel;
}

const AccountContainer = ({ location, setActiveSection, user }: Props) => {
    return (
        <PrivateMainSettingsAreaWithPermissions
            location={location}
            config={getAccountPage(user)}
            setActiveSection={setActiveSection}
        >
            <UsernameSection />
            <PasswordsSection />
            <TwoFactorSection />
            <RecoveryMethodsSection />
            <NewsSection />
            <DeleteSection />
        </PrivateMainSettingsAreaWithPermissions>
    );
};

export default AccountContainer;

{'fraction_non_alphanumeric': 0.12005616662766207, 'fraction_numerical': 0.0007020828457758015, 'mean_word_length': 1.7807417046193885, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2650918', 'n_tokens_mistral': 1120, 'n_tokens_neox': 1100, 'n_words': 218}