"use client"; import { RiArchiveLine, RiCheckLine, RiDeleteBin5Line, RiFileList2Line, RiInboxUnarchiveLine, RiPencilLine, } from "@remixicon/react"; import { buildNoteDisplayTitle, formatNoteCreatedAt, } from "@/features/notes/lib/formatters"; import { Badge } from "@/shared/components/ui/badge"; import { Card, CardContent, CardFooter } from "@/shared/components/ui/card"; import { type Note, sortTasksByStatus } from "./types"; interface NoteCardProps { note: Note; onEdit?: (note: Note) => void; onDetails?: (note: Note) => void; onRemove?: (note: Note) => void; onArquivar?: (note: Note) => void; isArquivadas?: boolean; } export function NoteCard({ note, onEdit, onDetails, onRemove, onArquivar, isArquivadas = false, }: NoteCardProps) { const displayTitle = buildNoteDisplayTitle(note.title); const createdAtLabel = formatNoteCreatedAt(note.createdAt); const isTask = note.type === "tarefa"; const tasks = note.tasks || []; const sortedTasks = sortTasksByStatus(tasks); const completedCount = tasks.filter((t) => t.completed).length; const totalCount = tasks.length; const actions = [ { label: "editar", icon: , onClick: onEdit, destructive: false, }, { label: "detalhes", icon: , onClick: onDetails, destructive: false, }, { label: isArquivadas ? "desarquivar" : "arquivar", icon: isArquivadas ? ( ) : ( ), onClick: onArquivar, destructive: false, }, { label: "remover", icon: , onClick: onRemove, destructive: true, }, ].filter((action) => typeof action.onClick === "function"); return ( {displayTitle} {createdAtLabel && ( {createdAtLabel} )} {isTask && ( {completedCount}/{totalCount} concluídas )} {isTask ? ( {sortedTasks.slice(0, 5).map((task) => ( {task.completed && ( )} {task.text} ))} {tasks.length > 5 && ( +{tasks.length - 5}{" "} {tasks.length - 5 === 1 ? "tarefa" : "tarefas"}... )} ) : ( {note.description} )} {actions.length > 0 ? ( {actions.map(({ label, icon, onClick, destructive }) => ( onClick?.(note)} className={`flex items-center gap-1 font-medium transition-opacity hover:opacity-80 ${destructive ? "text-destructive" : "text-primary"}`} aria-label={`${label} anotação`} > {icon} {label} ))} ) : null} ); }
+{tasks.length - 5}{" "} {tasks.length - 5 === 1 ? "tarefa" : "tarefas"}...
{note.description}