Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | 3x 3x 25x 25x 25x 25x 25x 25x 25x 25x 25x 25x 13x | import { v4 as uuidv4 } from "uuid"; import { TodoItem, TodoCategory } from "@calendar-todo/shared-types"; export class TodoEntity { id: string; title: string; description?: string; completed: boolean; priority: "high" | "medium" | "low"; categoryId: string; dueDate: Date; createdAt: Date; updatedAt: Date; userId: string; constructor(data: Partial<TodoEntity>) { this.id = data.id || uuidv4(); this.title = data.title || ""; this.description = data.description; this.completed = data.completed || false; this.priority = data.priority || "medium"; this.categoryId = data.categoryId || "personal"; this.dueDate = data.dueDate || new Date(); this.createdAt = data.createdAt || new Date(); this.updatedAt = data.updatedAt || new Date(); this.userId = data.userId || ""; } // Convert to TodoItem for frontend (category will be resolved by service) toTodoItem(category?: TodoCategory): TodoItem { return { id: this.id, title: this.title, date: this.dueDate, completed: this.completed, category: category || { id: this.categoryId, name: "Unknown", color: "#64748b", createdAt: new Date(), order: 0, }, userId: this.userId, }; } // Update entity data update(data: Partial<TodoEntity>): void { Iif (data.title !== undefined) this.title = data.title; Iif (data.description !== undefined) this.description = data.description; Iif (data.completed !== undefined) this.completed = data.completed; Iif (data.priority !== undefined) this.priority = data.priority; Iif (data.categoryId !== undefined) this.categoryId = data.categoryId; Iif (data.dueDate !== undefined) this.dueDate = data.dueDate; this.updatedAt = new Date(); } // Toggle completion status toggleComplete(): void { this.completed = !this.completed; this.updatedAt = new Date(); } } |