Added useNote state in composable

main
TZGyn 3 years ago
parent 9f2550fcac
commit a0034ac4f5

@ -1,4 +1,4 @@
export const submitNote = async ( const submitNote = async (
note: Note, note: Note,
query: NoteQuery query: NoteQuery
): Promise<ApiResponse> => { ): Promise<ApiResponse> => {
@ -20,3 +20,8 @@ export const submitNote = async (
return response return response
} }
const useNote = () =>
useState<Note>('note', () => Object({ title: '', description: '' }))
export { submitNote, useNote }

@ -56,10 +56,7 @@
type Comp = 'text' | 'md' type Comp = 'text' | 'md'
const note = reactive<Note>({ const note = useNote()
title: '',
description: '',
})
const route = useRoute() const route = useRoute()
const router = useRouter() const router = useRouter()
const isLoading = ref<Boolean>(false) const isLoading = ref<Boolean>(false)
@ -83,8 +80,8 @@
router.push('/notes') router.push('/notes')
return return
} }
note.title = response._data.note.title note.value.title = response._data.note.title
note.description = response._data.note.description note.value.description = response._data.note.description
}, },
}) })

Loading…
Cancel
Save