initial commit
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
<script setup lang="ts">
|
||||
import type { FormSubmitEvent } from '@nuxt/ui'
|
||||
|
||||
const emit = defineEmits<{ saved: [] }>()
|
||||
|
||||
const state = reactive({ date: todayIso(), text: '' })
|
||||
const { saving, save } = useSaveEntry({ url: '/api/notes', dataKey: 'notes', noun: 'note', onSaved: () => emit('saved') })
|
||||
|
||||
function onSubmit(event: FormSubmitEvent<NewNoteInput>) {
|
||||
return save(event.data)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<UForm :schema="newNoteSchema" :state="state" class="space-y-5" @submit="onSubmit">
|
||||
<UFormField label="Date" name="date" required>
|
||||
<UInput v-model="state.date" type="date" />
|
||||
</UFormField>
|
||||
|
||||
<UFormField label="Note" name="text" required>
|
||||
<UTextarea v-model="state.text" :rows="8" autoresize :maxrows="18" class="w-full" autofocus />
|
||||
</UFormField>
|
||||
|
||||
<UButton type="submit" label="Save note" :icon="NOTE_ICON" :loading="saving" />
|
||||
</UForm>
|
||||
</template>
|
||||
Reference in New Issue
Block a user