diff --git a/src/components/CommunityComponents/CommunityListItem.vue b/src/components/CommunityComponents/CommunityListItem.vue index f260d3b475014d6c247a12b73543f8364a9801ba..1dc94f4e3421de11b7367b51ad8c12eae11a242b 100644 --- a/src/components/CommunityComponents/CommunityListItem.vue +++ b/src/components/CommunityComponents/CommunityListItem.vue @@ -8,20 +8,19 @@ <div class="flex justify-center p-2"> <!-- If a user is not a member in the community, this button will show --> <ColoredButton - v-if="!member && community.visibility!==0" + v-if="!member && community.visibility !== 0" :text="'Bli med'" @click="goToJoin(community.communityId)" class="m-2" /> - <ColoredButton - v-if="!member && community.visibility===0" + <ColoredButton + v-if="!member && community.visibility === 0" :text="'Spør om å bli med'" @click="goToRequest(community.communityId)" class="m-2" - /> + /> - <!-- If a user is member this button will show --> <ColoredButton v-if="member" @@ -104,8 +103,8 @@ export default { this.$router.push("/community/" + id); } }, - goToRequest(id){ - this.$router.push("/community/" + id + "/private/join") + goToRequest(id) { + this.$router.push("/community/" + id + "/private/join"); }, toggleDialog() { this.dialogOpen = !this.dialogOpen; diff --git a/src/components/CommunityComponents/CommunityRequestForm.vue b/src/components/CommunityComponents/CommunityRequestForm.vue index d0b58ae3aab0a895f1444060ba7b0d36653ce313..51a2e418c064f125ea349ae9141ba96f4c12b025 100644 --- a/src/components/CommunityComponents/CommunityRequestForm.vue +++ b/src/components/CommunityComponents/CommunityRequestForm.vue @@ -6,17 +6,17 @@ <div class="text-xl md:text-2xl font-medium text-center text-gray-600 dark:text-gray-200 mt-4 mb-10" > - Bli med i: {{community.name}} + Bli med i: {{ community.name }} </div> - <!-- message --> <div class="mt-6" :class="{ error: v$.message.$errors.length }"> <label class="block mb-2 text-sm font-medium text-gray-900 dark:text-gray-400" id="messageLabel" - > Melding til administrator av gruppa: </label > + Melding til administrator av gruppa: + </label> <textarea id="message" rows="4" @@ -49,8 +49,8 @@ import axios from "axios"; import useVuelidate from "@vuelidate/core"; import { required, helpers, maxLength } from "@vuelidate/validators"; import Button from "@/components/BaseComponents/ColoredButton"; -import {tokenHeader} from "@/utils/token-utils"; -import {GetCommunity} from "@/utils/apiutil"; +import { tokenHeader } from "@/utils/token-utils"; +import { GetCommunity } from "@/utils/apiutil"; export default { name: "CommunityRequestForm.vue", @@ -64,45 +64,48 @@ export default { validations() { return { - message: { - required: helpers.withMessage( - () => "Meldingen kan ikke være tom", - required - ), - max: helpers.withMessage( - () => `Meldingen kan inneholde max 200 tegn`, - maxLength(200) - ), - }, - + message: { + required: helpers.withMessage( + () => "Meldingen kan ikke være tom", + required + ), + max: helpers.withMessage( + () => `Meldingen kan inneholde max 200 tegn`, + maxLength(200) + ), + }, }; }, data() { return { - message: "", - communityId: null, - community: {}, + message: "", + communityId: null, + community: {}, }; }, - computed: { - }, + computed: {}, methods: { //TODO fix so that community id is set (not null) async saveClicked() { - this.communityID = await this.$router.currentRoute.value.params + this.communityID = await this.$router.currentRoute.value.params .communityID; - await axios.post(process.env.VUE_APP_BASEURL+ `communities/${this.communityID}/private/join`, {message: this.message, }, {headers: tokenHeader()} ); + await axios.post( + process.env.VUE_APP_BASEURL + + `communities/${this.communityID}/private/join`, + { message: this.message }, + { headers: tokenHeader() } + ); }, - getCommunityFromAPI: async function () { + getCommunityFromAPI: async function () { this.communityID = await this.$router.currentRoute.value.params .communityID; - console.log("Dette er community id =" + this.communityID) + console.log("Dette er community id =" + this.communityID); this.community = await GetCommunity(this.communityID); - console.log(this.community) - } + console.log(this.community); + }, }, - async created() { + async created() { await this.getCommunityFromAPI(); //To get the id of the community before mounting the view }, }; diff --git a/src/utils/apiutil.js b/src/utils/apiutil.js index 072f0a0b0e68d7ef5ac68038b21a1690cbf0ca16..f42879c400cc016c5c782c18813a46739f704fd9 100644 --- a/src/utils/apiutil.js +++ b/src/utils/apiutil.js @@ -222,8 +222,6 @@ export async function GetListingsInCommunity(communityID) { }); } - - export async function GetMembersOfCommunity(communityID) { return axios .get(API_URL + "community/" + communityID + "/members", {