<commit_before>import React               from 'react';
import {
    Redirect,
    Route }                from 'react-router-dom';
import { redirectToLogin } from '_common/base/login';
import BinarySocket        from '_common/base/socket_base';
import routes              from 'Constants/routes';
import GTM                 from 'Utils/gtm';
import LoginPrompt         from '../Elements/login-prompt.jsx';
import { default_title }   from '../../Constants/app-config';

const RouteWithSubRoutes = route => {
    const renderFactory = props => {
        let result = null;
        if (route.component === Redirect) {
            let to = route.to;

            // This if clause has been added just to remove '/index' from url in localhost env.
            if (route.path === routes.index) {
                const { location } = props;
                to = location.pathname.toLowerCase().replace(route.path, '');
            }
            result = <Redirect to={to} />;
        } else {
            result = (
                (route.is_authenticated && !route.is_logged_in) ?
                    <LoginPrompt onLogin={redirectToLogin} page_title={route.title} />
                    :
                    <route.component {...props} routes={route.routes} />
            );
        }

        const title = route.title ? `${route.title} | ` : '';
        document.title = `${ title }${ default_title }`;
        BinarySocket.wait('website_status').then(() => {
            GTM.pushDataLayer({ event: 'page_load' });
        });
        return result;
    };

    return <Route
        exact={route.exact}
        path={route.path}
        render={renderFactory}
    />;
};

export default RouteWithSubRoutes;<commit_msg>call setCookie after loading new app<commit_after>import React               from 'react';
import {
    Redirect,
    Route }                from 'react-router-dom';
import { redirectToLogin } from '_common/base/login';
import BinarySocket        from '_common/base/socket_base';
import Language            from '_common/language';
import routes              from 'Constants/routes';
import GTM                 from 'Utils/gtm';
import LoginPrompt         from '../Elements/login-prompt.jsx';
import { default_title }   from '../../Constants/app-config';

const RouteWithSubRoutes = route => {
    const renderFactory = props => {
        let result = null;
        if (route.component === Redirect) {
            let to = route.to;

            // This if clause has been added just to remove '/index' from url in localhost env.
            if (route.path === routes.index) {
                const { location } = props;
                to = location.pathname.toLowerCase().replace(route.path, '');
            }
            result = <Redirect to={to} />;
        } else {
            result = (
                (route.is_authenticated && !route.is_logged_in) ?
                    <LoginPrompt onLogin={redirectToLogin} page_title={route.title} />
                    :
                    <route.component {...props} routes={route.routes} />
            );
        }

        Language.setCookie();
        const title = route.title ? `${route.title} | ` : '';
        document.title = `${ title }${ default_title }`;
        BinarySocket.wait('website_status').then(() => {
            GTM.pushDataLayer({ event: 'page_load' });
        });
        return result;
    };

    return <Route
        exact={route.exact}
        path={route.path}
        render={renderFactory}
    />;
};

export default RouteWithSubRoutes;
{'fraction_non_alphanumeric': 0.1293419937870658, 'fraction_numerical': 0.0, 'mean_word_length': 1.797788309636651, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, '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': '7321764', 'n_tokens_mistral': 952, 'n_tokens_neox': 928, 'n_words': 219}