From cd0aba20384fc4f31b678f9d7d51bb4595bdd3ab Mon Sep 17 00:00:00 2001 From: Jacob Filik Date: Wed, 9 Oct 2024 15:25:13 +0100 Subject: [PATCH] Add page and route for persitent view --- src/App.tsx | 2 + src/components/PersistentView.tsx | 68 +++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 src/components/PersistentView.tsx diff --git a/src/App.tsx b/src/App.tsx index 55f2407..8666a73 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -38,6 +38,7 @@ import { createTheme, ThemeProvider } from "@mui/material/styles"; import { MetadataProvider } from "./contexts/MetadataContext.tsx"; import { Routes, Route } from "react-router-dom"; import XDIPage from "./components/XDIPage.tsx"; +import PersistentView from "./components/PersistentView.tsx"; function App() { const prefersDarkMode = useMediaQuery("(prefers-color-scheme: dark)"); @@ -73,6 +74,7 @@ function App() { } /> } /> } /> + } /> diff --git a/src/components/PersistentView.tsx b/src/components/PersistentView.tsx new file mode 100644 index 0000000..565abfd --- /dev/null +++ b/src/components/PersistentView.tsx @@ -0,0 +1,68 @@ + +import { useState, useContext } from "react"; + +import axios from "axios"; +import MetadataTab from "./MetadataTab.tsx"; + +import { Grid, Typography } from "@mui/material"; +import XDIFile from "../xdifile.ts"; + +import { XDIFileProvider } from "../contexts/XDIFileContext.tsx"; +import XDIChart from "./XDIChart.tsx"; + +import { useLocation} from "react-router-dom"; +import { useEffect } from "react"; + +import { MetadataContext } from "../contexts/MetadataContext.tsx"; + + + +function PersistentView() { + + const location = useLocation(); + const id = location.pathname.slice(5) + + const [xdiFile, setXDIFile] = useState(null); + const allStandards = useContext(MetadataContext); + + console.log(id) + console.log(allStandards[1]) + + const standard = allStandards.find((f) => f.location === id) + + useEffect(() => { + axios.get("/webxdiviewer/xdidata/" + id).then((response) => { + + let xdi = null; + try { + xdi = XDIFile.parseFile(response.data); + + } catch { + console.log("Could not read {}", focus) + + } + + setXDIFile(xdi); + })}, [id]); + + + + // const onClick = getData(); + + return ( + + + + {standard + ? + : Could not find {id} + } + + + + + + + ); + } +export default PersistentView; \ No newline at end of file