diff --git a/components/anotacoes/note-details-dialog.tsx b/components/anotacoes/note-details-dialog.tsx index b4e2910..54de84f 100644 --- a/components/anotacoes/note-details-dialog.tsx +++ b/components/anotacoes/note-details-dialog.tsx @@ -45,13 +45,14 @@ export function NoteDetailsDialog({ }; }, [note]); + const tasks = note?.tasks || []; + const sortedTasks = useMemo(() => sortTasksByStatus(tasks), [tasks]); + if (!note) { return null; } 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; diff --git a/components/anotacoes/note-dialog.tsx b/components/anotacoes/note-dialog.tsx index 5c5f8df..edd44ef 100644 --- a/components/anotacoes/note-dialog.tsx +++ b/components/anotacoes/note-dialog.tsx @@ -26,6 +26,7 @@ import { DialogTrigger, } from "@/components/ui/dialog"; import { Input } from "@/components/ui/input"; +import { Label } from "@/components/ui/label"; import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; import { Textarea } from "@/components/ui/textarea"; import { useControlledState } from "@/hooks/use-controlled-state"; @@ -76,7 +77,6 @@ export function NoteDialog({ const descRef = useRef(null); const newTaskRef = useRef(null); - // Use controlled state hook for dialog open state const [dialogOpen, setDialogOpen] = useControlledState( open, false, @@ -85,7 +85,6 @@ export function NoteDialog({ const initialState = buildInitialValues(note); - // Use form state hook for form management const { formState, updateField, setFormState } = useFormState(initialState); @@ -98,7 +97,11 @@ export function NoteDialog({ } }, [dialogOpen, note, setFormState]); - const title = mode === "create" ? "Nova anotação" : "Editar anotação"; + const dialogTitle = mode === "create" ? "Nova anotação" : "Editar anotação"; + const description = + mode === "create" + ? "Crie uma nota simples ou uma lista de tarefas." + : "Altere o conteúdo desta anotação."; const submitLabel = mode === "create" ? "Salvar" : "Atualizar"; const titleCount = formState.title.length; @@ -224,104 +227,114 @@ export function NoteDialog({ return ( {trigger ? {trigger} : null} - + - {title} - - {mode === "create" - ? "Criar nova anotação" - : "Editar anotação existente"} - + {dialogTitle} + {description}
{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" + > +
+ + +
+
+ + +
+
+
)} - updateField("title", e.target.value)} - placeholder="Título" - maxLength={MAX_TITLE} - disabled={isPending} - required - /> - - {isNote && ( -