Skip to content
Snippets Groups Projects
Commit da31f113 authored by Oda Alida Fønstelien Hjelljord's avatar Oda Alida Fønstelien Hjelljord
Browse files

Merge branch 'community-admin' into 'main'

Community admin

See merge request !88
parents 297c450f e43eedaa
No related branches found
No related tags found
1 merge request!88Community admin
Pipeline #180217 passed
Showing
with 220 additions and 232 deletions
......@@ -53,9 +53,7 @@ export default {
async loadProfile() {
if (this.$store.state.user.token !== null) {
let user = parseUserFromToken(this.$store.state.user.token);
//console.log(user);
let id = user.accountId;
//console.log(id);
await this.$router.push("/profile/" + id);
} else {
await this.$router.push("/login");
......
<template>
<!-- Main modal -->
<div
v-if="visible"
class="fixed grid place-items-center bg-gray-600 bg-opacity-50 top-0 left-0 right-0 z-50 w-full overflow-x-hidden overflow-y-auto inset-0 h-full"
v-if="visible"
class="fixed grid place-items-center bg-gray-600 bg-opacity-50 top-0 left-0 right-0 z-50 w-full overflow-x-hidden overflow-y-auto inset-0 h-full"
>
<div class="relative w-full h-full max-w-2xl p-4 md:h-auto">
<!-- Modal content -->
<div class="relative bg-white rounded-lg shadow dark:bg-gray-700">
<!-- Modal header -->
<div
class="flex p-4 border-b rounded-t dark:border-gray-600"
>
<div class="flex p-4 border-b rounded-t dark:border-gray-600">
<h3 class="text-xl font-semibold text-gray-900 dark:text-white">
{{ name }}
</h3>
<button
@click="close()"
class="text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm p-1.5 ml-auto inline-flex items-center dark:hover:bg-gray-600 dark:hover:text-white"
@click="close()"
class="text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm p-1.5 ml-auto inline-flex items-center dark:hover:bg-gray-600 dark:hover:text-white"
>
<svg
class="w-5 h-5"
fill="currentColor"
viewBox="0 0 20 20"
xmlns="http://www.w3.org/2000/svg"
class="w-5 h-5"
fill="currentColor"
viewBox="0 0 20 20"
xmlns="http://www.w3.org/2000/svg"
>
<path
fill-rule="evenodd"
d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
clip-rule="evenodd"
fill-rule="evenodd"
d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
clip-rule="evenodd"
></path>
</svg>
</button>
</div>
<!-- Modal body -->
<div class="p-6 space-y-6">
<p class="text-lg text-base leading-relaxed text-gray-500 dark:text-gray-400">
<p
class="text-lg text-base leading-relaxed text-gray-500 dark:text-gray-400"
>
{{ title }}
</p>
</div>
<div class="ml-6 mt-4">
<p class=" text-base leading-relaxed text-gray-500 dark:text-gray-400" v-show="renterIsReceiverOfRating">
<p
class="text-base leading-relaxed text-gray-500 dark:text-gray-400"
v-show="renterIsReceiverOfRating"
>
Gi en vurdering til utleieren
</p>
<p class="text-base leading-relaxed text-gray-500 dark:text-gray-400" v-show="!renterIsReceiverOfRating">
<p
class="text-base leading-relaxed text-gray-500 dark:text-gray-400"
v-show="!renterIsReceiverOfRating"
>
Gi en vurdering til leietakeren
</p>
</div>
<div class= "flex justify-center px-4">
<textarea class="w-full h-40 bg-gray-200 mb-4 ring-1 ring-gray-400 rounded-xl"/>
<div class="flex justify-center px-4">
<textarea
class="w-full h-40 bg-gray-200 mb-4 ring-1 ring-gray-400 rounded-xl"
/>
</div>
<div class="flex items-center justify-center mb-8">
<svg class="w-10 h-10 text-warn cursor-pointer" :class="rating[0]" @click="setRating(1)" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
<svg
class="w-10 h-10 text-warn cursor-pointer"
:class="rating[0]"
@click="setRating(1)"
fill="currentColor"
viewBox="0 0 20 20"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z">
</path>
d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"
></path>
</svg>
<svg class="w-10 h-10 text-warn cursor-pointer" :class="rating[1]" @click="setRating(2)" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
<svg
class="w-10 h-10 text-warn cursor-pointer"
:class="rating[1]"
@click="setRating(2)"
fill="currentColor"
viewBox="0 0 20 20"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z">
</path>
d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"
></path>
</svg>
<svg class="w-10 h-10 text-warn cursor-pointer" :class="rating[2]" @click="setRating(3)" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
<svg
class="w-10 h-10 text-warn cursor-pointer"
:class="rating[2]"
@click="setRating(3)"
fill="currentColor"
viewBox="0 0 20 20"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z">
</path>
d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"
></path>
</svg>
<svg class="w-10 h-10 text-warn cursor-pointer" :class="rating[3]" @click="setRating(4)" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
<svg
class="w-10 h-10 text-warn cursor-pointer"
:class="rating[3]"
@click="setRating(4)"
fill="currentColor"
viewBox="0 0 20 20"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z">
</path>
d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"
></path>
</svg>
<svg class="w-10 h-10 text-warn cursor-pointer" :class="rating[4]" @click="setRating(5)" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
<svg
class="w-10 h-10 text-warn cursor-pointer"
:class="rating[4]"
@click="setRating(5)"
fill="currentColor"
viewBox="0 0 20 20"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z">
</path>
d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"
></path>
</svg>
</div>
<div class="flex justify-center mb-4">
<Button
:text="'Send en vurdering'"
@click="sendRating"></Button>
<Button :text="'Send en vurdering'" @click="sendRating"></Button>
</div>
<!-- Modal footer -->
......@@ -98,15 +139,21 @@
<script>
import Button from "@/components/BaseComponents/ColoredButton";
import { postNewRating} from "@/utils/apiutil";
import { postNewRating } from "@/utils/apiutil";
export default {
name: "RatingModal",
data(){
return{
data() {
return {
score: 3,
comment: "",
rating:["text-warn", "text-warn", "text-warn", "text-gray-300", "text-gray-300"],
rating: [
"text-warn",
"text-warn",
"text-warn",
"text-gray-300",
"text-gray-300",
],
};
},
props: {
......@@ -115,42 +162,35 @@ export default {
title: String,
rentID: Number,
renterIsReceiverOfRating: Boolean,
},
components: {
Button,
},
methods: {
setRating(ratingNumber){
setRating(ratingNumber) {
this.score = ratingNumber;
for(let i = 0; i < 5; i++ ){
if(i < ratingNumber) {
this.rating[i] = "text-warn"
}
else {
this.rating[i] = "text-gray-300"
for (let i = 0; i < 5; i++) {
if (i < ratingNumber) {
this.rating[i] = "text-warn";
} else {
this.rating[i] = "text-gray-300";
}
}
},
close() {
this.$emit("close");
},
async sendRating(){
async sendRating() {
const ratingInfo = {
score: this.score,
comment: this.comment,
renterIsReceiverOfRating: this.renterIsReceiverOfRating,
rentID: this.rentID
}
const postResponse = await postNewRating(ratingInfo);
console.log("posted: " + postResponse);
rentID: this.rentID,
};
await postNewRating(ratingInfo);
this.$router.push("/");
},
},
};
......
......@@ -33,7 +33,6 @@ export default {
},
methods: {
color() {
//console.log(this.userID);
return this?.message.from == this.userID
? "bg-gray-300"
: "bg-primary-medium";
......
......@@ -52,7 +52,6 @@ export default {
},
methods: {
selectUser() {
//console.log(this.conversation.recipient.userId);
this.$emit("recipient", this.conversation.recipient.userId);
},
},
......
......@@ -57,8 +57,8 @@ export default {
this.$router.push("/");
},
},
mounted() {
this.admin = CommunityAdminService.isUserAdmin(
async mounted() {
this.admin = await CommunityAdminService.isUserAdmin(
this.$route.params.communityID
);
},
......
......@@ -123,11 +123,11 @@ export default {
this.community = await CommunityService.getCommunity(
this.$route.params.communityID
);
let members = await CommunityService.getCommunityMembers(
const members = await CommunityService.getCommunityMembers(
this.$route.params.communityID
);
for (let mem in members) {
if (mem === this.userid) {
for (let i = 0; i < members.length; i++) {
if (members[i].userId == this.userid) {
this.member = true;
return;
}
......
......@@ -116,7 +116,7 @@ export default {
title: "",
pricePerDay: 0,
},
communityID: -1,
community: {},
......
......@@ -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;
......
......@@ -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,46 @@ 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)
this.community = await GetCommunity(this.communityID);
console.log(this.community)
}
},
},
async created() {
async created() {
await this.getCommunityFromAPI(); //To get the id of the community before mounting the view
},
};
......
......@@ -9,7 +9,7 @@
</template>
<script>
// import AdminService from "@/services/community-admin.service";
// import CommunityAdminService from "@/services/community-admin.service";
import IconButton from "@/components/BaseComponents/IconButton.vue";
//TODO: OPEN CONFIRMATION DIALOG WHEN DELETING
......@@ -20,8 +20,8 @@ export default {
},
methods: {
deleteCommunity() {
//console.log("DELETED");
// AdminService.deleteCommunity(this.$route.params.communityID);
console.log("DELETED");
// CommunityAdminService.deleteCommunity(this.$route.params.communityID);
},
},
};
......
......@@ -10,7 +10,7 @@
<script>
import UserListItemCard from "@/components/UserProfileComponents/UserListItemCard.vue";
import CommunityService from "@/services/community.service";
import {GetMemberRequestsOfCommunity} from "@/utils/apiutil";
import { GetMemberRequestsOfCommunity } from "@/utils/apiutil";
export default {
name: "MemberList",
......@@ -32,14 +32,15 @@ export default {
},
async created() {
this.loading = true;
if(this.requests){
this.members = await GetMemberRequestsOfCommunity(
this.$route.params.communityID
);
if (this.requests) {
this.members = await GetMemberRequestsOfCommunity(
this.$route.params.communityID
);
} else {
this.members = await CommunityService.getCommunityMembers(
this.$route.params.communityID
);}
this.members = await CommunityService.getCommunityMembers(
this.$route.params.communityID
);
}
this.loading = false;
},
};
......
......@@ -137,7 +137,6 @@ export default {
this.v$.user.$touch();
if (this.v$.user.$invalid) {
//console.log("Ugyldig, avslutter...");
return;
}
......@@ -153,8 +152,6 @@ export default {
} else if (loginResponse.isLoggedIn === true) {
this.$store.commit("saveToken", loginResponse.token);
await this.$router.push("/");
} else {
//console.log("Something went wrong");
}
},
},
......
......@@ -130,7 +130,6 @@ export default {
this.v$.user.$touch();
if (this.v$.user.$invalid) {
//console.log("Invalid, exiting...");
return;
}
......@@ -139,25 +138,9 @@ export default {
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");
await this.$router.push("/");
} else if (newPasswordResponse.newPasswordSet === false) {
//console.log("Couldn't set new password");
} else {
//console.log("Something went wrong");
}
*/
},
validate() {
this.$refs.form.validate();
......
......@@ -83,7 +83,6 @@ export default {
this.v$.email.$touch();
if (this.v$.email.$invalid) {
//console.log("Ugyldig, avslutter...");
return;
} else {
this.$router.push("/");
......
......@@ -311,37 +311,19 @@ export default {
},
methods: {
checkValidation: function () {
//console.log("sjekker validering");
this.v$.item.$touch();
if (this.v$.item.$invalid || this.item.selectedGroups.length === 0) {
if (this.item.selectedGroups.length === 0) {
this.groupErrorMessage = "Velg gruppe/grupper";
}
//console.log("Invalid, avslutter...");
return false;
}
//console.log("validert!");
return true;
},
async saveClicked() {
//console.log("Attempting to save item");
if (this.checkValidation()) {
//console.log("validert, videre...");
this.checkUser();
//console.log("Tittel: " + this.item.title);
//console.log("Kategori: " + this.item.select);
//console.log("Beskrivelse: " + this.item.description);
//console.log("Addressen: " + this.item.address);
//console.log("Pris: " + this.item.price);
//console.log("bilder: " + this.item.images);
//console.log("gruppe: " + this.item.selectedGroups);
const itemInfo = {
title: this.item.title,
description: this.item.description,
......@@ -351,12 +333,7 @@ export default {
categoryNames: [],
communityIDs: this.item.selectedGroups,
};
//console.log(itemInfo);
/* const postRequest = */ await postNewItem(itemInfo);
//console.log("posted: " + postRequest);
await postNewItem(itemInfo);
this.$router.push("/");
}
......@@ -368,7 +345,6 @@ export default {
},
addImage: function (event) {
//console.log(event.target.files);
this.item.images.push(URL.createObjectURL(event.target.files[0]));
},
......@@ -379,7 +355,6 @@ export default {
onChangeGroup: function (e) {
this.selectedGroupId = e.target.value;
let alreadyInGroupList = false;
//console.log("selected clicked");
for (let i = 0; i <= this.item.selectedGroups.length; i++) {
if (this.selectedGroupId == this.item.selectedGroups[i]) {
......
......@@ -51,7 +51,10 @@
</div>
</div>
<div class="mt-2">
<UserListItemCard :user="userForId"></UserListItemCard>
<UserListItemCard
:buttons="['chat']"
:user="userForId"
></UserListItemCard>
</div>
<div class="mt-4">
<h3 class="text-base font-base text-gray-900">Tidspunkter</h3>
......@@ -87,10 +90,11 @@
<script>
import NewRent from "@/components/RentingComponents/NewRent.vue";
import { getItem, getItemPictures, getUser } from "@/utils/apiutil";
import { getItem, getItemPictures } from "@/utils/apiutil";
import ImageCarousel from "@/components/RentingComponents/ImageCarousel.vue";
import UserListItemCard from "@/components/UserProfileComponents/UserListItemCard.vue";
import DatepickerRange from "@/components/TimepickerComponents/DatepickerRange/DatepickerRange.vue";
import UserService from "@/services/user.service";
export default {
name: "ItemInfo",
......@@ -123,7 +127,7 @@ export default {
],
pictures: [],
noPicture: true,
userForId: Object,
userForId: {},
rentingStartDate: null,
rentingEndDate: null,
totPrice: 0,
......@@ -181,7 +185,7 @@ export default {
//TODO fixs so each image get a correct alt text.
},
async getUser(userId) {
this.userForId = await getUser(userId);
this.userForId = await UserService.getUserFromId(userId);
},
setDate(dateOfsomthing) {
if (dateOfsomthing.startDate == null || dateOfsomthing.endDate == null) {
......
......@@ -81,7 +81,6 @@ export default {
this.$emit("back", this.type);
},
forward() {
//console.log(this.type);
this.$emit("forward", this.type);
},
},
......
<template>
<div id = "headline" class = "text-xl md:text-2xl text-gray-600 font-medium w-full">
Dine gjenstander
<div
id="headline"
class="text-xl md:text-2xl text-gray-600 font-medium w-full"
>
Dine gjenstander
</div>
<!-- Search field -->
<div class="relative" id="searchComponent">
<span class="absolute inset-y-0 left-0 flex items-center pl-3">
<svg class="w-5 h-5 text-gray-400" viewBox="0 0 24 24" fill="none">
<path
d="M21 21L15 15M17 10C17 13.866 13.866 17 10 17C6.13401 17 3 13.866 3 10C3 6.13401 6.13401 3 10 3C13.866 3 17 6.13401 17 10Z"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
></path>
</svg>
</span>
<div class="relative" id="searchComponent">
<span class="absolute inset-y-0 left-0 flex items-center pl-3">
<svg class="w-5 h-5 text-gray-400" viewBox="0 0 24 24" fill="none">
<path
d="M21 21L15 15M17 10C17 13.866 13.866 17 10 17C6.13401 17 3 13.866 3 10C3 6.13401 6.13401 3 10 3C13.866 3 17 6.13401 17 10Z"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
></path>
</svg>
</span>
<input
type="text"
id="searchInput"
class="w-full py-3 pl-10 pr-4 text-gray-700 bg-white border rounded-md dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 focus:border-primary-medium dark:focus:border-primary-medium focus:outline-none focus:ring"
placeholder="Search"
v-model="search"
@change="searchWritten"
/>
</div>
<div class="absolute inset-x-0 px-5 py-3">
<!-- ItemCards -->
<div class="flex items-center justify-center w-screen">
<!-- Shows items based on pagination -->
<div
class="grid grid-flow-row-dense grid-cols-2 md:grid-cols-4 lg:grid-cols-5 w-full"
v-if="showItems"
>
<ItemCard
v-for="item in visibleItems"
:key="item"
:item="item"
/>
</div>
<input
type="text"
id="searchInput"
class="w-full py-3 pl-10 pr-4 text-gray-700 bg-white border rounded-md dark:bg-gray-800 dark:text-gray-300 dark:border-gray-600 focus:border-primary-medium dark:focus:border-primary-medium focus:outline-none focus:ring"
placeholder="Search"
v-model="search"
@change="searchWritten"
/>
</div>
<!-- Shows items based on search field input -->
<div
class="grid grid-flow-row-dense grid-cols-2 md:grid-cols-4 lg:grid-cols-5 w-full place-items-center"
v-if="showSearchedItems"
>
<ItemCard
v-for="item in searchedItems"
:key="item"
:item="item"
/>
</div>
<div class="absolute inset-x-0 px-5 py-3">
<!-- ItemCards -->
<div class="flex items-center justify-center w-screen">
<!-- Shows items based on pagination -->
<div
class="grid grid-flow-row-dense grid-cols-2 md:grid-cols-4 lg:grid-cols-5 w-full"
v-if="showItems"
>
<ItemCard v-for="item in visibleItems" :key="item" :item="item" />
</div>
<!-- pagination -->
<div class="flex justify-center" v-if="showItems">
<PaginationTemplate
v-bind:items="items"
v-on:page:update="updatePage"
v-bind:currentPage="currentPage"
v-bind:pageSize="pageSize"
class="mt-10"
/>
<!-- Shows items based on search field input -->
<div
class="grid grid-flow-row-dense grid-cols-2 md:grid-cols-4 lg:grid-cols-5 w-full place-items-center"
v-if="showSearchedItems"
>
<ItemCard v-for="item in searchedItems" :key="item" :item="item" />
</div>
</div>
<!-- pagination -->
<div class="flex justify-center" v-if="showItems">
<PaginationTemplate
v-bind:items="items"
v-on:page:update="updatePage"
v-bind:currentPage="currentPage"
v-bind:pageSize="pageSize"
class="mt-10"
/>
</div>
</div>
</template>
<script>
import { GetUserListings, getItemPictures } from "@/utils/apiutil";
......@@ -74,7 +69,7 @@ export default {
name: "UserItems",
components: {
ItemCard,
PaginationTemplate
PaginationTemplate,
},
data() {
return {
......@@ -88,7 +83,7 @@ export default {
},
showItems: true,
showSearchedItems: false,
search: "",
search: "",
//Variables connected to pagination
currentPage: 0,
pageSize: 12,
......@@ -119,7 +114,7 @@ export default {
}
}
},
//Pagination
//Pagination
updatePage(pageNumber) {
this.currentPage = pageNumber;
this.updateVisibleTodos();
......@@ -149,7 +144,6 @@ export default {
async beforeMount() {
await this.getUserListingsFromAPI();
this.updateVisibleTodos();
},
};
</script>
......@@ -158,7 +152,6 @@ export default {
#headline {
display: block;
margin-top: 10px;
margin-bottom: 10px;
margin-bottom: 10px;
}
</style>
\ No newline at end of file
</style>
......@@ -110,6 +110,8 @@ export default {
this.communityID,
this.user.userId
);
//Find a better way to do this
window.location.reload();
},
acceptMemberRequest() {
CommunityAdminService.acceptUserIntoCommunity(
......
......@@ -33,7 +33,6 @@
>
<li>
<router-link
to="/user/userItems"
class="block py-2 px-4 text-sm text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 dark:hover:text-white"
>Mine gjenstander</router-link
......
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