fix(ui): sélection groupée dans la boîte de réception
All checks were successful
CI / Lint, Unit Tests & Build (push) Successful in 7m17s
CI / Deploy production (on server) (push) Successful in 24s

Permet de cocher plusieurs notes, les déplacer vers un carnet ou les envoyer à la corbeille, et rend la carte mentale plus lisible.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Antigravity
2026-09-01 19:40:10 +00:00
parent 4fc5e3ce04
commit a7b16870a4
15 changed files with 509 additions and 37 deletions

View File

@@ -64,6 +64,57 @@ export async function restoreNote(id: string) {
}
}
const MAX_BULK_NOTES = 200
function uniqueNoteIds(ids: string[]) {
return [...new Set(ids.filter((id) => typeof id === 'string' && id.length > 0))].slice(0, MAX_BULK_NOTES)
}
export async function bulkTrashNotes(ids: string[], options?: { skipRevalidation?: boolean }) {
const session = await auth()
if (!session?.user?.id) throw new Error('Unauthorized')
const unique = uniqueNoteIds(ids)
if (unique.length === 0) return { success: true, count: 0 }
try {
const result = await prisma.note.updateMany({
where: { id: { in: unique }, userId: session.user.id, trashedAt: null },
data: { trashedAt: new Date() },
})
if (!options?.skipRevalidation) {
revalidatePath('/home')
}
return { success: true, count: result.count }
} catch (error) {
console.error('Error bulk-trashing notes:', error)
throw new Error('Failed to trash notes')
}
}
export async function restoreNotes(ids: string[], options?: { skipRevalidation?: boolean }) {
const session = await auth()
if (!session?.user?.id) throw new Error('Unauthorized')
const unique = uniqueNoteIds(ids)
if (unique.length === 0) return { success: true, count: 0 }
try {
const result = await prisma.note.updateMany({
where: { id: { in: unique }, userId: session.user.id, trashedAt: { not: null } },
data: { trashedAt: null },
})
if (!options?.skipRevalidation) {
revalidatePath('/home')
revalidatePath('/trash')
}
return { success: true, count: result.count }
} catch (error) {
console.error('Error restoring notes:', error)
throw new Error('Failed to restore notes')
}
}
export async function getTrashedNotes() {
const session = await auth()
if (!session?.user?.id) return []