import { useEffect, useState } from "react"; import DocumentUploader from "./DocumentUploader"; import Chat from "./Chat"; import Dashboard from "./Dashboard"; import { getHealth } from "./api"; // Minimal hash routing keeps the dashboard on its own URL (/#/dashboard) // without pulling in a router dependency. function useHashRoute() { const [route, setRoute] = useState(window.location.hash || "#/"); useEffect(() => { const onChange = () => setRoute(window.location.hash || "#/"); window.addEventListener("hashchange", onChange); return () => window.removeEventListener("hashchange", onChange); }, []); return route; } export default function App() { const [status, setStatus] = useState("loading"); const [doc, setDoc] = useState(null); const route = useHashRoute(); const onDashboard = route.startsWith("#/dashboard"); useEffect(() => { let cancelled = false; getHealth() .then((s) => !cancelled && setStatus(s)) .catch(() => !cancelled && setStatus("unreachable")); return () => { cancelled = true; }; }, []); const ok = status === "ok"; return (

DocuAsk

Upload a document, ask questions

{onDashboard ? ( ) : doc ? ( setDoc(null)} /> ) : (

Add a document

Upload a PDF or paste text. We extract and index it so you can ask questions about it.

)}
); } function NavLink({ href, active, children }) { return ( {children} ); }