From f19345c652cfcf1bdf13d0a44a2f302e0cd1aa4c Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Sun, 6 Aug 2023 09:28:22 -0700 Subject: feat: :construction: Router and new history page --- extension/react-app/src/pages/history.tsx | 55 +++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 extension/react-app/src/pages/history.tsx (limited to 'extension/react-app/src/pages/history.tsx') diff --git a/extension/react-app/src/pages/history.tsx b/extension/react-app/src/pages/history.tsx new file mode 100644 index 00000000..6539f0f5 --- /dev/null +++ b/extension/react-app/src/pages/history.tsx @@ -0,0 +1,55 @@ +import React, { useContext, useEffect, useState } from "react"; +import { SessionInfo } from "../../../schema/SessionInfo"; +import { GUIClientContext } from "../App"; +import fetch from "node-fetch"; +import { useSelector } from "react-redux"; +import { RootStore } from "../redux/store"; + +function History() { + const [sessions, setSessions] = useState([]); + const client = useContext(GUIClientContext); + const apiUrl = useSelector((state: RootStore) => state.config.apiUrl); + + useEffect(() => { + const fetchSessions = async () => { + console.log("fetching sessions"); + if (!apiUrl) { + return; + } + const response = await fetch(`${apiUrl}/sessions/list`); + const json = await response.json(); + console.log(json); + setSessions(json); + }; + fetchSessions(); + }, [client]); + + return ( +
+ + + {sessions.map((session, index) => ( + + + + ))} + +
+
{ + // client?.loadSession(session.id); + // document.location.href = "/gui"; + }} + > +
{session.title}
+
+ {session.date_created} +
+
+
+
+ ); +} + +export default History; -- cgit v1.2.3-70-g09d2