Skip to content
Snippets Groups Projects
Commit d5b71388 authored by Håkon Eilertsen Røskaft's avatar Håkon Eilertsen Røskaft
Browse files

Merge branch 'main' of...

Merge branch 'main' of https://gitlab.stud.idi.ntnu.no/idatt2106_2022_02/boco-frontend into change-password
parents 5dec4a17 2a5a5d21
No related branches found
No related tags found
1 merge request!92Change password 2
Pipeline #180414 passed
...@@ -21,7 +21,8 @@ class CommunityAdminService { ...@@ -21,7 +21,8 @@ class CommunityAdminService {
async acceptUserIntoCommunity(communityID, userID) { async acceptUserIntoCommunity(communityID, userID) {
return await axios.post( return await axios.post(
API_URL + "communities/" + communityID + "/requests", API_URL + "communities/" + communityID + "/requests",
{ params: { userId: userID } } null,
{ headers: tokenHeader(), params: { userId: userID } }
); );
} }
...@@ -29,9 +30,8 @@ class CommunityAdminService { ...@@ -29,9 +30,8 @@ class CommunityAdminService {
async rejectUserFromCommunity(communityID, userID) { async rejectUserFromCommunity(communityID, userID) {
return await axios.patch( return await axios.patch(
API_URL + "communitites/" + communityID + "/requests/reject", API_URL + "communitites/" + communityID + "/requests/reject",
{ null,
params: { userId: userID }, { headers: tokenHeader(), params: { userId: userID } }
}
); );
} }
......
...@@ -17,9 +17,24 @@ class CommunityService { ...@@ -17,9 +17,24 @@ class CommunityService {
}); });
} }
async getPublicCommunities() { async getAllCommunities() {
return await axios 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) => { .then((response) => {
return response.data; return response.data;
}) })
......
...@@ -68,9 +68,9 @@ ...@@ -68,9 +68,9 @@
<script> <script>
import CommunityList from "@/components/CommunityComponents/CommunityList.vue"; import CommunityList from "@/components/CommunityComponents/CommunityList.vue";
import { getMyGroups, getVisibleGroups } from "@/utils/apiutil";
import { UserAddIcon, SearchIcon } from "@heroicons/vue/outline"; import { UserAddIcon, SearchIcon } from "@heroicons/vue/outline";
import PaginationTemplate from "@/components/BaseComponents/PaginationTemplate"; import PaginationTemplate from "@/components/BaseComponents/PaginationTemplate";
import CommunityService from "@/services/community.service";
export default { export default {
name: "HomeView", name: "HomeView",
...@@ -153,10 +153,10 @@ export default { ...@@ -153,10 +153,10 @@ export default {
this.showSearched = this.search.length > 0; this.showSearched = this.search.length > 0;
}, },
async load() { async load() {
this.publicCommunities = await getVisibleGroups(); this.publicCommunities = await CommunityService.getAllCommunities();
this.loggedIn = this.$store.state.user.token !== null; this.loggedIn = this.$store.state.user.token !== null;
if (!this.loggedIn) return; if (!this.loggedIn) return;
this.myCommunities = await getMyGroups(); this.myCommunities = await CommunityService.getUserCommunities();
}, },
}, },
async mounted() { async mounted() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment