/ concept-collection / benchcompress
Sign in
concept-collection / benchcompress
benchcompress / web-ui / src / App.tsx
122 lines · 3.3 KBCodeBlameHistory
85d3449pagesJeremy Magland 1import { BrowserRouter, Routes, Route, Link } from "react-router-dom";
0968553routingJeremy Magland 2import { useEffect, useState } from "react";
3import axios from "axios";
85d3449pagesJeremy Magland 4import Home from "./pages/Home";
5import Datasets from "./pages/Datasets";
6import Algorithms from "./pages/Algorithms";
0968553routingJeremy Magland 7import { BenchmarkData } from "./types";
a4762faweb-uiJeremy Magland 8
9function App() {
0968553routingJeremy Magland 10 const [benchmarkData, setBenchmarkData] = useState<BenchmarkData | null>(
11 null,
12 );
13 const [isLoading, setIsLoading] = useState(true);
14 const [error, setError] = useState<string | null>(null);
16 useEffect(() => {
17 const fetchData = async () => {
18 try {
19 setIsLoading(true);
20 setError(null);
21 const response = await axios.get(
22 "https://raw.githubusercontent.com/magland/zia/benchmark-results/benchmark_results/results.json",
23 );
24 setBenchmarkData(response.data);
25 } catch (error) {
26 const message =
27 error instanceof Error ? error.message : "Failed to fetch data";
28 setError(message);
29 console.error("Error fetching benchmark data:", error);
30 } finally {
31 setIsLoading(false);
32 }
33 };
35 fetchData();
36 }, []);
a4762faweb-uiJeremy Magland 38 return (
0968553routingJeremy Magland 39 <BrowserRouter basename="/zia">
85d3449pagesJeremy Magland 40 <div style={{ padding: "2rem" }}>
41 <nav style={{ marginBottom: "2rem" }}>
0968553routingJeremy Magland 42 <ul
43 style={{
44 listStyle: "none",
45 padding: 0,
46 margin: 0,
47 display: "flex",
48 gap: "1.5rem",
49 }}
50 >
85d3449pagesJeremy Magland 51 <li>
52 <Link
0968553routingJeremy Magland 53 to="/home"
85d3449pagesJeremy Magland 54 style={{
55 color: "#0066cc",
56 textDecoration: "none",
0968553routingJeremy Magland 57 fontWeight: "500",
85d3449pagesJeremy Magland 58 }}
59 >
60 Home
61 </Link>
62 </li>
63 <li>
64 <Link
65 to="/datasets"
66 style={{
67 color: "#0066cc",
68 textDecoration: "none",
0968553routingJeremy Magland 69 fontWeight: "500",
85d3449pagesJeremy Magland 70 }}
71 >
72 Datasets
73 </Link>
74 </li>
75 <li>
76 <Link
77 to="/algorithms"
78 style={{
79 color: "#0066cc",
80 textDecoration: "none",
0968553routingJeremy Magland 81 fontWeight: "500",
85d3449pagesJeremy Magland 82 }}
83 >
84 Algorithms
85 </Link>
86 </li>
87 </ul>
88 </nav>
89 <main>
0968553routingJeremy Magland 90 {isLoading ? (
91 <div>Loading benchmark data...</div>
92 ) : error ? (
93 <div>Error: {error}</div>
94 ) : (
95 <Routes>
96 <Route
97 path="/home"
98 element={<Home benchmarkData={benchmarkData} />}
99 />
100 <Route
101 path="/"
102 element={<Home benchmarkData={benchmarkData} />}
103 />
104 <Route
105 path="/datasets"
106 element={<Datasets datasets={benchmarkData?.datasets || []} />}
107 />
108 <Route
109 path="/algorithms"
110 element={
111 <Algorithms algorithms={benchmarkData?.algorithms || []} />
112 }
113 />
114 </Routes>
115 )}
85d3449pagesJeremy Magland 116 </main>
117 </div>
118 </BrowserRouter>
a4762faweb-uiJeremy Magland 119 );
122export default App;
moveopenescclose