fix(ui): sélection groupée dans la boîte de réception
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:
@@ -1,7 +1,7 @@
|
||||
'use client'
|
||||
|
||||
import { toast } from 'sonner'
|
||||
import { restoreNote } from '@/app/actions/notes'
|
||||
import { restoreNote, restoreNotes } from '@/app/actions/notes'
|
||||
import { emitNoteChange } from '@/lib/note-change-sync'
|
||||
import type { Note } from '@/lib/types'
|
||||
|
||||
@@ -27,3 +27,31 @@ export function showNoteTrashedToast(
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function showNotesTrashedToast(
|
||||
notes: Note[],
|
||||
t: (key: string, params?: Record<string, string | number>) => string,
|
||||
onRestored?: () => void,
|
||||
) {
|
||||
if (notes.length === 1) {
|
||||
showNoteTrashedToast(notes[0], t, onRestored)
|
||||
return
|
||||
}
|
||||
toast.success(t('notes.bulkTrashedToast', { count: notes.length }), {
|
||||
action: {
|
||||
label: t('notes.undoDelete'),
|
||||
onClick: async () => {
|
||||
try {
|
||||
await restoreNotes(notes.map((note) => note.id), { skipRevalidation: true })
|
||||
for (const note of notes) {
|
||||
emitNoteChange({ type: 'created', note: { ...note, trashedAt: null } })
|
||||
}
|
||||
onRestored?.()
|
||||
toast.success(t('trash.noteRestored'))
|
||||
} catch {
|
||||
toast.error(t('general.error'))
|
||||
}
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user