carnet panel dairy health

This commit is contained in:
alma 2025-04-20 17:53:41 +02:00
parent 26fe0433e7
commit 502316804f

View File

@ -92,19 +92,19 @@ export const NotesView: React.FC<NotesViewProps> = ({ onNoteSelect, currentFolde
}; };
const sortNotes = (notes: Note[]) => { const sortNotes = (notes: Note[]) => {
if (currentFolder === 'Diary' || currentFolder === 'Health') {
return [...notes].sort((a, b) => { return [...notes].sort((a, b) => {
// Try to extract dates from titles if (currentFolder === 'Diary' || currentFolder === 'Health') {
// For Diary and Health, sort by date in title first
const dateA = a.title.match(/^(\d{4}-\d{2}-\d{2})/); const dateA = a.title.match(/^(\d{4}-\d{2}-\d{2})/);
const dateB = b.title.match(/^(\d{4}-\d{2}-\d{2})/); const dateB = b.title.match(/^(\d{4}-\d{2}-\d{2})/);
if (dateA && dateB) { if (dateA && dateB) {
return new Date(dateB[1]).getTime() - new Date(dateA[1]).getTime(); return new Date(dateB[1]).getTime() - new Date(dateA[1]).getTime();
} }
return 0;
});
} }
return notes; // For all folders, sort by lastModified date
return new Date(b.lastModified).getTime() - new Date(a.lastModified).getTime();
});
}; };
const Icon = getFolderIcon(currentFolder); const Icon = getFolderIcon(currentFolder);
@ -164,12 +164,22 @@ export const NotesView: React.FC<NotesViewProps> = ({ onNoteSelect, currentFolde
<div className="flex items-center space-x-2"> <div className="flex items-center space-x-2">
<Icon className="h-4 w-4 text-carnet-text-muted" /> <Icon className="h-4 w-4 text-carnet-text-muted" />
<div className="flex-1"> <div className="flex-1">
{currentFolder === 'Diary' || currentFolder === 'Health' ? (
<>
<div className="text-sm font-medium text-carnet-text-primary"> <div className="text-sm font-medium text-carnet-text-primary">
{formatNoteTitle(note)} {formatNoteTitle(note)}
</div> </div>
</>
) : (
<>
<div className="text-sm font-medium text-carnet-text-primary">
{note.title}
</div>
<div className="text-xs text-carnet-text-muted"> <div className="text-xs text-carnet-text-muted">
{formatDate(note.lastModified)} {formatDate(note.lastModified)}
</div> </div>
</>
)}
</div> </div>
</div> </div>
</li> </li>
@ -177,6 +187,17 @@ export const NotesView: React.FC<NotesViewProps> = ({ onNoteSelect, currentFolde
</ul> </ul>
)} )}
</div> </div>
{/* New Note Button */}
<div className="p-4 border-t border-carnet-border">
<button
onClick={handleNewNote}
className="w-full flex items-center justify-center space-x-2 px-4 py-2 bg-primary text-white rounded-md hover:bg-primary-dark"
>
<Plus className="h-4 w-4" />
<span>Nouvelle note</span>
</button>
</div>
</div> </div>
); );
}; };