refactor: agrega queries e cache do dashboard

This commit is contained in:
Felipe Coutinho
2026-03-20 18:38:20 +00:00
parent 5b8d25d894
commit 41fd8226cb
24 changed files with 1648 additions and 690 deletions

View File

@@ -18,21 +18,26 @@ export type NoteData = {
createdAt: string;
};
function toNoteData(note: Note): NoteData {
let tasks: Task[] | undefined;
if (note.tasks) {
try {
tasks = JSON.parse(note.tasks);
} catch (error) {
console.error("Failed to parse tasks for note", note.id, error);
}
function parseTasks(value: string | null): Task[] | undefined {
if (!value) {
return undefined;
}
try {
const parsed = JSON.parse(value);
return Array.isArray(parsed) ? parsed : undefined;
} catch {
return undefined;
}
}
function toNoteData(note: Note): NoteData {
return {
id: note.id,
title: (note.title ?? "").trim(),
description: (note.description ?? "").trim(),
type: (note.type ?? "nota") as "nota" | "tarefa",
tasks,
tasks: parseTasks(note.tasks),
archived: note.archived,
createdAt: note.createdAt.toISOString(),
};