diff options
Diffstat (limited to 'src/pages/Editor.tsx')
| -rw-r--r-- | src/pages/Editor.tsx | 30 |
1 files changed, 30 insertions, 0 deletions
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; |
