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

@@ -721,6 +721,41 @@ export async function updateNote(id: string, data: {
}
}
const MAX_BULK_MOVE = 200
export async function bulkMoveNotes(
ids: string[],
notebookId: string,
options?: { skipRevalidation?: boolean },
) {
const session = await auth()
if (!session?.user?.id) throw new Error('Unauthorized')
const unique = [...new Set(ids.filter((id) => typeof id === 'string' && id.length > 0))].slice(0, MAX_BULK_MOVE)
if (unique.length === 0) return { success: true, count: 0 }
const notebook = await prisma.notebook.findFirst({
where: { id: notebookId, userId: session.user.id, trashedAt: null },
select: { id: true },
})
if (!notebook) throw new Error('Notebook not found')
try {
const result = await prisma.note.updateMany({
where: { id: { in: unique }, userId: session.user.id, trashedAt: null },
data: { notebookId },
})
if (!options?.skipRevalidation) {
revalidatePath('/home')
revalidatePath(`/notebook/${notebookId}`)
}
return { success: true, count: result.count }
} catch (error) {
console.error('Error bulk-moving notes:', error)
throw new Error('Failed to move notes')
}
}
// Toggle functions
export async function togglePin(
id: string,
@@ -1169,6 +1204,8 @@ import {
deleteNote as _deleteNote,
trashNote as _trashNote,
restoreNote as _restoreNote,
bulkTrashNotes as _bulkTrashNotes,
restoreNotes as _restoreNotes,
getTrashedNotes as _getTrashedNotes,
permanentDeleteNote as _permanentDeleteNote,
emptyTrash as _emptyTrash,
@@ -1202,6 +1239,8 @@ export async function enableNoteHistory(...args: Parameters<typeof _enableNoteHi
export async function deleteNote(...args: Parameters<typeof _deleteNote>) { return _deleteNote(...args) }
export async function trashNote(...args: Parameters<typeof _trashNote>) { return _trashNote(...args) }
export async function restoreNote(...args: Parameters<typeof _restoreNote>) { return _restoreNote(...args) }
export async function bulkTrashNotes(...args: Parameters<typeof _bulkTrashNotes>) { return _bulkTrashNotes(...args) }
export async function restoreNotes(...args: Parameters<typeof _restoreNotes>) { return _restoreNotes(...args) }
export async function getTrashedNotes(...args: Parameters<typeof _getTrashedNotes>) { return _getTrashedNotes(...args) }
export async function permanentDeleteNote(...args: Parameters<typeof _permanentDeleteNote>) { return _permanentDeleteNote(...args) }
export async function emptyTrash(...args: Parameters<typeof _emptyTrash>) { return _emptyTrash(...args) }