Working system

This commit is contained in:
2026-02-27 22:51:02 +01:00
parent 162e2b3d3f
commit 5895974af2
17 changed files with 356 additions and 332 deletions
+52 -5
View File
@@ -1,13 +1,60 @@
import { Workspace } from "./types";
import { Workspace, TodoEntity, DocEntity, Status } from "./types";
export function createDefaultWorkspace(): Workspace {
const now = Date.now();
const todoId = crypto.randomUUID();
const docId = crypto.randomUUID();
const defaultStatuses: Status[] = [
{ id: "status_todo", name: "To Do", order: 0, color: "#808080" },
{
id: "status_inprogress",
name: "In Progress",
order: 1,
color: "#0ea5e9",
},
{ id: "status_done", name: "Done", order: 2, color: "#10b981" },
];
const todoEntity: TodoEntity = {
id: todoId,
type: "todo",
name: "Tasks",
config: { statuses: defaultStatuses },
tags: {},
tasks: {},
createdAt: now,
updatedAt: now,
};
const docEntity: DocEntity = {
id: docId,
type: "doc",
name: "Notes",
content: { version: "2.28.0", time: now, blocks: [] },
createdAt: now,
updatedAt: now,
};
return {
id: crypto.randomUUID(),
name: "New Workspace",
entities: {},
layout: [],
name: "My Workspace",
entities: {
[todoId]: todoEntity,
[docId]: docEntity,
},
layout: [
{
type: "group",
id: crypto.randomUUID(),
name: "Productivity",
children: [
{ entityId: todoId, type: "item" },
{ entityId: docId, type: "item" },
],
},
],
createdAt: now,
updatedAt: now,
};
@@ -27,7 +74,7 @@ export function loadWorkspaceFromLocalStorage(id: string): Workspace {
if (
typeof parsed !== "object" ||
parsed === null ||
typeof parsed.version !== "number"
typeof parsed.id !== "string"
) {
console.warn("Invalid workspace shape. Resetting.");
return createDefaultWorkspace();