<commit_before>import React from 'react';
import {graphql} from 'react-apollo';
import gql from 'graphql-tag';
import WeatherStation from './WeatherStation';
import WeatherStationForm from './WeatherStationForm';

const AllWeatherStationsContainer = (props) => {
	let {data: {loading, allStations}} = props;

	if (loading) {
		return <p>Loading all weather stations&hellip;</p>;
	}

	if (!allStations.stations.length) {
		return <div>
			<h2>At this place you can add and maintain all your weather stations</h2>
			<p>Are you ready to add your first weather station?</p>
			<WeatherStationForm series={allStations.series}/>
		</div>;
	} else {
		return <div>
			{allStations.stations.map(dataSource =>
				<WeatherStation
					key={dataSource.node.id}
					id={dataSource.node.id}
					name={dataSource.node.name}
					lastRecord={dataSource.node.records ? dataSource.node.records[0] : { //defaults
							indoorTemperature: null
						}}
				/>
			)}
			<WeatherStationForm series={allStations.series}/>
		</div>
	}
};

//TODO: stránkování
export default graphql(gql`{
  allStations: allWeatherStations {
    stations: edges {
      cursor
      node {
        id
        name
        records: allRecords(first: 1) {
          indoorTemperature
        }
      }
    }
    series: series {
      id
      name
    }
  }
}`)(AllWeatherStationsContainer);<commit_msg>AllWeatherStationsContainer: do not repeat form usage<commit_after>import React from 'react';
import {graphql} from 'react-apollo';
import gql from 'graphql-tag';
import WeatherStation from './WeatherStation';
import WeatherStationForm from './WeatherStationForm';

const AllWeatherStationsContainer = (props) => {
	let {data: {loading, allStations}} = props;

	if (loading) {
		return <p>Loading all weather stations&hellip;</p>;
	}

	let weatherStationForm = <WeatherStationForm series={allStations.series}/>;

	if (!allStations.stations.length) {
		return <div>
			<h2>At this place you can add and maintain all your weather stations</h2>
			<p>Are you ready to add your first weather station?</p>
			{weatherStationForm}
		</div>;
	} else {
		return <div>
			{allStations.stations.map(dataSource =>
				<WeatherStation
					key={dataSource.node.id}
					id={dataSource.node.id}
					name={dataSource.node.name}
					lastRecord={dataSource.node.records ? dataSource.node.records[0] : { //defaults
							indoorTemperature: null
						}}
				/>
			)}
			{weatherStationForm}
		</div>
	}
};

//TODO: stránkování
export default graphql(gql`{
  allStations: allWeatherStations {
    stations: edges {
      cursor
      node {
        id
        name
        records: allRecords(first: 1) {
          indoorTemperature
        }
      }
    }
    series: series {
      id
      name
    }
  }
}`)(AllWeatherStationsContainer);
{'fraction_non_alphanumeric': 0.12177650429799428, 'fraction_numerical': 0.0028653295128939827, 'mean_word_length': 3.137777777777778, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 32, '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': '3875329', 'n_tokens_mistral': 1001, 'n_tokens_neox': 895, 'n_words': 208}