From 3b8c7e391e1f370af74df30a14a699a49543f918 Mon Sep 17 00:00:00 2001
From: Sam Nystrom <sam@samnystrom.dev>
Date: Sat, 16 Mar 2024 21:09:02 +0000
Subject: refactor: extract NodeEditor into a component

---
 src/pages/Editor.tsx | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100644 src/pages/Editor.tsx

(limited to 'src/pages/Editor.tsx')

diff --git a/src/pages/Editor.tsx b/src/pages/Editor.tsx
new file mode 100644
index 0000000..c929595
--- /dev/null
+++ b/src/pages/Editor.tsx
@@ -0,0 +1,30 @@
+import { useEffect, useMemo, useContext } from 'preact/hooks';
+import { useSignal } from '@preact/signals';
+import { Pb } from '../context.ts';
+import type { Project } from '../types.ts';
+import { NodeEditor } from '../components';
+
+export interface EditorProps {
+	user: string;
+	project: string;
+}
+
+const Editor = ({ user, project }: EditorProps) => {
+	const pb = useContext(Pb)!;
+	const projectData = useSignal<Project | null>(null);
+
+	useEffect(() => {
+		(async () => {
+			projectData.value = await pb.collection('projects')
+				.getFirstListItem(pb.filter('owner.username = {:user} && name = {:project}', { user, project }));
+		})();
+	}, []);
+
+	return (
+		<>
+			{!!projectData.value && <NodeEditor project={projectData.value} />}
+		</>
+	);
+};
+
+export default Editor;
-- 
cgit v1.2.3

