feat: category creation

This commit is contained in:
Florian Sylvain
2024-10-10 22:26:54 +02:00
parent 81bc46ebfa
commit ec9bc1bb4b
7 changed files with 121 additions and 39 deletions
+16 -2
View File
@@ -1,11 +1,25 @@
<script setup lang="ts">
import CategoriesTable from '@/components/CategoriesTable.vue'
import CategoryCreate from '@/components/CategoryCreate.vue'
import type { Category } from '@/composables/category'
import { useCategoriesStore } from '@/stores/categories'
import { onMounted, ref, type Ref } from 'vue'
const categoriesStore = useCategoriesStore()
const fetchedCategories: Ref<Category | undefined> = ref()
async function updateCategories() {
const categoriesPromise = await categoriesStore.getCategories()
fetchedCategories.value = await categoriesPromise.json()
}
onMounted(updateCategories)
</script>
<template>
<header class="d-flex align-center justify-space-between">
<h1 class="text-h3">Categories</h1>
<VBtn prepend-icon="mdi-plus" variant="flat" color="primary">Create category</VBtn>
<CategoryCreate @categoryCreated="updateCategories" />
</header>
<CategoriesTable />
<CategoriesTable :fetched-categories="fetchedCategories" />
</template>