Refactoring search, navigation, canvas and others to fit the new data model

This commit is contained in:
2024-08-06 00:15:09 +02:00
parent e28d72fd1b
commit a3d0b3b5bd
26 changed files with 409 additions and 253 deletions

37
composables/useProject.ts Normal file
View File

@@ -0,0 +1,37 @@
import type { Project } from "~/server/api/project.get";
export default function useProject()
{
const id = useState<number>("projectId", () => 1);
const name = useState<string>("projectName", undefined);
const owner = useState<number>("projectOwner", undefined);
const home = useState<string | null>("projectHomepage", () => null);
return {
id, name, owner, home, get, set
}
}
async function get(): Promise<void> {
const id = useState<number>("projectId");
if (!id.value)
return;
try {
const result = await $fetch(`/api/project/${id}`) as Project;
const name = useState<string>("projectName");
const owner = useState<number>("projectOwner");
const home = useState<string | null>("projectHomepage");
name.value = result.name;
owner.value = result.owner;
home.value = result.home;
} catch(e) {}
}
function set(id: number): void {
const _id = useState<number>("projectId");
_id.value = id;
}