panorama/app/src/App.tsx

51 lines
1.3 KiB
TypeScript
Raw Normal View History

2024-05-25 10:04:05 +00:00
import Header from "./components/Header";
import styles from "./App.module.scss";
import "@fontsource/inter";
import "./global.scss";
2024-05-27 04:35:18 +00:00
import "katex/dist/katex.min.css";
2024-05-25 10:04:05 +00:00
import { useEffect, useState } from "react";
import NodeDisplay from "./components/NodeDisplay";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
2024-05-25 11:45:23 +00:00
import TimeAgo from "javascript-time-ago";
import en from "javascript-time-ago/locale/en";
2024-05-25 10:04:05 +00:00
const queryClient = new QueryClient();
2024-05-25 11:45:23 +00:00
TimeAgo.addDefaultLocale(en);
2024-05-25 10:04:05 +00:00
function App() {
const [nodesOpened, setNodesOpened] = useState<string[]>(() => []);
useEffect(() => {
(async () => {
console.log("ndoes", nodesOpened);
if (nodesOpened.length === 0) {
console.log("Opening today's entry.");
const resp = await fetch(
"http://localhost:5195/journal/get_todays_journal_id",
);
const data = await resp.json();
console.log("resp", data);
setNodesOpened([data.node_id]);
}
})();
}, [nodesOpened]);
const nodes = nodesOpened.map((nodeId) => (
<NodeDisplay key={nodeId} id={nodeId} />
));
return (
<QueryClientProvider client={queryClient}>
<div className={styles.container}>
<Header />
<div className={styles.nodeContainer}>{nodes}</div>
</div>
</QueryClientProvider>
);
}
export default App;