import { Alert, Box } from "@mui/material"; import { useEffect, useState } from "react"; import { useLocation, useNavigate } from "react-router-dom"; import { IReport } from "../../../server/src/core/interfaces"; import { ajax, PagesEnum } from "../functions"; import { Report } from "../Report"; import ReportHelper from "../ReportHelper"; import Search from "../Search"; export function AnalyzePage() { const location = useLocation(); const library = new URLSearchParams(location.search).get("library") ?? ""; const [report, setReport] = useState(undefined); const navigate = useNavigate(); useEffect(() => { if (library && library.length >= 3) { loadReport(library); } }, [library]); async function loadReport(library: string) { console.log(`Searching ${library}`); const report = await ajax("?library=" + encodeURIComponent(library)); setReport(report); } return ( <> navigate(`${PagesEnum.AnalyzePage}?library=${library}`)} /> {report && ( {ReportHelper.fetchAllVersions(report).size === 0 ? ( Library "{library}" not found ) : ( )} )} ); }