mirror of
https://github.com/Floriansylvain/snippets-manager-front.git
synced 2026-08-20 03:53:38 +02:00
feat: category creation
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user