{"size": 1010, "ext": "js", "max_stars_repo_path": "src/Week/Component.js", "max_stars_repo_name": "Matmonsen/weather", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Week/Component.js", "max_issues_repo_name": "Matmonsen/weather", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Week/Component.js", "max_forks_repo_name": "Matmonsen/weather", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 27.2972972973, "max_line_length": 126, "alphanum_fraction": 0.5930693069}
import React, { Component } from 'react';
import TableReport from '../Tablereport';
import Loading from "../Loading";
import './style.css';
import {forecastIsInvalid} from "../utils/utils";

class Week extends Component {
    componentDidMount() {
        if (forecastIsInvalid(this.props.forecasts, this.props.lastModified))
            this.props.redirectToSearch();

        this.props.showFooter();
    }

    componentWillUnmount() {
        this.props.hideFooter();
    }

    componentWillReceiveProps(next) {
        if (!next.loading)
            this.props.showFooter();
    }

    render() {
        if (this.props.loading) {
            return (<div className="now">
                <Loading message={this.props.loadingMessage} />
            </div>);
        } else {
            return (<div className="week">
                <TableReport language={this.props.language} location={this.props.location} forecasts={this.props.forecasts} />
            </div>)
        }
    }
}

export default Week;