refactor(Notes): update favorite filtering logic for clarity and consistency in NotesPageClient and NotesList components
This commit is contained in:
@@ -284,11 +284,14 @@ function NotesPageContent({
|
|||||||
// Filtrer les notes par dossier
|
// Filtrer les notes par dossier
|
||||||
const filteredNotes =
|
const filteredNotes =
|
||||||
selectedFolderId === '__favorites__'
|
selectedFolderId === '__favorites__'
|
||||||
? notes.filter((note) => note.isFavorite) // Notes favorites
|
? notes.filter((note) => note.isFavorite === true) // Notes favorites
|
||||||
: selectedFolderId === '__uncategorized__'
|
: selectedFolderId === '__uncategorized__'
|
||||||
? notes.filter((note) => !note.folderId) // Notes sans dossier
|
? notes.filter((note) => !note.folderId) // Notes sans dossier
|
||||||
: selectedFolderId
|
: selectedFolderId
|
||||||
? notes.filter((note) => note.folderId === selectedFolderId)
|
? notes.filter((note) => {
|
||||||
|
// Gérer les cas où folderId pourrait être undefined ou null
|
||||||
|
return note.folderId === selectedFolderId;
|
||||||
|
})
|
||||||
: notes; // Toutes les notes
|
: notes; // Toutes les notes
|
||||||
|
|
||||||
// Gérer le changement de dossier
|
// Gérer le changement de dossier
|
||||||
@@ -299,7 +302,7 @@ function NotesPageContent({
|
|||||||
// Sélectionner automatiquement la première note du dossier
|
// Sélectionner automatiquement la première note du dossier
|
||||||
const folderNotes =
|
const folderNotes =
|
||||||
folderId === '__favorites__'
|
folderId === '__favorites__'
|
||||||
? notes.filter((note) => note.isFavorite)
|
? notes.filter((note) => note.isFavorite === true)
|
||||||
: folderId === '__uncategorized__'
|
: folderId === '__uncategorized__'
|
||||||
? notes.filter((note) => !note.folderId)
|
? notes.filter((note) => !note.folderId)
|
||||||
: folderId
|
: folderId
|
||||||
@@ -422,7 +425,7 @@ function NotesPageContent({
|
|||||||
availableTags={availableTags}
|
availableTags={availableTags}
|
||||||
onNoteDrop={handleNoteDrop}
|
onNoteDrop={handleNoteDrop}
|
||||||
favoritesCount={
|
favoritesCount={
|
||||||
notes.filter((note) => note.isFavorite).length
|
notes.filter((note) => note.isFavorite === true).length
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -128,9 +128,14 @@ function SortableNoteItem({
|
|||||||
|
|
||||||
<div className="flex-1 min-w-0">
|
<div className="flex-1 min-w-0">
|
||||||
<div className="flex items-start justify-between gap-2 mb-1">
|
<div className="flex items-start justify-between gap-2 mb-1">
|
||||||
|
<div className="flex items-center gap-1.5 flex-1 min-w-0">
|
||||||
|
{note.isFavorite === true && (
|
||||||
|
<Star className="w-3 h-3 text-[var(--accent)] fill-current flex-shrink-0" />
|
||||||
|
)}
|
||||||
<h3 className="font-medium text-sm text-[var(--foreground)] truncate">
|
<h3 className="font-medium text-sm text-[var(--foreground)] truncate">
|
||||||
{getNoteTitle(note.content)}
|
{getNoteTitle(note.content)}
|
||||||
</h3>
|
</h3>
|
||||||
|
</div>
|
||||||
{showDeleteConfirm === note.id ? (
|
{showDeleteConfirm === note.id ? (
|
||||||
<div className="flex gap-1">
|
<div className="flex gap-1">
|
||||||
<button
|
<button
|
||||||
@@ -158,18 +163,18 @@ function SortableNoteItem({
|
|||||||
onClick={handleToggleFavorite}
|
onClick={handleToggleFavorite}
|
||||||
disabled={isPending}
|
disabled={isPending}
|
||||||
className={`p-1 rounded-md transition-colors ${
|
className={`p-1 rounded-md transition-colors ${
|
||||||
note.isFavorite
|
note.isFavorite === true
|
||||||
? 'text-[var(--accent)] bg-[var(--accent)]/20'
|
? 'text-[var(--accent)] bg-[var(--accent)]/20'
|
||||||
: 'hover:bg-[var(--accent)]/20 text-[var(--muted-foreground)] hover:text-[var(--accent)]'
|
: 'hover:bg-[var(--accent)]/20 text-[var(--muted-foreground)] hover:text-[var(--accent)]'
|
||||||
}`}
|
}`}
|
||||||
title={
|
title={
|
||||||
note.isFavorite
|
note.isFavorite === true
|
||||||
? 'Retirer des favoris'
|
? 'Retirer des favoris'
|
||||||
: 'Ajouter aux favoris'
|
: 'Ajouter aux favoris'
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Star
|
<Star
|
||||||
className={`w-3 h-3 ${note.isFavorite ? 'fill-current' : ''}`}
|
className={`w-3 h-3 ${note.isFavorite === true ? 'fill-current' : ''}`}
|
||||||
/>
|
/>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
|
|||||||
Reference in New Issue
Block a user