blob: c5b369f5d088bb244451180e8ed4e4abf4a919be (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
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} /> : null;
};
export default Editor;
|