diff --git a/canopeum_frontend/src/App.scss b/canopeum_frontend/src/App.scss index f23dc6227..aba961d2e 100644 --- a/canopeum_frontend/src/App.scss +++ b/canopeum_frontend/src/App.scss @@ -15,27 +15,27 @@ body { } .navbar { - position: sticky; - top: 0; - z-index: 1000; - box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1); - padding-bottom: 0; + position: sticky; + top: 0; + z-index: 1000; + box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1); + padding-bottom: 0; } .navbar-logo { - padding-bottom: 0.3rem; + padding-bottom: 0.3rem; } .navbar li { - border-bottom: 0.3rem solid transparent; + border-bottom: 0.3rem solid transparent; } .nav-item.active { - border-bottom-color: white; + border-bottom-color: white; } .nav-item.active .material-symbols-outlined { - font-variation-settings: 'FILL' 1, 'wght' 700, 'GRAD' 0, 'opsz' 48; + font-variation-settings: 'FILL' 1, 'wght' 700, 'GRAD' 0, 'opsz' 48; } .fill-icon { diff --git a/canopeum_frontend/src/pages/Analytics.tsx b/canopeum_frontend/src/pages/Analytics.tsx index 08b806765..705c5c1d4 100644 --- a/canopeum_frontend/src/pages/Analytics.tsx +++ b/canopeum_frontend/src/pages/Analytics.tsx @@ -1,10 +1,93 @@ -const Analytics = () => ( -
-
-
-

Analytics

+import { useEffect, useState } from 'react' + +import type { SiteSummary } from '../services/api'; +import api from '../services/apiInterface'; +import { ensureError } from '../services/errors'; + +const Analytics = () => { + const [siteSummaries, setSiteSummaries] = useState([]); + const [isLoadingSiteSummaries, setIsLoadingSiteSummaries] = useState(false); + const [siteSummariesError, setSiteSummariesError] = useState(undefined); + + const fetchSites = async () => { + setIsLoadingSiteSummaries(true); + try { + const response = await api.siteSummary(); + setSiteSummaries(response); + } catch (error_: unknown) { + setSiteSummariesError(ensureError(error_)); + } finally { + setIsLoadingSiteSummaries(false); + } + }; + + useEffect((): void => { + void fetchSites(); + }, []); + + const renderSiteCards = () => { + if (isLoadingSiteSummaries) { + return

Loading...

+ } + + if (siteSummariesError) { + return

Error: {siteSummariesError.message}

+ } + + return siteSummaries.map(site => ( +
+
+
+
{site.name ?? 'Unnamed site'}
+

+ Site summary content here. +

+
+
+ )) + } + + + const renderSuccessRatesChart = () => ( +
+ Chart to be rendered here
-
-) + ) + + return ( +
+
+
+

Manage my Sites

+ + +
+ +
+ {renderSiteCards()} +
+ +
+

Average Annual Success Rate Per Site

+ {renderSuccessRatesChart()} +
+ +
+
+

Batch Tracking

+
+ Filters Go Here +
+
+ {renderSuccessRatesChart()} +
+
+
+ ) +} + export default Analytics