diff --git a/src/components/CategoriesTable.vue b/src/components/CategoriesTable.vue
index 1eb919c..cdc6964 100644
--- a/src/components/CategoriesTable.vue
+++ b/src/components/CategoriesTable.vue
@@ -1,9 +1,37 @@
@@ -14,13 +42,23 @@ const props = defineProps<{
]"
:items="props.fetchedCategories?.categories"
>
-
+
-
+
+
+
+
+
+ Are you sure you want to delete the
+ {{ deleteDialogCategory?.name }} category?
+
+
+
+
+
+
+
+
diff --git a/src/components/CategoryCreate.vue b/src/components/CategoryCreate.vue
index e1db1c5..fbc502f 100644
--- a/src/components/CategoryCreate.vue
+++ b/src/components/CategoryCreate.vue
@@ -24,6 +24,7 @@ async function onSubmit(): Promise {
const createdCategory: { id: number } = await createdCategoryPromise.json()
emit('categoryCreated', createdCategory.id)
dialog.value = false
+ name.value = ''
}
@@ -50,9 +51,9 @@ async function onSubmit(): Promise {
required
>
-
+
-
+
{
})
}
- return { getCategories, postCategory }
+ const deleteCategory = async (id: number): Promise => {
+ return await fetch(`${api.url}/category/${id}`, {
+ ...api.options,
+ method: 'DELETE'
+ })
+ }
+
+ return { getCategories, postCategory, deleteCategory }
})
diff --git a/src/views/CategoriesView.vue b/src/views/CategoriesView.vue
index def74b0..f0a57b7 100644
--- a/src/views/CategoriesView.vue
+++ b/src/views/CategoriesView.vue
@@ -13,7 +13,9 @@ async function updateCategories() {
fetchedCategories.value = await categoriesPromise.json()
}
-onMounted(updateCategories)
+onMounted(async () => {
+ await updateCategories()
+})
@@ -21,5 +23,5 @@ onMounted(updateCategories)
Categories
-
+