diff --git a/src/components/BaseComponents/NavBar.vue b/src/components/BaseComponents/NavBar.vue index 58020e292abccaa07ac2e7cfa6d66f30961e42fc..3281cf2e521896053954387941ba03dc04c88281 100644 --- a/src/components/BaseComponents/NavBar.vue +++ b/src/components/BaseComponents/NavBar.vue @@ -38,12 +38,12 @@ <script> import { parseUserFromToken } from "@/utils/token-utils"; -import {PlusIcon, ChatAlt2Icon, UserCircleIcon} from "@heroicons/vue/outline"; +import { PlusIcon, ChatAlt2Icon, UserCircleIcon } from "@heroicons/vue/outline"; export default { name: "NavBar.vue", - components:{ + components: { PlusIcon, ChatAlt2Icon, UserCircleIcon, diff --git a/src/components/CommunityComponents/CommunityHamburger.vue b/src/components/CommunityComponents/CommunityHamburger.vue index 704b199bc9876af2f3a4e222d34269d2a33b4947..34c82b645697dce95fc6d42ce3e6ea75db622323 100644 --- a/src/components/CommunityComponents/CommunityHamburger.vue +++ b/src/components/CommunityComponents/CommunityHamburger.vue @@ -38,7 +38,6 @@ </template> <script> - import { LeaveCommunity } from "@/utils/apiutil"; export default { @@ -46,18 +45,18 @@ export default { props: { communityID: Number, }, - data(){ - return{ + data() { + return { id: -1, - } + }; }, - methods:{ - leaveCommunity: async function(){ + methods: { + leaveCommunity: async function () { this.id = await this.$router.currentRoute.value.params.communityID; await LeaveCommunity(this.id); - this.$router.push('/'); - } - } + this.$router.push("/"); + }, + }, }; </script> diff --git a/src/components/CommunityComponents/NewCommunityForm.vue b/src/components/CommunityComponents/NewCommunityForm.vue index 0a756fcd785cbaf623af7b4612d26ee63d1642d1..fa6652b28bec742c631b401028466820a9108106 100644 --- a/src/components/CommunityComponents/NewCommunityForm.vue +++ b/src/components/CommunityComponents/NewCommunityForm.vue @@ -1,5 +1,7 @@ <template> - <div class="md:ring-1 ring-gray-300 rounded-xl overflow-hidden mx-auto mb-auto max-w-md w-full p-4"> + <div + class="md:ring-1 ring-gray-300 rounded-xl overflow-hidden mx-auto mb-auto max-w-md w-full p-4" + > <!-- Component heading --> <div class="text-xl md:text-2xl font-medium text-center text-gray-600 dark:text-gray-200 mt-4 mb-10" @@ -10,41 +12,41 @@ <!-- Radio boxes --> <div class="mt-6"> <label - class="block mb-2 text-sm font-medium text-gray-900 dark:text-gray-300" - id="radioBoxLabel" - >Synlighet</label + class="block mb-2 text-sm font-medium text-gray-900 dark:text-gray-300" + id="radioBoxLabel" + >Synlighet</label > <div class="form-check"> <input - class="form-check-input appearance-none rounded-full h-4 w-4 border border-gray-300 bg-white checked:bg-primary-medium checked:border-primary-medium focus:outline-none transition duration-200 mt-1 align-top bg-no-repeat bg-center bg-contain float-left mr-2 cursor-pointer" - type="radio" - name="flexRadioDefault" - id="flexRadioOpen" - value="Åpen" - @change="checkRadioButton($event)" - checked + class="form-check-input appearance-none rounded-full h-4 w-4 border border-gray-300 bg-white checked:bg-primary-medium checked:border-primary-medium focus:outline-none transition duration-200 mt-1 align-top bg-no-repeat bg-center bg-contain float-left mr-2 cursor-pointer" + type="radio" + name="flexRadioDefault" + id="flexRadioOpen" + value="Åpen" + @change="checkRadioButton($event)" + checked /> <label - class="form-check-label inline-block text-gray-800" - for="flexRadioOpen" - id="radioBoxOpenLabel" + class="form-check-label inline-block text-gray-800" + for="flexRadioOpen" + id="radioBoxOpenLabel" > Åpen </label> </div> <div class="form-check"> <input - class="form-check-input appearance-none rounded-full h-4 w-4 border border-gray-300 bg-white checked:bg-primary-medium checked:border-primary-medium focus:outline-none transition duration-200 mt-1 align-top bg-no-repeat bg-center bg-contain float-left mr-2 cursor-pointer" - type="radio" - name="flexRadioDefault" - id="flexRadioPrivate" - value="Privat" - @change="checkRadioButton($event)" + class="form-check-input appearance-none rounded-full h-4 w-4 border border-gray-300 bg-white checked:bg-primary-medium checked:border-primary-medium focus:outline-none transition duration-200 mt-1 align-top bg-no-repeat bg-center bg-contain float-left mr-2 cursor-pointer" + type="radio" + name="flexRadioDefault" + id="flexRadioPrivate" + value="Privat" + @change="checkRadioButton($event)" /> <label - class="form-check-label inline-block text-gray-800" - for="flexRadioPrivate" - id="radioBoxPrivateLabel" + class="form-check-label inline-block text-gray-800" + for="flexRadioPrivate" + id="radioBoxPrivateLabel" > Privat </label> @@ -54,23 +56,23 @@ <!-- Title --> <div class="mt-6" :class="{ error: v$.group.name.$errors.length }"> <label - class="block mb-2 text-sm font-medium text-gray-900 dark:text-gray-300" - id="titleLabel" - >Gruppenavn</label + class="block mb-2 text-sm font-medium text-gray-900 dark:text-gray-300" + id="titleLabel" + >Gruppenavn</label > <input - type="text" - id="title" - class="block w-full px-4 py-2 mt-2 text-gray-700 placeholder-gray-500 bg-white border rounded-md dark:bg-gray-800 dark:border-gray-600 dark:placeholder-gray-400 focus:border-primary-light dark:focus:border-primary-light focus:ring-opacity-40 focus:outline-none focus:ring focus:ring-primary-light" - v-model="v$.group.name.$model" - required + type="text" + id="title" + class="block w-full px-4 py-2 mt-2 text-gray-700 placeholder-gray-500 bg-white border rounded-md dark:bg-gray-800 dark:border-gray-600 dark:placeholder-gray-400 focus:border-primary-light dark:focus:border-primary-light focus:ring-opacity-40 focus:outline-none focus:ring focus:ring-primary-light" + v-model="v$.group.name.$model" + required /> <!-- error message for title--> <div - class="text-error" - v-for="(error, index) of v$.group.name.$errors" - :key="index" + class="text-error" + v-for="(error, index) of v$.group.name.$errors" + :key="index" > <div class="text-error text-sm"> {{ error.$message }} @@ -81,22 +83,22 @@ <!-- Place --> <div class="mt-6" :class="{ error: v$.group.place.$errors.length }"> <label - class="block mb-2 text-sm font-medium text-gray-900 dark:text-gray-300" - id="positionLabel" - >By/Sted</label + class="block mb-2 text-sm font-medium text-gray-900 dark:text-gray-300" + id="positionLabel" + >By/Sted</label > <input - type="text" - class="block w-full px-4 py-2 mt-2 text-gray-700 placeholder-gray-500 bg-white border rounded-md dark:bg-gray-800 dark:border-gray-600 dark:placeholder-gray-400 focus:border-primary-light dark:focus:border-primary-light focus:ring-opacity-40 focus:outline-none focus:ring focus:ring-primary-light" - v-model="v$.group.place.$model" - required + type="text" + class="block w-full px-4 py-2 mt-2 text-gray-700 placeholder-gray-500 bg-white border rounded-md dark:bg-gray-800 dark:border-gray-600 dark:placeholder-gray-400 focus:border-primary-light dark:focus:border-primary-light focus:ring-opacity-40 focus:outline-none focus:ring focus:ring-primary-light" + v-model="v$.group.place.$model" + required /> <!-- error message for place--> <div - class="text-error" - v-for="(error, index) of v$.group.place.$errors" - :key="index" + class="text-error" + v-for="(error, index) of v$.group.place.$errors" + :key="index" > <div class="text-error text-sm"> {{ error.$message }} @@ -107,23 +109,23 @@ <!-- Description --> <div class="mt-6" :class="{ error: v$.group.description.$errors.length }"> <label - class="block mb-2 text-sm font-medium text-gray-900 dark:text-gray-400" - id="descriptionLabel" - >Beskrivelse</label + class="block mb-2 text-sm font-medium text-gray-900 dark:text-gray-400" + id="descriptionLabel" + >Beskrivelse</label > <textarea - id="description" - rows="4" - v-model="v$.group.description.$model" - class="block w-full px-4 py-2 mt-2 text-gray-700 placeholder-gray-500 bg-white border rounded-md dark:bg-gray-800 dark:border-gray-600 dark:placeholder-gray-400 focus:border-primary-light dark:focus:border-primary-light focus:ring-opacity-40 focus:outline-none focus:ring focus:ring-primary-light" - required + id="description" + rows="4" + v-model="v$.group.description.$model" + class="block w-full px-4 py-2 mt-2 text-gray-700 placeholder-gray-500 bg-white border rounded-md dark:bg-gray-800 dark:border-gray-600 dark:placeholder-gray-400 focus:border-primary-light dark:focus:border-primary-light focus:ring-opacity-40 focus:outline-none focus:ring focus:ring-primary-light" + required ></textarea> <!-- error message for description --> <div - class="text-error" - v-for="(error, index) of v$.group.description.$errors" - :key="index" + class="text-error" + v-for="(error, index) of v$.group.description.$errors" + :key="index" > <div class="text-error text-sm"> {{ error.$message }} @@ -134,19 +136,19 @@ <!-- Images --> <div class="mt-6"> <label - class="block mb-2 text-xl font-medium text-gray-900 dark:text-gray-400" - id="imageLabel" + class="block mb-2 text-xl font-medium text-gray-900 dark:text-gray-400" + id="imageLabel" > Bilde </label> <input - type="file" - ref="file" - style="display: none" - @change="addImage" - multiple - accept="image/png, image/jpeg" + type="file" + ref="file" + style="display: none" + @change="addImage" + multiple + accept="image/png, image/jpeg" /> <!-- Button for adding an image --> @@ -171,12 +173,7 @@ <!-- Save item button --> <div class="flex justify-center mt-10 float-right"> - <Button - @click="saveClicked" - id="saveButton" - :text="'Lagre'" - > - </Button> + <Button @click="saveClicked" id="saveButton" :text="'Lagre'"> </Button> </div> </div> </template> @@ -202,32 +199,32 @@ export default { group: { name: { required: helpers.withMessage( - () => "Navnt kan ikke være tom", - required + () => "Navnt kan ikke være tom", + required ), max: helpers.withMessage( - () => `Navnet kan være på max 50 tegn`, - maxLength(50) + () => `Navnet kan være på max 50 tegn`, + maxLength(50) ), }, place: { required: helpers.withMessage( - () => "Stedsnavn kan ikke være tom", - required + () => "Stedsnavn kan ikke være tom", + required ), max: helpers.withMessage( - () => `Stednavn kan være på max 50 tegn`, - maxLength(50) + () => `Stednavn kan være på max 50 tegn`, + maxLength(50) ), }, description: { required: helpers.withMessage( - () => "Beskrivelsen kan ikke være tom", - required + () => "Beskrivelsen kan ikke være tom", + required ), max: helpers.withMessage( - () => `Beskrivelsen kan inneholde max 200 tegn`, - maxLength(200) + () => `Beskrivelsen kan inneholde max 200 tegn`, + maxLength(200) ), }, }, diff --git a/src/components/FormComponents/LoginForm.vue b/src/components/FormComponents/LoginForm.vue index 9bd28d962bc2bebea069c4515535485a3c991ad9..bbb849a1008414ed2abc3899b7216c9a80d7d562 100644 --- a/src/components/FormComponents/LoginForm.vue +++ b/src/components/FormComponents/LoginForm.vue @@ -1,5 +1,7 @@ <template> - <div class="md:ring-1 ring-gray-300 rounded-xl overflow-hidden mx-auto mb-auto max-w-md w-full"> + <div + class="md:ring-1 ring-gray-300 rounded-xl overflow-hidden mx-auto mb-auto max-w-md w-full" + > <div class="px-6 py-4 mt-4"> <div class="text-xl md:text-2xl font-medium text-center text-gray-600 dark:text-gray-200 mt-4 mb-8" diff --git a/src/components/FormComponents/NewPasswordForm.vue b/src/components/FormComponents/NewPasswordForm.vue index 0675e051a873b2717bb96a3cc4a43fb4f4e67114..f25e934c1e892c525994266892deeb6d26727aa2 100644 --- a/src/components/FormComponents/NewPasswordForm.vue +++ b/src/components/FormComponents/NewPasswordForm.vue @@ -1,9 +1,12 @@ <template> <div - class="md:ring-1 ring-gray-300 rounded-xl overflow-hidden mx-auto mb-auto max-w-md w-full p-4" + class="md:ring-1 ring-gray-300 rounded-xl overflow-hidden mx-auto mb-auto max-w-md w-full p-4" > - - <div class="text-2xl font-medium text-center text-gray-600 dark:text-gray-200 mt-4 mb-8">Endre passord</div> + <div + class="text-2xl font-medium text-center text-gray-600 dark:text-gray-200 mt-4 mb-8" + > + Endre passord + </div> <div id="firstPasswordField" @@ -63,7 +66,7 @@ <div id="buttonsField" class="mt-6"> <Button - class="float-right" + class="float-right" @click="setNewPassword" :text="'Sett ny passord'" /> @@ -81,8 +84,9 @@ import Button from "@/components/BaseComponents/ColoredButton"; export default { name: "NewPasswordForm.vue", - components:{ - Button,}, + components: { + Button, + }, setup() { return { v$: useVuelidate() }; }, @@ -91,10 +95,16 @@ export default { user: { password: { required: helpers.withMessage(`Feltet må være utfylt`, required), - minLength: helpers.withMessage('Passordet må være minst 8 karakterer lang', minLength(8)), + minLength: helpers.withMessage( + "Passordet må være minst 8 karakterer lang", + minLength(8) + ), }, rePassword: { - sameAs: helpers.withMessage('Passordene må være like', sameAs(this.user.password)), + sameAs: helpers.withMessage( + "Passordene må være like", + sameAs(this.user.password) + ), required: helpers.withMessage(`Feltet må være utfylt`, required), }, }, @@ -124,12 +134,19 @@ export default { return; } - const newPasswordInfo = { - token: this.token, - newPassword: this.password, - }; + const newPassword = this.user.password; - const newPasswordResponse = doNewPassword(newPasswordInfo); + const newPasswordResponse = await doNewPassword(newPassword); + + if(newPasswordResponse != null) { + console.log("New password set"); + this.$store.commit("saveToken", newPasswordResponse); + await this.$router.push("/"); + } else { + console.log("Couldn't set new password"); + } + + /* if (newPasswordResponse.newPasswordSet === true) { console.log("New password set"); @@ -139,6 +156,8 @@ export default { } else { console.log("Something went wrong"); } + + */ }, validate() { this.$refs.form.validate(); diff --git a/src/components/FormComponents/RegisterForm.vue b/src/components/FormComponents/RegisterForm.vue index c79d4c0af2b58a9a901a908ac9d12490317d8584..994ec8567489beb3e1ac135cb192bd5260918f44 100644 --- a/src/components/FormComponents/RegisterForm.vue +++ b/src/components/FormComponents/RegisterForm.vue @@ -3,7 +3,8 @@ class="w-full max-w-md mx-auto mb-auto md:ring-1 ring-gray-300 overflow-hidden rounded-xl p-4" > <div - class="text-xl md:text-2xl font-medium text-center text-gray-600 dark:text-gray-200 mt-4 mb-8" id="registerLabel" + class="text-xl md:text-2xl font-medium text-center text-gray-600 dark:text-gray-200 mt-4 mb-8" + id="registerLabel" > Opprett ny konto </div> diff --git a/src/components/FormComponents/ResetPasswordForm.vue b/src/components/FormComponents/ResetPasswordForm.vue index 5443c3c0bab2cc57db4b1a3425a3e781343c1f69..61a48774e9d97658981eeadf44659e2d9e73b86a 100644 --- a/src/components/FormComponents/ResetPasswordForm.vue +++ b/src/components/FormComponents/ResetPasswordForm.vue @@ -1,7 +1,12 @@ <template> - <div class="md:ring-1 ring-gray-300 rounded-xl overflow-hidden mx-auto mb-auto max-w-md w-full p-4"> - - <div class="text-2xl font-medium text-center text-gray-600 dark:text-gray-200 mt-4 mb-8">Glemt passordet ditt?</div> + <div + class="md:ring-1 ring-gray-300 rounded-xl overflow-hidden mx-auto mb-auto max-w-md w-full p-4" + > + <div + class="text-2xl font-medium text-center text-gray-600 dark:text-gray-200 mt-4 mb-8" + > + Glemt passordet ditt? + </div> <div id="emailField" @@ -35,12 +40,11 @@ </div> </div> <Button - class="float-right" - @click="sendHome" - :text="'Tilbakestill passord'" + class="float-right" + @click="sendHome" + :text="'Tilbakestill passord'" /> </div> - </div> </template> @@ -52,7 +56,7 @@ import Button from "@/components/BaseComponents/ColoredButton"; export default { name: "ResetPassword.vue", - components:{ + components: { Button, }, data() { @@ -67,7 +71,7 @@ export default { validations() { return { email: { - required: helpers.withMessage('Feltet må være utfylt', required), + required: helpers.withMessage("Feltet må være utfylt", required), email: helpers.withMessage(`E-posten er ugyldig`, email), }, }; diff --git a/src/components/ItemComponents/NewItemForm.vue b/src/components/ItemComponents/NewItemForm.vue index 265f8ec969d4fbadd2d7a4660f58bff9a3bbd438..14208374965626387442ef8e888e4c2cda8195ca 100644 --- a/src/components/ItemComponents/NewItemForm.vue +++ b/src/components/ItemComponents/NewItemForm.vue @@ -1,7 +1,13 @@ <template> - <div class="md:ring-1 ring-gray-300 rounded-xl overflow-hidden mx-auto mb-auto max-w-md w-full p-4"> + <div + class="md:ring-1 ring-gray-300 rounded-xl overflow-hidden mx-auto mb-auto max-w-md w-full p-4" + > <!-- Component heading --> - <div class="text-xl md:text-2xl font-medium text-center text-gray-600 dark:text-gray-200 mt-4 mb-10">Opprett ny utleie</div> + <div + class="text-xl md:text-2xl font-medium text-center text-gray-600 dark:text-gray-200 mt-4 mb-10" + > + Opprett ny utleie + </div> <!-- Title --> <div class="mb-6" :class="{ error: v$.item.title.$errors.length }"> @@ -33,22 +39,22 @@ <!-- Select category --> <div class="mb-6"> <label - class="block mb-2 text-sm font-medium text-gray-900 dark:text-gray-400" - id="selectCategoryLabel" - >Kategori</label + class="block mb-2 text-sm font-medium text-gray-900 dark:text-gray-400" + id="selectCategoryLabel" + >Kategori</label > <select - v-model="v$.item.select.$model" - id="categories" - class="block w-full px-4 py-2 mt-2 text-gray-700 placeholder-gray-500 bg-white border rounded-md dark:bg-gray-800 dark:border-gray-600 dark:placeholder-gray-400 focus:border-primary-light dark:focus:border-primary-light focus:ring-opacity-40 focus:outline-none focus:ring focus:ring-primary-light" + v-model="v$.item.select.$model" + id="categories" + class="block w-full px-4 py-2 mt-2 text-gray-700 placeholder-gray-500 bg-white border rounded-md dark:bg-gray-800 dark:border-gray-600 dark:placeholder-gray-400 focus:border-primary-light dark:focus:border-primary-light focus:ring-opacity-40 focus:outline-none focus:ring focus:ring-primary-light" > <option class="text-gray-400" value="" disabled selected> Velg en kategori </option> <option - v-for="category in categories" - :key="category" - class="text-gray-900 text-sm" + v-for="category in categories" + :key="category" + class="text-gray-900 text-sm" > {{ category }} </option> @@ -56,9 +62,9 @@ <!-- error message for select box --> <div - class="text-error" - v-for="(error, index) of v$.item.select.$errors" - :key="index" + class="text-error" + v-for="(error, index) of v$.item.select.$errors" + :key="index" > <div class="text-error text-sm"> {{ error.$message }} @@ -68,22 +74,21 @@ <!-- Grupper --> <div class="mb-6"> - <label - class="block text-sm font-medium text-gray-900 dark:text-gray-400" - >Grupper</label> + <label class="block text-sm font-medium text-gray-900 dark:text-gray-400" + >Grupper</label + > <div - class="overflow-auto w-full h-32 mt-2 text-base list-none bg-white rounded divide-y divide-gray-100 dark:bg-gray-700" + class="overflow-auto w-full h-32 mt-2 text-base list-none bg-white rounded divide-y divide-gray-100 dark:bg-gray-700" > <ul class="py-1" aria-labelledby="dropdownDefault"> <li> <div class="form-check" v-for="group in groups" :key="group"> <input - - class="form-check-input appearance-none h-4 w-4 border border-gray-300 rounded-sm bg-white checked:bg-primary-medium focus:outline-none transition duration-200 mt-1 align-top bg-no-repeat bg-center bg-contain float-left mr-2 cursor-pointer" - type="checkbox" - :value="group.communityId" - @change="onChangeGroup($event)" - > + class="form-check-input appearance-none h-4 w-4 border border-gray-300 rounded-sm bg-white checked:bg-primary-medium focus:outline-none transition duration-200 mt-1 align-top bg-no-repeat bg-center bg-contain float-left mr-2 cursor-pointer" + type="checkbox" + :value="group.communityId" + @change="onChangeGroup($event)" + /> <label class="form-check-label inline-block text-gray-800"> {{ group.name }} </label> @@ -301,7 +306,7 @@ export default { //Kategorier skal legges inn ved api/hente fra db, her må det endres etterhvert categories: ["Hage", "Kjøkken", "Musikk", "Annet"], groups: [], - groupErrorMessage: '', + groupErrorMessage: "", }; }, methods: { @@ -310,7 +315,7 @@ export default { this.v$.item.$touch(); if (this.v$.item.$invalid || this.item.selectedGroups.length === 0) { - if(this.item.selectedGroups.length === 0){ + if (this.item.selectedGroups.length === 0) { this.groupErrorMessage = "Velg gruppe/grupper"; } console.log("Invalid, avslutter..."); @@ -353,7 +358,7 @@ export default { console.log("posted: " + postRequest); - this.$router.push('/'); + this.$router.push("/"); } }, @@ -367,11 +372,11 @@ export default { this.item.images.push(URL.createObjectURL(event.target.files[0])); }, - getGroups: async function(){ + getGroups: async function () { this.groups = await getMyGroups(); }, - onChangeGroup: function(e){ + onChangeGroup: function (e) { this.selectedGroupId = e.target.value; let alreadyInGroupList = false; console.log("selected clicked"); @@ -386,15 +391,14 @@ export default { } } - if(!alreadyInGroupList){ + if (!alreadyInGroupList) { this.item.selectedGroups.push(this.selectedGroupId); this.groupErrorMessage = ""; } - }, }, beforeMount() { this.getGroups(); - } + }, }; </script> diff --git a/src/router/index.js b/src/router/index.js index 436a688cd7721a4f54c21dff55db17571030e5b6..68199685ba9f8d6a9ee545c619630f25409ac08a 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -79,7 +79,8 @@ const routes = [ { path: "/notifications", name: "notifications", - component: () => import("../components/BaseComponents/NotificationsForm.vue"), + component: () => + import("../components/BaseComponents/NotificationsForm.vue"), beforeEnter: guardRoute, }, { diff --git a/src/utils/apiutil.js b/src/utils/apiutil.js index fd412f2d0aa88bc3a2798753caab284afaf6cb2b..6611f8a00bb2342d87c3bf9fba4a5c6e40471474 100644 --- a/src/utils/apiutil.js +++ b/src/utils/apiutil.js @@ -84,15 +84,22 @@ export function getAverageRating(userid) { console.error(error); }); } -export function doNewPassword() { - //m - //add newPasswordInfo to input - const auth = { newPasswordSet: false }; - //return axios - //.post(API_URL + "newPassword", newPasswordInfo) - //.then((response) => {auth.newPasswordSet = true;return auth;}) - //.catch((error) => {console.log(error);return auth;}); - return auth; //remove after axios is added +export async function doNewPassword(password) { + let res = await axios({ + method: 'put', + url: API_URL + "user/profile/password", + headers: tokenHeader(), + data: { + password: password, + } + }) + .then((response) => { + return response; + }) + .catch((error) => { + console.log(error); + }); + return res.data; } export function postNewItem(itemInfo) { @@ -175,65 +182,64 @@ export async function GetListingsInCommunity(communityID) { } export async function GetMembersOfCommunity(communityID) { - return axios - .get(API_URL + "community/" + communityID + "/members", { - headers: tokenHeader(), - }) - .then((response) => { - return response.data; - }) - .catch((error) => { - console.error(error); - }); + return axios + .get(API_URL + "community/" + communityID + "/members", { + headers: tokenHeader(), + }) + .then((response) => { + return response.data; + }) + .catch((error) => { + console.error(error); + }); } export function JoinOpenCommunity(communityId) { + if (tokenHeader().Authorization == "Bearer " + null) { + console.log("ikke logget på!"); + return "Login to join any community"; + } - if(tokenHeader().Authorization == "Bearer " + null){ - console.log("ikke logget på!"); - return "Login to join any community"; - } - - return axios - .post(API_URL + "communities/" + communityId + "/join", communityId, { - headers: tokenHeader(), - }) - .then((response) => { - return response; - }) - .catch((error) => { - console.log(error.response); - return error; - }); + return axios + .post(API_URL + "communities/" + communityId + "/join", communityId, { + headers: tokenHeader(), + }) + .then((response) => { + return response; + }) + .catch((error) => { + console.log(error.response); + return error; + }); } export async function GetIfUserAlreadyInCommunity(communityID) { - if(tokenHeader().Authorization == "Bearer " + null){ - return false; - } + if (tokenHeader().Authorization == "Bearer " + null) { + return false; + } - return axios - .get(API_URL + "communities/" + communityID + "/user/status", { - headers: tokenHeader(), - }) - .then((response) => { - return response.data; - }) - .catch((error) => { - return error; - }); + return axios + .get(API_URL + "communities/" + communityID + "/user/status", { + headers: tokenHeader(), + }) + .then((response) => { + return response.data; + }) + .catch((error) => { + return error; + }); } export async function LeaveCommunity(communityID) { - return axios - .patch(API_URL + "communities/" + communityID + "/leave", communityID, { - headers: tokenHeader(), - }) - .then((response) => { - return response.data; - }) - .catch((error) => { - console.log(error.data); - return error; - }); + return axios + .patch(API_URL + "communities/" + communityID + "/leave", communityID, { + headers: tokenHeader(), + }) + .then((response) => { + return response.data; + }) + .catch((error) => { + console.log(error.data); + return error; + }); } diff --git a/src/views/CommunityViews/CommunityView.vue b/src/views/CommunityViews/CommunityView.vue index 2c988245f6333e1cf07dd2efba9a6055668bb9c3..b6643a00e413da9d9195fd6357c82876f19d5211 100644 --- a/src/views/CommunityViews/CommunityView.vue +++ b/src/views/CommunityViews/CommunityView.vue @@ -1,23 +1,27 @@ <template> <div v-if="loggedIn"> <div class="flex flex-row p-4 relative"> - <div class="text-xl md:text-2xl text-gray-600 font-medium w-full">Mine grupper</div> + <div class="text-xl md:text-2xl text-gray-600 font-medium w-full"> + Mine grupper + </div> <UserAddIcon - class="cursor-pointer max-h-6 max-w-6 float-right grow" - @click="$router.push('/newCommunity')" - alt="Opprett ny gruppe" + class="cursor-pointer max-h-6 max-w-6 float-right grow" + @click="$router.push('/newCommunity')" + alt="Opprett ny gruppe" /> </div> - <CommunityList :communities="myCommunities" :member="true"/> + <CommunityList :communities="myCommunities" :member="true" /> </div> - <p class="text-xl md:text-2xl text-gray-600 font-medium w-full p-4">Offentlige grupper</p> - <CommunityList :communities="publicCommunities" :member="false"/> + <p class="text-xl md:text-2xl text-gray-600 font-medium w-full p-4"> + Offentlige grupper + </p> + <CommunityList :communities="publicCommunities" :member="false" /> </template> <script> import CommunityList from "@/components/CommunityComponents/CommunityList.vue"; -import {getMyGroups, getVisibleGroups} from "@/utils/apiutil"; -import {UserAddIcon} from "@heroicons/vue/outline"; +import { getMyGroups, getVisibleGroups } from "@/utils/apiutil"; +import { UserAddIcon } from "@heroicons/vue/outline"; export default { name: "HomeView", @@ -41,7 +45,7 @@ export default { // Remove all of the user's communities from the public communities arrays this.publicCommunities = this.publicCommunities.filter( - (val) => !this.myCommunities.includes(val) + (val) => !this.myCommunities.includes(val) ); }, }; diff --git a/src/views/CommunityViews/NewCommunityView.vue b/src/views/CommunityViews/NewCommunityView.vue index f78ccde49e36551c8f47530ef8ed51bd944ce1a1..e8274f2d13b0f049b6ce56e0f005431e9ee1efe4 100644 --- a/src/views/CommunityViews/NewCommunityView.vue +++ b/src/views/CommunityViews/NewCommunityView.vue @@ -2,7 +2,6 @@ <div class="h-screen grid md:mt-8"> <NewCommunity /> </div> - </template> <script> diff --git a/src/views/ItemViews/NewItemView.vue b/src/views/ItemViews/NewItemView.vue index fa8ba75077b76aa1a1af647d9b54ea9bf599a7ac..fc9db3697ba1fe00f740bb7457f233be22e6cee5 100644 --- a/src/views/ItemViews/NewItemView.vue +++ b/src/views/ItemViews/NewItemView.vue @@ -1,8 +1,7 @@ <template> <div class="h-screen grid md:mt-8"> - <AddNewItem/> + <AddNewItem /> </div> - </template> <script> diff --git a/tests/unit/component-tests/community-component-tests/community-header.spec.js b/tests/unit/component-tests/community-component-tests/community-header.spec.js index 84c03bcf42a854598edb236b4de23f26a902507e..91159a1232da99c64557d545283538488996e7a9 100644 --- a/tests/unit/component-tests/community-component-tests/community-header.spec.js +++ b/tests/unit/component-tests/community-component-tests/community-header.spec.js @@ -1,6 +1,6 @@ import { mount } from "@vue/test-utils"; import CommunityHeader from "@/components/CommunityComponents/CommunityHeader.vue"; -import { route, router, $route, $router } from "../../mock-router" +import { route, router, $route, $router } from "../../mock-router"; describe("CommunityHeader component", () => { let wrapper; @@ -25,8 +25,8 @@ describe("CommunityHeader component", () => { router, $route, $router, - } - } + }, + }, }); });