diff --git a/src/components/UserProfileComponents/LargeProfileCard.vue b/src/components/UserProfileComponents/LargeProfileCard.vue index 7c5c036f8103be9c42b62d0c818dfa229af2f8cd..695ef260ac7df019805abe3f27cbeda6cc00f5b3 100644 --- a/src/components/UserProfileComponents/LargeProfileCard.vue +++ b/src/components/UserProfileComponents/LargeProfileCard.vue @@ -1,13 +1,13 @@ <template> <div - class="max-w-sm bg-white rounded-lg border border-gray-200 shadow-md dark:bg-gray-800 dark:border-gray-700" + class="min-w-full md:min-w-0 md:w-96 my-4 py-8 bg-white rounded-lg border border-gray-200 shadow-md dark:bg-gray-800 dark:border-gray-700" > - <div v-show="isCurrentUser" class="flex justify-end px-4 pt-4"> + <div v-show="isCurrentUser" class="flex absolute justify-end px-4 pt-4"> <button id="dropdownDefault" data-dropdown-toggle="dropdown" @click="dropdown = !dropdown" - class="hidden sm:inline-block text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 focus:outline-none focus:ring-4 focus:ring-gray-200 dark:focus:ring-gray-700 rounded-lg text-sm p-1.5" + class="w-10 h-10 text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 focus:outline-none focus:ring-4 focus:ring-gray-200 dark:focus:ring-gray-700 rounded-lg text-sm p-1.5" type="button" > <svg @@ -25,7 +25,6 @@ <div id="dropdown" v-show="dropdown" - zindex="2" class="z-10 w-44 text-base list-none bg-white rounded divide-y divide-gray-100 shadow dark:bg-gray-700" > <ul class="py-1" aria-labelledby="dropdownDefault"> @@ -67,6 +66,7 @@ </ul> </div> </div> + <div class="flex flex-col items-center pb-10"> <img class="mb-3 w-24 h-24 rounded-full shadow-lg" @@ -95,8 +95,7 @@ <script> import RatingComponent from "@/components/UserProfileComponents/RatingComponent.vue"; import { parseCurrentUser } from "@/utils/token-utils"; -import { getUser, getRenterRating, getOwnerRating } from "@/utils/apiutil"; -import router from "@/router"; +import { getUser, getAverageRating } from "@/utils/apiutil"; export default { name: "LargeProfileCard", @@ -106,8 +105,8 @@ export default { currentUser: {}, id: -1, isCurrentUser: false, - renterRating: -1, //getRenterRating(this.userID), - ownerRating: -1, //getOwnerRating(this.userID), + renterRating: -1, + ownerRating: -1, dropdown: false, }; }, @@ -116,21 +115,25 @@ export default { }, methods: { async getUser() { - this.currentUser = parseCurrentUser(); - this.id = router.currentRoute.value.params.id; - if (this.id == this.currentUser.account_id) { + this.currentUser = await parseCurrentUser(); + this.id = await this.$router.currentRoute.value.params.id; + + if (this.id == this.currentUser.accountId) { this.isCurrentUser = true; this.user = this.currentUser; return; } this.user = await getUser(this.id); - this.renterRating = getRenterRating(this.id); - this.ownerRating = getOwnerRating(this.id); + let rating = await getAverageRating(this.id); + if (rating >= 0 && rating <= 5) { + this.renterRating = rating; + this.ownerRating = rating; + } }, getProfilePicture() { - /* if (this.user.picture != "") { + if (this.user.picture != "") { return this.user.picture; - } */ + } return "../assets/defaultUserProfileImage.jpg"; }, }, diff --git a/src/components/UserProfileComponents/RatingComponent.vue b/src/components/UserProfileComponents/RatingComponent.vue index 662b9607911697c89421e7c4727b44caa93dfe4c..c6e7e8252f2fb8916098f3a1ab8b6a2a7290eb62 100644 --- a/src/components/UserProfileComponents/RatingComponent.vue +++ b/src/components/UserProfileComponents/RatingComponent.vue @@ -1,5 +1,5 @@ <template> - <ul v-if="compRating != -1" class="flex justify-center"> + <ul v-if="rating != -1" class="flex justify-center"> <li> <p class="ml-2 text-sm font-medium text-gray-500 dark:text-gray-400"> {{ ratingType }}: @@ -19,7 +19,7 @@ </li> <li> <p class="ml-2 text-sm font-medium text-gray-500 dark:text-gray-400"> - {{ compRating }} out of 5 + {{ rating }} out of 5 </p> </li> </ul> @@ -40,11 +40,6 @@ <script> export default { name: "RatingComponent", - data() { - return { - compRating: this.rating + 0, - }; - }, props: { rating: Number, ratingType: String, diff --git a/src/views/ProfileView.vue b/src/views/ProfileView.vue index cfd2cefd902017ad7b867b7cfe447cce5648cf07..c4ea15c9d2d5c8f640b8180c226a64e4555535a2 100644 --- a/src/views/ProfileView.vue +++ b/src/views/ProfileView.vue @@ -1,6 +1,7 @@ -<!-- View for looking at different profile display methods --> <template> - <large-profile-card :isCurrentUser="true" /> + <div class="h-screen bg-gray-200 grid place-items-center"> + <large-profile-card :isCurrentUser="true" class="align-top" /> + </div> </template> <script>