"use client"; import { useState } from "react"; import { Note, SortMode } from "../types"; import { Plus, Search, Pin, Trash2, ArrowDownAZ, Clock, Trash, FileText, PanelLeftClose, PanelLeftOpen, } from "lucide-react"; function formatDate(ts: number): string { const d = new Date(ts); const now = new Date(); const diff = now.getTime() - ts; if (diff < 60000) return "À l'instant"; if (diff < 3600000) return `il y a ${Math.floor(diff / 60000)} min`; if (diff < 86400000) return `il y a ${Math.floor(diff / 3600000)}h`; if (d.toDateString() === now.toDateString()) { return d.toLocaleTimeString("fr-FR", { hour: "2-digit", minute: "2-digit" }); } return d.toLocaleDateString("fr-FR", { day: "numeric", month: "short", year: d.getFullYear() !== now.getFullYear() ? "numeric" : undefined, }); } interface SidebarProps { notes: Note[]; activeNoteId: string | null; searchQuery: string; sortMode: SortMode; onSelectNote: (id: string) => void; onCreateNote: () => void; onDeleteNote: (id: string) => void; onTogglePin: (id: string) => void; onSearchChange: (q: string) => void; onSortChange: (mode: SortMode) => void; onDeleteAll: () => void; onExportNote: (id: string) => void; } export default function Sidebar({ notes, activeNoteId, searchQuery, sortMode, onSelectNote, onCreateNote, onDeleteNote, onTogglePin, onSearchChange, onSortChange, onDeleteAll, onExportNote, }: SidebarProps) { const [collapsed, setCollapsed] = useState(false); const [confirmDeleteAll, setConfirmDeleteAll] = useState(false); const [hoveredId, setHoveredId] = useState(null); if (collapsed) { return (
); } return ( ); }