3import axios from "axios";
5import Datasets from "./pages/Datasets";
6import Algorithms from "./pages/Algorithms";
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 }, []);
41 <nav style={{ marginBottom: "2rem" }}>
43 style={{
44 listStyle: "none",
45 padding: 0,
46 margin: 0,
47 display: "flex",
48 gap: "1.5rem",
49 }}
50 >
52 <Link
55 color: "#0066cc",
56 textDecoration: "none",
59 >
60 Home
61 </Link>
62 </li>
63 <li>
64 <Link
65 to="/datasets"
66 style={{
67 color: "#0066cc",
68 textDecoration: "none",
71 >
72 Datasets
73 </Link>
74 </li>
75 <li>
76 <Link
77 to="/algorithms"
78 style={{
79 color: "#0066cc",
80 textDecoration: "none",
83 >
84 Algorithms
85 </Link>
86 </li>
87 </ul>
88 </nav>
89 <main>
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 )}
117 </div>
118 </BrowserRouter>
120}
122export default App;