"use client"; import { RiCheckLine, RiSubtractLine } from "@remixicon/react"; import { buildNoteDisplayTitle, formatNoteCreatedAtLong, } from "@/features/notes/lib/formatters"; import { Badge } from "@/shared/components/ui/badge"; import { Button } from "@/shared/components/ui/button"; import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "@/shared/components/ui/dialog"; import { type Note, sortTasksByStatus } from "./types"; interface NoteDetailsDialogProps { note: Note | null; open: boolean; onOpenChange: (open: boolean) => void; onEdit?: (note: Note) => void; } export function NoteDetailsDialog({ note, open, onOpenChange, onEdit, }: NoteDetailsDialogProps) { if (!note) { return null; } const formattedDate = formatNoteCreatedAtLong(note.createdAt) ?? ""; const displayTitle = buildNoteDisplayTitle(note.title); const tasks = note.tasks || []; const sortedTasks = sortTasksByStatus(tasks); const isTask = note.type === "tarefa"; const completedCount = tasks.filter((t) => t.completed).length; const totalCount = tasks.length; return ( {displayTitle} {isTask && ( {completedCount}/{totalCount} )} {formattedDate} {isTask ? (
{sortedTasks.map((task) => (
{task.completed ? ( ) : ( )}
{task.text}
))}
) : (
{note.description}
)} {onEdit && ( )}
); }