summaryrefslogtreecommitdiff
path: root/extension/react-app/src/pages/history.tsx
diff options
context:
space:
mode:
authorNate Sesti <sestinj@gmail.com>2023-08-06 09:28:22 -0700
committerNate Sesti <sestinj@gmail.com>2023-08-06 09:28:22 -0700
commitf19345c652cfcf1bdf13d0a44a2f302e0cd1aa4c (patch)
tree4582964105452768a5346afcd764d26db6091504 /extension/react-app/src/pages/history.tsx
parent98de69abbd221d0f6b7257a72b89b191356b10b7 (diff)
downloadsncontinue-f19345c652cfcf1bdf13d0a44a2f302e0cd1aa4c.tar.gz
sncontinue-f19345c652cfcf1bdf13d0a44a2f302e0cd1aa4c.tar.bz2
sncontinue-f19345c652cfcf1bdf13d0a44a2f302e0cd1aa4c.zip
feat: :construction: Router and new history page
Diffstat (limited to 'extension/react-app/src/pages/history.tsx')
-rw-r--r--extension/react-app/src/pages/history.tsx55
1 files changed, 55 insertions, 0 deletions
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<SessionInfo[]>([]);
+ 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 (
+ <div style={{ width: "100%" }}>
+ <table style={{ width: "100%" }}>
+ <tbody>
+ {sessions.map((session, index) => (
+ <tr key={index}>
+ <td>
+ <div
+ style={{ cursor: "pointer" }}
+ onClick={() => {
+ // client?.loadSession(session.id);
+ // document.location.href = "/gui";
+ }}
+ >
+ <div>{session.title}</div>
+ <div style={{ color: "lightgray" }}>
+ {session.date_created}
+ </div>
+ </div>
+ </td>
+ </tr>
+ ))}
+ </tbody>
+ </table>
+ </div>
+ );
+}
+
+export default History;