From 55c96be15442a4e0636631f48f6bad5f8a707695 Mon Sep 17 00:00:00 2001 From: Ashley Date: Fri, 12 Jun 2020 01:12:41 +1200 Subject: [PATCH] API Call for Dashboard Statistics --- client/src/components/Dashboard/index.js | 41 ++++++++++++++++++------ 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/client/src/components/Dashboard/index.js b/client/src/components/Dashboard/index.js index 3231244..12bd891 100644 --- a/client/src/components/Dashboard/index.js +++ b/client/src/components/Dashboard/index.js @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useEffect, useState } from "react"; import { useAuth } from "../App/Authentication"; import Statistic from "./components/Statistic"; import UserOverview from "./components/UserOverview"; @@ -8,6 +8,27 @@ const Dashboard = () => { const { user } = useAuth(); const name = `${user.first_name} ${user.last_name}`; + const [data, setData] = useState([]); + const [userData, setUserData] = useState([]); + + useEffect(() => { + fetch('/api/v1/admin/stats', { + headers: { "Content-type": "application/json" }, + }) + .then(response => response.json()) + .then((response) => (response?.evidence ? setData(response.evidence) : setData(null))) + .then(data => console.log(data)); + }, []); + + useEffect(() => { + fetch('/api/v1/admin/stats', { + headers: { "Content-type": "application/json" }, + }) + .then(response => response.json()) + .then((response) => (response?.users? setUserData(response.users) : setUserData(null))) + .then(data => console.log(data)); + }, []); + return ( <>
@@ -20,30 +41,32 @@ const Dashboard = () => { {/* Platform Statistics */}
+ {/* {data.evidence.map(({total}) => ( */} + {/* ))} */}
{