From 1d1d048428bc8f4b90dfd29608887e0b940ab106 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Mon, 6 Nov 2023 11:39:38 -0500 Subject: [PATCH] Page: Refactor pagecategory service to use axios instead of vuex store --- assets/vue/components/page/Form.vue | 8 +++----- assets/vue/main.js | 8 -------- assets/vue/services/pageCategoryService.js | 10 ++++++++++ assets/vue/services/pagecategory.js | 3 --- 4 files changed, 13 insertions(+), 16 deletions(-) create mode 100644 assets/vue/services/pageCategoryService.js delete mode 100644 assets/vue/services/pagecategory.js diff --git a/assets/vue/components/page/Form.vue b/assets/vue/components/page/Form.vue index 6bbfdf2e57..b89e7392b0 100644 --- a/assets/vue/components/page/Form.vue +++ b/assets/vue/components/page/Form.vue @@ -122,6 +122,7 @@ import useVuelidate from '@vuelidate/core'; import { required } from '@vuelidate/validators'; import isEmpty from 'lodash/isEmpty'; import { useI18n } from 'vue-i18n'; +import pageCategoryService from "../../services/pageCategoryService" const props = defineProps({ modelValue: { @@ -143,12 +144,9 @@ let locales = ref([]); let categories = ref([]); locales.value = window.languages.map(locale => locale.isocode); -store.dispatch('pagecategory/findAll') - .then((response) => { - categories.value = response.map(data => data); - }); +const findAllPageCategories = async () => categories.value = await pageCategoryService.findAll() -const currentUser = computed(() => store.getters['security/getUser']); +findAllPageCategories() watch( () => props.modelValue, diff --git a/assets/vue/main.js b/assets/vue/main.js index 2fb69fde98..8d182c597d 100644 --- a/assets/vue/main.js +++ b/assets/vue/main.js @@ -23,7 +23,6 @@ import userRelUserService from "./services/userreluser" import calendarEventService from "./services/ccalendarevent" import toolIntroService from "./services/ctoolintro" import pageService from "./services/page" -import pageCategoryService from "./services/pagecategory" import sessionService from "./services/session" import socialPostService from "./services/socialpost" @@ -102,13 +101,6 @@ store.registerModule( }), ) -store.registerModule( - "pagecategory", - makeCrudModule({ - service: pageCategoryService, - }), -) - store.registerModule( "session", makeCrudModule({ diff --git a/assets/vue/services/pageCategoryService.js b/assets/vue/services/pageCategoryService.js new file mode 100644 index 0000000000..66f2dfd757 --- /dev/null +++ b/assets/vue/services/pageCategoryService.js @@ -0,0 +1,10 @@ +import {ENTRYPOINT} from "../config/entrypoint" +import axios from "axios" + +export default { + findAll: async () => { + const response = await axios.get(ENTRYPOINT + 'page_categories') + + return response.data['hydra:member'] + }, +} diff --git a/assets/vue/services/pagecategory.js b/assets/vue/services/pagecategory.js deleted file mode 100644 index 929b6ea9c9..0000000000 --- a/assets/vue/services/pagecategory.js +++ /dev/null @@ -1,3 +0,0 @@ -import makeService from './api'; - -export default makeService('page_categories');