diff --git a/components/anotacoes/note-card.tsx b/components/anotacoes/note-card.tsx index 6c2cbb6..351c00d 100644 --- a/components/anotacoes/note-card.tsx +++ b/components/anotacoes/note-card.tsx @@ -11,7 +11,7 @@ import { import { useMemo } from "react"; import { Badge } from "@/components/ui/badge"; import { Card, CardContent, CardFooter } from "@/components/ui/card"; -import type { Note } from "./types"; +import { type Note, sortTasksByStatus } from "./types"; const DATE_FORMATTER = new Intl.DateTimeFormat("pt-BR", { dateStyle: "medium", @@ -47,6 +47,7 @@ export function NoteCard({ const isTask = note.type === "tarefa"; const tasks = note.tasks || []; + const sortedTasks = useMemo(() => sortTasksByStatus(tasks), [tasks]); const completedCount = tasks.filter((t) => t.completed).length; const totalCount = tasks.length; @@ -82,7 +83,7 @@ export function NoteCard({ ].filter((action) => typeof action.onClick === "function"); return ( - +
@@ -99,7 +100,7 @@ export function NoteCard({ {isTask ? (
- {tasks.slice(0, 5).map((task) => ( + {sortedTasks.slice(0, 5).map((task) => (
sortTasksByStatus(tasks), [tasks]); const completedCount = tasks.filter((t) => t.completed).length; const totalCount = tasks.length; @@ -71,7 +72,7 @@ export function NoteDetailsDialog({ {isTask ? (
- {tasks.map((task) => ( + {sortedTasks.map((task) => ( sortTasksByStatus(formState.tasks || []), + [formState.tasks], + ); + const onlySpaces = normalize(formState.title).length === 0 || (isNote && formState.description.trim().length === 0) || @@ -222,198 +227,139 @@ export function NoteDialog({ {title} - {description} + + {mode === "create" + ? "Criar nova anotação" + : "Editar anotação existente"} +
- {/* Seletor de Tipo - apenas no modo de criação */} {mode === "create" && ( -
- - - updateField("type", value as "nota" | "tarefa") - } - disabled={isPending} - className="flex gap-4" - > -
- - -
-
- - -
-
-
+ + updateField("type", value as "nota" | "tarefa") + } + disabled={isPending} + className="flex gap-4" + > +
+ + +
+
+ + +
+
)} - {/* Título */} -
- - updateField("title", e.target.value)} - placeholder={ - isNote ? "Ex.: Revisar metas do mês" : "Ex.: Tarefas da semana" - } - maxLength={MAX_TITLE} + updateField("title", e.target.value)} + placeholder="Título" + maxLength={MAX_TITLE} + disabled={isPending} + required + /> + + {isNote && ( +