diff --git a/src/services/community-admin.service.js b/src/services/community-admin.service.js index 81f1581dd2f2903fe609a4ee41a62fdc1b7c900e..af9b685bbbde1b7f7760b60d6c08f6d349744293 100644 --- a/src/services/community-admin.service.js +++ b/src/services/community-admin.service.js @@ -7,41 +7,54 @@ const API_URL = process.env.VUE_APP_BASEURL; * Service class acting as a middle layer between our components and the API */ class CommunityAdminService { - async isUserAdmin() { + async isUserAdmin(communityID) { return await axios - .get( - API_URL + - "communities/" + - this.$route.params.communityID + - "/user/admin", - { - headers: tokenHeader(), - } - ) + .get(API_URL + "communities/" + communityID + "/user/admin", { + headers: tokenHeader(), + }) .then((res) => { return res.data; }); } //TODO - acceptUserIntoCommunity() {} + async acceptUserIntoCommunity(communityID, userID) { + return await axios.post( + API_URL + "communities/" + communityID + "/requests", + { params: { userId: userID } } + ); + } //TODO - rejectUserFromCommunity() {} + async rejectUserFromCommunity(communityID, userID) { + return await axios.patch( + API_URL + "communitites/" + communityID + "/requests/reject", + { + params: { userId: userID }, + } + ); + } - //TODO - async removeUserFromCommunity(user, community) { - return await axios.post(API_URL + "communities/" + community.id + "/leave"); + /** + * Method that kicks a user from a community + * @param {int} communityID the community to remove the user from + * @param {int} userID the user to remove + * @returns TODO + */ + async removeUserFromCommunity(communityID, userID) { + return await axios.patch(API_URL + "communities/" + communityID + "/kick", { + params: { userId: userID }, + }); } /** * Method to delete a community - * @param {int} communityId id of the community to delete. + * @param {int} communityID id of the community to delete. * @returns TODO */ - async deleteCommunity(communityId) { + async deleteCommunity(communityID) { return await axios.post( - API_URL + "communities/" + communityId + "/remove", + API_URL + "communities/" + communityID + "/remove", { headers: tokenHeader(), }