import React, { useContext, FC } from "react";
// import DegreeDay from "../data/DegreeDay";
// import TemperaturePerSeason from "../data/TemperaturePerSeason";
import TemperaturePerSector from "../data/TemperaturePerSector";
// import Precipitation from "../data/Precipitation";
import { UserStateContext } from "../../context/auth/AuthProvider";
import DashboardProvider from "../../context/dashboard/Provider";
import { Redirect } from "react-router-dom";
import Layout from "../layout";
import Cockpit from "../UI/dashboard/cockpit";

const Home: FC = () => {
  const userState = useContext(UserStateContext);

  if (!userState.loggedIn) {
    return <Redirect to="/login" />;
  }

  return (
    <>
      <Layout>
        <DashboardProvider>
          <Cockpit />

          <section className="row">
            <div className="col-xl-8">
              <TemperaturePerSector />
            </div>
          </section>
        </DashboardProvider>
      </Layout>
    </>
  );
};

export default Home;
