feat(notes): return to list after saving a note

This commit is contained in:
devcodetools committed 2026-09-13 16:31:43 +02:00
1 parent c52705ca01
commit 37ace9cab2
3 files changed
+12 -8

No files matched your search

+8 -3
View File
@@ -1,4 +1,5 @@
import { useState } from 'react'
import type { Note } from './types'
import { useNotes } from './hooks/useNotes'
import NoteList from './components/NoteList'
import NoteEditor from './components/NoteEditor'
@@ -16,9 +17,13 @@ function App() {
const cancelCreate = () => setCreating(false)
const handleCreate = (title: string, content: string) => {
const note = addNote(title, content)
addNote(title, content)
setCreating(false)
setSelectedId(note.id)
}
const handleUpdate = (id: number, patch: Partial<Pick<Note, 'title' | 'content'>>) => {
updateNote(id, patch)
setSelectedId(null)
}
const handleDelete = (id: number) => {
@@ -64,7 +69,7 @@ function App() {
key={selectedNote.id}
mode="edit"
note={selectedNote}
onUpdate={updateNote}
onUpdate={handleUpdate}
onDelete={handleDelete}
/>
) : (