File size: 874 Bytes
3382f47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import React, { useState, useEffect } from "react";
import tw from "tailwind-styled-components";

import Dashboard from "~/components/data/Dashboard";
import Reports from "~/components/data/Reports";

const DataPage: React.FC = () => {
  const [data, setData] = useState<any>([]);
  const getData = async () => {
    try {
      let url = `http://localhost:8000/data`;
      const response = await fetch(url);
      const responseData = await response.json();

      setData(responseData);
    } catch (error) {
      console.error("There was an error fetching the data", error);
    }
  };

  useEffect(() => {
    getData();
  }, []);

  return (
    <PageContainer>
      <Dashboard data={data} />
      <Reports data={data} />
    </PageContainer>
  );
};

export default DataPage;

const PageContainer = tw.div`
  px-12
  w-full
  h-full
  min-h-screen
  bg-gray-50
`;