"use client"; import React, { useState } from 'react'; import { Plus, Search, X } from 'lucide-react'; import { format } from 'date-fns'; import { fr } from 'date-fns/locale'; interface Note { id: string; title: string; content: string; lastEdited: Date; category?: string; tags?: string[]; } interface NotesViewProps { onNoteSelect?: (note: Note) => void; } export const NotesView: React.FC = ({ onNoteSelect }) => { const [searchQuery, setSearchQuery] = useState(''); const [notes, setNotes] = useState([ { id: '1', title: 'Budget and expenses', content: 'Created with Secure Spreadsheets', lastEdited: new Date('2022-03-24T19:16:00'), category: 'Finance', tags: ['Finance'] } ]); const handleNewNote = () => { const newNote: Note = { id: Date.now().toString(), title: 'New Note', content: '', lastEdited: new Date() }; setNotes([newNote, ...notes]); onNoteSelect?.(newNote); }; const formatDate = (date: Date) => { return format(date, 'EEEE d MMM yyyy, HH:mm', { locale: fr }); }; return (
{/* Search Header */}
setSearchQuery(e.target.value)} placeholder="Link tags, notes, files..." className="w-full pl-9 pr-4 py-2 bg-white border border-carnet-border rounded-md text-sm text-carnet-text-primary placeholder-carnet-text-muted focus:outline-none focus:ring-1 focus:ring-primary" /> {searchQuery && ( )}
{/* Category Header */}
F
Finance
{/* Notes List */}
{notes.map((note) => (
onNoteSelect?.(note)} >
{note.title} {note.tags?.map((tag) => ( {tag} ))}
{formatDate(note.lastEdited)} {note.content && ( <> {note.content} )}
))}
); };