mirror of
https://github.com/Floriansylvain/snippets-manager-front.git
synced 2026-08-19 19:53:17 +02:00
26 lines
865 B
Vue
26 lines
865 B
Vue
<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>
|
|
<CategoryCreate @categoryCreated="updateCategories" />
|
|
</header>
|
|
<CategoriesTable :fetched-categories="fetchedCategories" />
|
|
</template>
|