Add debug logging for note deletion
This commit is contained in:
13
src/App.tsx
13
src/App.tsx
@@ -147,11 +147,20 @@ function App() {
|
||||
};
|
||||
|
||||
const handleDeleteNote = async (note: Note) => {
|
||||
if (!api) return;
|
||||
if (!confirm(`Delete "${note.title}"?`)) return;
|
||||
console.log('handleDeleteNote called for note:', note.id, note.title);
|
||||
if (!api) {
|
||||
console.log('No API instance');
|
||||
return;
|
||||
}
|
||||
|
||||
const confirmed = confirm(`Delete "${note.title}"?`);
|
||||
console.log('User confirmed deletion:', confirmed);
|
||||
if (!confirmed) return;
|
||||
|
||||
try {
|
||||
console.log('Calling API deleteNote...');
|
||||
await api.deleteNote(note.id);
|
||||
console.log('Note deleted successfully, updating state...');
|
||||
setNotes(notes.filter(n => n.id !== note.id));
|
||||
if (selectedNoteId === note.id) {
|
||||
setSelectedNoteId(notes[0]?.id || null);
|
||||
|
||||
@@ -146,7 +146,9 @@ export function NotesList({
|
||||
</div>
|
||||
<button
|
||||
onClick={(e) => {
|
||||
console.log('Delete button clicked for note:', note.id);
|
||||
e.stopPropagation();
|
||||
console.log('Calling onDeleteNote...');
|
||||
onDeleteNote(note);
|
||||
}}
|
||||
className="ml-2 p-1 hover:bg-red-100 dark:hover:bg-red-900/30 rounded text-red-600 dark:text-red-400 opacity-0 group-hover:opacity-100 transition-opacity"
|
||||
|
||||
Reference in New Issue
Block a user