<commit_before>/**
 * Created by Andy on 19-Apr-17.
 */
import React, {Component} from 'react';
import ReactDOM from 'react-dom';
import {Provider, connect} from "react-redux";

import {fetchAllProHostingActivities} from '../actions/activitiesActions';
import ActivityCardHomePage from '../components/ActivityCardHomePage';
import configureStore from "../configureStore";
import { withoutTime } from "../DateFunctions";

import '../../styles/activityBox.css';

const store = configureStore();

import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import getMuiTheme from 'material-ui/styles/getMuiTheme';
// import Provider from "react-redux/src/components/Provider";

class ProviderHostingContainer extends Component {

    createActivityCardComponent = () => {
        return this.props.proHostingActivities.map(activity => {
            return (
                <ActivityCardHomePage
                    key={activity.id + activity.fields.activityName}
                    id={activity.pk}
                    activity={activity.fields}
                />
            )
        });
    };

    render() {
        const styles = {
            activitiesContainerStyle: {
                padding: "1em"
            },
            activitiesStyle: {
                display: "flex",
                flexWrap: "wrap",
                flexDirection: "row",
                justifyContent: "flex-start",
                padding: "0.5em"
            },
        };

        let proHostingContainer = <p>Vi har desverre ingen kommende aktiviteter for øyeblikket</p>;
        if (this.props.proHostingActivities.length > 0) {
            proHostingContainer =
                <div style={styles.activitiesStyle}>
                    {this.createActivityCardComponent()}
                </div>
        }

        return (
            <div style={styles.activitiesContainerStyle}>
                {proHostingContainer}
            </div>
        );
    }
}

const mapStateToProps = state => {
    return {
        proHostingActivities: state.activity.proHostingList
            .sort((a, b) => withoutTime(new Date(a.fields.date)) > withoutTime(new Date(b.fields.date)))
    };
};

const mapDispatchToProps = dispatch => {
    return {
        fetchProHostingActivities: () => dispatch(fetchAllProHostingActivities()),
    }
};

const muiTheme = getMuiTheme({
    palette: {
        primary1Color: '#3F51B5',
    },
});

// Fetch initial data for state
store.dispatch(fetchAllProHostingActivities());

ProviderHostingContainer = connect(mapStateToProps, mapDispatchToProps)(ProviderHostingContainer);

ReactDOM.render(
    <MuiThemeProvider muiTheme={muiTheme}>
        <Provider store={store}>
            <ProviderHostingContainer />
        </Provider>
    </MuiThemeProvider>, document.getElementById('proHostingActivities')
);


<commit_msg>cleaned providerhostingcontainer<commit_after>import React, {Component} from 'react';
import ReactDOM from 'react-dom';
import {Provider, connect} from "react-redux";
import {fetchAllProHostingActivities} from '../actions/activitiesActions';
import ActivityCardHomePage from '../components/ActivityCardHomePage';
import configureStore from "../configureStore";
import {withoutTime} from "../DateFunctions";
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import getMuiTheme from 'material-ui/styles/getMuiTheme';
import '../../styles/activityBox.css';

const store = configureStore();

class ProviderHostingContainer extends Component {

    createActivityCardComponent = () => {
        return this.props.proHostingActivities.map(activity => {
            return (
                <ActivityCardHomePage
                    key={activity.id + activity.fields.activityName}
                    id={activity.pk}
                    activity={activity.fields}
                />
            )
        });
    };

    render() {
        const styles = {
            activitiesContainerStyle: {
                padding: "1em"
            },
            activitiesStyle: {
                display: "flex",
                flexWrap: "wrap",
                flexDirection: "row",
                justifyContent: "flex-start",
                padding: "0.5em"
            },
        };

        let proHostingContainer = <p>Vi har desverre ingen kommende aktiviteter for øyeblikket</p>;
        if (this.props.proHostingActivities.length > 0) {
            proHostingContainer =
                <div style={styles.activitiesStyle}>
                    {this.createActivityCardComponent()}
                </div>
        }

        return (
            <div style={styles.activitiesContainerStyle}>
                {proHostingContainer}
            </div>
        );
    }
}

const mapStateToProps = state => {
    return {
        proHostingActivities: state.activity.proHostingList
            .sort((a, b) => withoutTime(new Date(a.fields.date)) > withoutTime(new Date(b.fields.date)))
    };
};

const mapDispatchToProps = dispatch => {
    return {
        fetchProHostingActivities: () => dispatch(fetchAllProHostingActivities()),
    }
};

const muiTheme = getMuiTheme({
    palette: {
        primary1Color: '#3F51B5',
    },
});

// Fetch initial data for state
store.dispatch(fetchAllProHostingActivities());

ProviderHostingContainer = connect(mapStateToProps, mapDispatchToProps)(ProviderHostingContainer);

ReactDOM.render(
    <MuiThemeProvider muiTheme={muiTheme}>
        <Provider store={store}>
            <ProviderHostingContainer />
        </Provider>
    </MuiThemeProvider>, document.getElementById('proHostingActivities')
);



{'fraction_non_alphanumeric': 0.11400071250445315, 'fraction_numerical': 0.003918774492340577, 'mean_word_length': 2.356246264196055, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 43, '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': '5928968', 'n_tokens_mistral': 1522, 'n_tokens_neox': 1480, 'n_words': 287}