added title to notes

main
TZGyn 3 years ago
parent a7b95f79f9
commit 6a9078f0f0

@ -1,5 +1,8 @@
<template> <template>
<div class="app"> <div class="app">
<textarea
v-model="title"
class="titleTextArea" />
<button @click="submit()"> <button @click="submit()">
<Icon <Icon
name="fa6-solid:floppy-disk" name="fa6-solid:floppy-disk"
@ -16,6 +19,7 @@
middleware: ['auth'], middleware: ['auth'],
}); });
const title = ref<string>('');
const description = ref<string>(''); const description = ref<string>('');
const route = useRoute(); const route = useRoute();
const isLoading = ref<Boolean>(false); const isLoading = ref<Boolean>(false);
@ -27,6 +31,7 @@
id: route.params.id[0], id: route.params.id[0],
}, },
onResponse({ response }) { onResponse({ response }) {
title.value = response._data.note.title;
description.value = response._data.note.description; description.value = response._data.note.description;
console.log(response); console.log(response);
}, },
@ -40,6 +45,7 @@
id: route.params.id[0], id: route.params.id[0],
}, },
body: { body: {
title: title.value,
description: description.value, description: description.value,
}, },
onResponse({ response }) { onResponse({ response }) {
@ -60,4 +66,10 @@
.noteTextArea { .noteTextArea {
@apply h-full w-full max-w-2xl p-4; @apply h-full w-full max-w-2xl p-4;
} }
.titleTextArea {
@apply bg-primary focus:bg-secondary w-full max-w-2xl text-center;
}
.app {
@apply h-full p-4;
}
</style> </style>

@ -7,11 +7,12 @@ export default defineEventHandler(async (event) => {
const query = getQuery(event); const query = getQuery(event);
const body = await readBody(event); const body = await readBody(event);
const title: string = body.title;
const description: string = body.description; const description: string = body.description;
const { data: note, error } = await supabase const { data: note, error } = await supabase
.from('notes') .from('notes')
.update({ description: description }) .update({ title: title, description: description })
.eq('id', query.id); .eq('id', query.id);
if (!user) { if (!user) {

Loading…
Cancel
Save