Les boutons suivent la couleur d’apparence, les libellés trop petits ou trop techniques sont clarifiés, et le catalogue des fournisseurs se met à jour tout seul. Co-authored-by: Cursor <cursoragent@cursor.com>
30 lines
767 B
TypeScript
30 lines
767 B
TypeScript
'use client'
|
|
|
|
import { toast } from 'sonner'
|
|
import { restoreNote } from '@/app/actions/notes'
|
|
import { emitNoteChange } from '@/lib/note-change-sync'
|
|
import type { Note } from '@/lib/types'
|
|
|
|
export function showNoteTrashedToast(
|
|
note: Note,
|
|
t: (key: string) => string,
|
|
onRestored?: () => void,
|
|
) {
|
|
toast.success(t('notes.noteDeletedToast'), {
|
|
action: {
|
|
label: t('notes.undoDelete'),
|
|
onClick: async () => {
|
|
try {
|
|
await restoreNote(note.id)
|
|
const restored = { ...note, trashedAt: null }
|
|
emitNoteChange({ type: 'created', note: restored })
|
|
onRestored?.()
|
|
toast.success(t('trash.noteRestored'))
|
|
} catch {
|
|
toast.error(t('general.error'))
|
|
}
|
|
},
|
|
},
|
|
})
|
|
}
|