diff --git a/frontend/src/components/admin/category/AdminCategoryListComponent.vue b/frontend/src/components/admin/category/AdminCategoryListComponent.vue index 9d1c491..d09fe4f 100644 --- a/frontend/src/components/admin/category/AdminCategoryListComponent.vue +++ b/frontend/src/components/admin/category/AdminCategoryListComponent.vue @@ -13,20 +13,20 @@ - + {{ index + 1 }} - {{ category.title }} - {{ category.description }} + {{ cat.title }} + {{ cat.description }} -
Upload Icon
@@ -50,9 +50,6 @@ export default { name: "AdminCategoryListComponent", components: { }, - computed: { - ...mapState('category', ['categories']) - }, setup() { }, data() { return { @@ -60,6 +57,14 @@ export default { categoryList: [], } }, + // computed: { + // ...mapState('category', { + // categoryList: 'categories' + // }) + // }, + computed: { + ...mapState('category', ['categories']) + }, methods: { ...mapActions('category', ['fetchCategories']), }, diff --git a/frontend/src/services/adminCategoryAPI.js b/frontend/src/services/adminCategoryAPI.js index 8e55274..313f649 100644 --- a/frontend/src/services/adminCategoryAPI.js +++ b/frontend/src/services/adminCategoryAPI.js @@ -43,22 +43,35 @@ apiClient.interceptors.response.use( } ); -export default { - getCategoriesForAdmin() { - return apiClient.get('/api/v1/categories/'); - }, - - createCategoryForAdmin(categoryData) { - return apiClient.post('/api/v1/categories/', categoryData, { - headers: { - 'Content-Type': 'multipart/form-data' - } - }); - }, +export const getCategoriesForAdmin = () => { + // return axios.get(`${API_URL}/categories`); + return apiClient.get("/api/v1/categories/"); +}; - deleteCategoryForAdmin(category_id) { - return apiClient.delete(`/api/v1/categories/${category_id}`); - }, +export const createCategoryForAdmin = (categoryData) => { + return apiClient.post('/api/v1/categories/', categoryData, { + headers: { + 'Content-Type': 'multipart/form-data' + } + }); +}; + +export const deleteCategoryForAdmin = (category_id) => { + return apiClient.delete(`/api/v1/categories/${category_id}`); +}; + +export default { + // createCategoryForAdmin(categoryData) { + // return apiClient.post('/api/v1/categories/', categoryData, { + // headers: { + // 'Content-Type': 'multipart/form-data' + // } + // }); + // }, + + // deleteCategoryForAdmin(category_id) { + // return apiClient.delete(`/api/v1/categories/${category_id}`); + // }, updateCategoryForAdmin(category_id, categoryData) { return apiClient.put(`/api/v1/categories/${category_id}`, categoryData, { diff --git a/frontend/src/store/modules/category.js b/frontend/src/store/modules/category.js index c7506ff..e13b45c 100644 --- a/frontend/src/store/modules/category.js +++ b/frontend/src/store/modules/category.js @@ -22,7 +22,9 @@ const mutations = { const actions = { async fetchCategories({ commit }) { + console.log('Hello'); const response = await getCategoriesForAdmin(); + console.log(response.data); commit("setCategories", response.data); }, @@ -42,8 +44,9 @@ const getters = { }; export default { - state, - mutations, - actions, - getters, + namespaced: true, + state, + mutations, + actions, + getters, }; \ No newline at end of file