import React, { useEffect } from "react";
import { Button, Grid, Link } from "@material-ui/core";
import CreateIcon from "@material-ui/icons/Create";

import { useStatusContext } from "../Contexts/StatusContext";
import useStyles from "../useStyles";
import ResponsiveIFrame from "../Controls/ResponsiveIFrame";

const Dashboard = () => {
  const classes = useStyles();
  const { setTitle } = useStatusContext();

  useEffect(() => {
    setTitle("Dashboard");
    // eslint-disable-next-line
  }, []);

  return (
    <div className={classes.paper}>
      <Grid container className={classes.root} spacing={2}>
        <Grid item md={6}>
          <ResponsiveIFrame
            classes={classes}
            src="https://grafana.fiskerdps.com/d-solo/jRKKo2gnz/battery?orgId=2&refresh=30s&panelId=2"
            title="Battery Time Series"
          />
        </Grid>
        <Grid item md={6}>
          <ResponsiveIFrame
            classes={classes}
            src="https://grafana.fiskerdps.com/d-solo/1VTVJ_qGk/dashboard?orgId=2&refresh=30s&panelId=12"
            title="Signals Time Series"
          />
        </Grid>
      </Grid>
      <Button
        style={{ marginTop: 10 }}
        aria-label="create"
        color="primary"
        component={Link}
        href="https://grafana.fiskerdps.com"
        rel="noopener"
        target="_blank"
      >
        <CreateIcon fontSize="large" />
        Create Charts
      </Button>
    </div>
  );
};

export default Dashboard;
