2021-08-08 20:52:44 -08:00
|
|
|
<template>
|
2021-12-10 19:48:06 -09:00
|
|
|
<v-container>
|
2022-04-20 20:09:23 +02:00
|
|
|
<RecipeCategoryTagToolPage v-if="categories" :items="categories" item-type="categories" @delete="removeCat" />
|
2021-08-08 20:52:44 -08:00
|
|
|
</v-container>
|
|
|
|
</template>
|
2021-12-10 19:48:06 -09:00
|
|
|
|
2021-08-08 20:52:44 -08:00
|
|
|
<script lang="ts">
|
2021-12-10 19:48:06 -09:00
|
|
|
import { defineComponent, useAsync } from "@nuxtjs/composition-api";
|
|
|
|
import RecipeCategoryTagToolPage from "~/components/Domain/Recipe/RecipeCategoryTagToolPage.vue";
|
2021-11-06 11:28:47 -08:00
|
|
|
import { useUserApi } from "~/composables/api";
|
2022-04-20 20:09:23 +02:00
|
|
|
import { useAsyncKey } from "~/composables/use-utils";
|
2021-08-08 20:52:44 -08:00
|
|
|
|
|
|
|
export default defineComponent({
|
2021-12-10 19:48:06 -09:00
|
|
|
components: {
|
|
|
|
RecipeCategoryTagToolPage,
|
|
|
|
},
|
2021-08-08 20:52:44 -08:00
|
|
|
setup() {
|
2021-12-10 19:48:06 -09:00
|
|
|
const userApi = useUserApi();
|
2021-08-08 20:52:44 -08:00
|
|
|
const categories = useAsync(async () => {
|
2021-12-10 19:48:06 -09:00
|
|
|
const { data } = await userApi.categories.getAll();
|
2021-09-04 20:24:32 -08:00
|
|
|
|
2021-12-10 19:48:06 -09:00
|
|
|
if (data) {
|
|
|
|
return data;
|
|
|
|
}
|
2022-04-20 20:09:23 +02:00
|
|
|
}, useAsyncKey());
|
|
|
|
|
|
|
|
function removeCat(id: string) {
|
|
|
|
if (categories.value) {
|
|
|
|
for (let i = 0; i < categories.value.length; i++) {
|
|
|
|
if (categories.value[i].id === id) {
|
|
|
|
categories.value.splice(i, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-09-04 20:24:32 -08:00
|
|
|
|
2021-10-07 09:39:47 -08:00
|
|
|
return {
|
2021-12-10 19:48:06 -09:00
|
|
|
categories,
|
2022-04-20 20:09:23 +02:00
|
|
|
removeCat,
|
2021-10-07 09:39:47 -08:00
|
|
|
};
|
|
|
|
},
|
2021-08-08 20:52:44 -08:00
|
|
|
});
|
2022-01-07 22:08:05 +01:00
|
|
|
</script>
|