<commit_before>// @flow weak
import React, {Component} from 'react';
import {connect} from 'react-redux';
import {fetchTrainings, startTraining} from "../actions/TrainingActions";
import type {Training, Trainings} from "../types/index";
import {Button, ListGroup, ListGroupItem} from "react-bootstrap";
import _ from 'lodash';

class TrainingList extends Component {

    componentWillMount() {
        this.props.fetchTrainings();
    }

    renderTrainings(trainings: Trainings) {
        const buttonStyle = {
            margin: 5
        };
        return _.map(trainings, training => {
            return <ListGroupItem header={training.name} key={training.id}>
                <Button onClick={event => this.startTraining(event, training)}
                            style={buttonStyle} bsStyle="primary">Start...
                    </Button>
            </ListGroupItem>
        })
    }

    render() {
        return (<div>
            <ListGroup>
                {this.renderTrainings(this.props.trainings)}
            </ListGroup>
        </div>)
    }

    startTraining(event, training: Training) {
        if (event) {
            event.preventDefault();
        }
    }
}

function mapStateToProps(state) {
    console.log('state = ', state);
    return {
        trainings: state.training.trainings
    }
}

export default connect(mapStateToProps, {fetchTrainings, startTraining: startTraining})(TrainingList);<commit_msg>Wieder Rückgängig: TrainingList zeigt jetzt wieder die Pläne an<commit_after>// @flow weak
import React, {Component} from 'react';
import {connect} from 'react-redux';
import {fetchPlans} from "../actions/PlanActions";
import {startTraining} from "../actions/TrainingActions";
import type {Plan, PlanState} from "../types/index";
import {Button, ListGroup, ListGroupItem} from "react-bootstrap";
import _ from 'lodash';

class TrainingList extends Component {

    componentWillMount() {
        this.props.fetchPlans();
    }

    renderPlans(plans: PlanState) {
        const buttonStyle = {
            margin: 5
        };
        return _.map(plans, plan => {
            return <ListGroupItem header={plan.name} key={plan.id}>
                <Button onClick={event => this.startTraining(event, plan)}
                        style={buttonStyle} bsStyle="primary">Start...
                </Button>
            </ListGroupItem>
        })
    }

    render() {
        return (<div>
            <ListGroup>
                {this.renderPlans(this.props.plans)}
            </ListGroup>
        </div>)
    }

    startTraining(event, plan: Plan) {
        if (event) {
            event.preventDefault();
        }
    }
}

function mapStateToProps(state) {
    return {
        plans: state.plans
    }
}

export default connect(mapStateToProps, {fetchPlans, startTraining: startTraining})(TrainingList);
{'fraction_non_alphanumeric': 0.12482468443197756, 'fraction_numerical': 0.0007012622720897616, 'mean_word_length': 2.36438679245283, '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': '793690', 'n_tokens_mistral': 813, 'n_tokens_neox': 771, 'n_words': 178}