import { Button } from "@/components/ui/button" import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu" import { Archive, ArchiveRestore, Bell, MoreVertical, Palette, Pin, Users, Maximize2, FileText, Trash2, RotateCcw, History, AlignLeft, FileCode2, PenLine, ListChecks, } from "lucide-react" import { cn } from "@/lib/utils" import { NOTE_COLORS } from "@/lib/types" import { useLanguage } from "@/lib/i18n" import { ReminderDialog } from "@/components/reminder-dialog" import { useState } from "react" interface NoteActionsProps { isPinned: boolean isArchived: boolean currentColor: string currentSize?: 'small' | 'medium' | 'large' onTogglePin: () => void onToggleArchive: () => void onColorChange: (color: string) => void onSizeChange?: (size: 'small' | 'medium' | 'large') => void onDelete: () => void onShareCollaborators?: () => void isMarkdown?: boolean noteType?: string onToggleMarkdown?: () => void isTrashView?: boolean onRestore?: () => void onPermanentDelete?: () => void onOpenHistory?: () => void historyEnabled?: boolean noteId?: string currentReminder?: Date | null onUpdateReminder?: (noteId: string, reminder: Date | null) => void className?: string } export function NoteActions({ isPinned, isArchived, currentColor, currentSize = 'small', onTogglePin, onToggleArchive, onColorChange, onSizeChange, onDelete, onShareCollaborators, isMarkdown = false, noteType = 'text', onToggleMarkdown, isTrashView, onRestore, onPermanentDelete, onOpenHistory, historyEnabled = false, noteId, currentReminder, onUpdateReminder, className }: NoteActionsProps) { const { t } = useLanguage() const [showReminder, setShowReminder] = useState(false) // Trash view: show only Restore and Permanent Delete if (isTrashView) { return (
e.stopPropagation()} > {/* Restore Button */} {/* Permanent Delete Button */}
) } return (
e.stopPropagation()} > {/* Reminder */} {noteId && onUpdateReminder && ( <>
e.stopPropagation()}> { onUpdateReminder(noteId, date) setShowReminder(false) }} onRemove={() => { onUpdateReminder(noteId, null) setShowReminder(false) }} />
)} {/* Color Palette */}
{Object.entries(NOTE_COLORS).map(([colorName, classes]) => (
{onToggleMarkdown && (() => { const iconMap: Record = { text: AlignLeft, markdown: FileCode2, richtext: PenLine, checklist: ListChecks } const TypeIcon = iconMap[noteType] || FileText return ( ) })()} {/* More Options */} {/* Pin/Unpin Option */} {isPinned ? ( <> {t('notes.unpin')} ) : ( <> {t('notes.pin')} )} {isArchived ? ( <> {t('notes.unarchive')} ) : ( <> {t('notes.archive')} )} {onOpenHistory && ( {historyEnabled ? (t('notes.history') || 'Historique') : (t('notes.enableHistory') || "Activer l'historique")} )} {/* Size Selector */} {onSizeChange && ( <>
{t('notes.size')}
{(['small', 'medium', 'large'] as const).map((size) => ( { onSizeChange?.(size); }} className={cn( "capitalize", currentSize === size && "bg-accent" )} > {t(`notes.${size}` as const)} ))} )} {/* Collaborators */} {onShareCollaborators && ( <> { e.stopPropagation() onShareCollaborators() }} > {t('notes.shareWithCollaborators')} )} {t('notes.delete')}
) }