diff --git a/composables/note.ts b/composables/note.ts index bcad8b5..bfd6033 100644 --- a/composables/note.ts +++ b/composables/note.ts @@ -1,4 +1,4 @@ -export const submitNote = async ( +const submitNote = async ( note: Note, query: NoteQuery ): Promise => { @@ -20,3 +20,8 @@ export const submitNote = async ( return response } + +const useNote = () => + useState('note', () => Object({ title: '', description: '' })) + +export { submitNote, useNote } diff --git a/pages/notes/[id].vue b/pages/notes/[id].vue index 44413d3..80f48d7 100644 --- a/pages/notes/[id].vue +++ b/pages/notes/[id].vue @@ -56,10 +56,7 @@ type Comp = 'text' | 'md' - const note = reactive({ - title: '', - description: '', - }) + const note = useNote() const route = useRoute() const router = useRouter() const isLoading = ref(false) @@ -83,8 +80,8 @@ router.push('/notes') return } - note.title = response._data.note.title - note.description = response._data.note.description + note.value.title = response._data.note.title + note.value.description = response._data.note.description }, })