diff --git a/src/services/community-admin.service.js b/src/services/community-admin.service.js index 9a71b83ea37b434e8b0f2a54bb74b077c72094f7..c935f1181ea5d8c81306dddae21a8015d95a8d9d 100644 --- a/src/services/community-admin.service.js +++ b/src/services/community-admin.service.js @@ -21,7 +21,8 @@ class CommunityAdminService { async acceptUserIntoCommunity(communityID, userID) { return await axios.post( API_URL + "communities/" + communityID + "/requests", - { params: { userId: userID } } + null, + { headers: tokenHeader(), params: { userId: userID } } ); } @@ -29,9 +30,8 @@ class CommunityAdminService { async rejectUserFromCommunity(communityID, userID) { return await axios.patch( API_URL + "communitites/" + communityID + "/requests/reject", - { - params: { userId: userID }, - } + null, + { headers: tokenHeader(), params: { userId: userID } } ); } diff --git a/src/services/community.service.js b/src/services/community.service.js index d2bf0954527324357777de183dda46891b321418..11bc85817db76d285c028434a7e8df2f64cc5f46 100644 --- a/src/services/community.service.js +++ b/src/services/community.service.js @@ -17,9 +17,24 @@ class CommunityService { }); } - async getPublicCommunities() { + async getAllCommunities() { return await axios - .get(API_URL + "communities") + .get(API_URL + "communities", { + headers: tokenHeader(), + }) + .then((response) => { + return response.data; + }) + .catch((error) => { + console.error(error); + }); + } + + async getUserCommunities() { + return await axios + .get(API_URL + "user/communities", { + headers: tokenHeader(), + }) .then((response) => { return response.data; }) diff --git a/src/views/CommunityViews/CommunityView.vue b/src/views/CommunityViews/CommunityView.vue index 69005196841e3efcdcc9acc14fa3d4440cff733c..bd7b2ea53207acf14628dc4aff86c896d12c275b 100644 --- a/src/views/CommunityViews/CommunityView.vue +++ b/src/views/CommunityViews/CommunityView.vue @@ -68,9 +68,9 @@ <script> import CommunityList from "@/components/CommunityComponents/CommunityList.vue"; -import { getMyGroups, getVisibleGroups } from "@/utils/apiutil"; import { UserAddIcon, SearchIcon } from "@heroicons/vue/outline"; import PaginationTemplate from "@/components/BaseComponents/PaginationTemplate"; +import CommunityService from "@/services/community.service"; export default { name: "HomeView", @@ -153,10 +153,10 @@ export default { this.showSearched = this.search.length > 0; }, async load() { - this.publicCommunities = await getVisibleGroups(); + this.publicCommunities = await CommunityService.getAllCommunities(); this.loggedIn = this.$store.state.user.token !== null; if (!this.loggedIn) return; - this.myCommunities = await getMyGroups(); + this.myCommunities = await CommunityService.getUserCommunities(); }, }, async mounted() {