<commit_before>import classNames                     from 'classnames';
import { PropTypes as MobxPropTypes } from 'mobx-react';
import PropTypes                      from 'prop-types';
import React                          from 'react';
import { connect }                    from '../../../../Stores/connect';
import { localize }                   from '../../../../../_common/localize';
import PortfolioDrawerCard            from './portfolio_drawer_card.jsx';
import EmptyPortfolioMessage          from '../../../../Modules/Portfolio/Components/empty_portfolio_message.jsx';

class PortfolioDrawer extends React.Component {
    componentDidMount()    { this.props.onMount(); }
    componentWillUnmount() { this.props.onUnmount(); }

    render() {
        const {
            data,
            error,
            currency,
            is_empty,
            is_portfolio_drawer_on,
            toggleDrawer,
        } = this.props;

        return (
            <div className={classNames('portfolio-drawer', { 'portfolio-drawer--open': is_portfolio_drawer_on })}>
                <div className='portfolio-drawer__header'>
                    <span className='portfolio-drawer__icon-main ic-portfolio' />
                    <span className='portfolio-drawer__title'>{localize('Portfolio Quick Menu')}</span>
                    <a
                        href='javascript:;'
                        className='portfolio-drawer__icon-close'
                        onClick={toggleDrawer}
                    />
                </div>
                <div className='portfolio-drawer__body'>
                    {
                        error ?
                            <p>{error}</p>
                            :
                            is_empty ?
                                <EmptyPortfolioMessage />
                                :
                                data.map((portfolio_position, id) => (
                                    <PortfolioDrawerCard
                                        key={id}
                                        currency={currency}
                                        {...portfolio_position}
                                    />
                                ))
                    }
                </div>
            </div>
        );
    }
};

PortfolioDrawer.propTypes = {<commit_msg>refactor nested ternary<commit_after>import classNames                     from 'classnames';
import { PropTypes as MobxPropTypes } from 'mobx-react';
import PropTypes                      from 'prop-types';
import React                          from 'react';
import { connect }                    from '../../../../Stores/connect';
import { localize }                   from '../../../../../_common/localize';
import PortfolioDrawerCard            from './portfolio_drawer_card.jsx';
import EmptyPortfolioMessage          from '../../../../Modules/Portfolio/Components/empty_portfolio_message.jsx';

class PortfolioDrawer extends React.Component {
    componentDidMount()    { this.props.onMount(); }
    componentWillUnmount() { this.props.onUnmount(); }

    render() {
        const {
            data,
            error,
            currency,
            is_empty,
            is_portfolio_drawer_on,
            toggleDrawer,
        } = this.props;

        let body_content;

        if (error) {
            body_content = <p>{error}</p>;
        }
        else if (is_empty) {
            body_content = <EmptyPortfolioMessage />;
        }
        else {
            body_content = data.map((portfolio_position, id) => (
                <PortfolioDrawerCard
                    key={id}
                    currency={currency}
                    {...portfolio_position}
                />
            ));
        }

        return (
            <div className={classNames('portfolio-drawer', { 'portfolio-drawer--open': is_portfolio_drawer_on })}>
                <div className='portfolio-drawer__header'>
                    <span className='portfolio-drawer__icon-main ic-portfolio' />
                    <span className='portfolio-drawer__title'>{localize('Portfolio Quick Menu')}</span>
                    <a
                        href='javascript:;'
                        className='portfolio-drawer__icon-close'
                        onClick={toggleDrawer}
                    />
                </div>
                <div className='portfolio-drawer__body'>
                    {body_content}
                </div>
            </div>
        );
    }
};

PortfolioDrawer.propTypes = {
{'fraction_non_alphanumeric': 0.11057587037442522, 'fraction_numerical': 0.0, 'mean_word_length': 1.189837008628955, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5110424', 'n_tokens_mistral': 1116, 'n_tokens_neox': 1073, 'n_words': 182}