Skip to content
Snippets Groups Projects
Commit b7d1d4db authored by Gilgard's avatar Gilgard
Browse files

rating added to userprofile

parent de49de95
No related branches found
No related tags found
1 merge request!18Display rating
......@@ -74,7 +74,7 @@
alt="Profile picture"
/>
<h5 class="mb-1 text-xl font-medium text-gray-900 dark:text-white">
{{ user.first_name }} {{ user.last_name }}
{{ user.firstName }} {{ user.lastName }}
</h5>
<div>
<rating-component :rating="renterRating" :ratingType="'Leietaker'" />
......@@ -94,8 +94,8 @@
<script>
import RatingComponent from "@/components/UserProfileComponents/RatingComponent.vue";
import { parseUserFromToken } from "@/utils/token-utils";
import { getUser /* getRenterRating, getOwnerRating */ } from "@/utils/apiutil";
import { parseCurrentUser } from "@/utils/token-utils";
import { getUser, getRenterRating, getOwnerRating } from "@/utils/apiutil";
import router from "@/router";
export default {
......@@ -106,8 +106,8 @@ export default {
currentUser: {},
id: -1,
isCurrentUser: false,
renterRating: 0, //getRenterRating(this.userID),
ownerRating: 0, //getOwnerRating(this.userID),
renterRating: -1, //getRenterRating(this.userID),
ownerRating: -1, //getOwnerRating(this.userID),
dropdown: false,
};
},
......@@ -116,19 +116,16 @@ export default {
},
methods: {
async getUser() {
this.currentUser = parseUserFromToken();
this.currentUser = parseCurrentUser();
this.id = router.currentRoute.value.params.id;
if (this.id == this.currentUser.account_id) {
this.isCurrentUser = true;
this.user = this.currentUser;
return;
}
let getuser = await getUser(this.id);
this.user = {
account_id: getuser.userID,
first_name: getuser.firstName,
last_name: getuser.lastName,
};
this.user = await getUser(this.id);
this.renterRating = getRenterRating(this.id);
this.ownerRating = getOwnerRating(this.id);
},
getProfilePicture() {
/* if (this.user.picture != "") {
......
<template>
<ul class="flex justify-center">
<ul v-if="compRating != -1" class="flex justify-center">
<li>
<p class="ml-2 text-sm font-medium text-gray-500 dark:text-gray-400">
{{ ratingType }}:&nbsp;
......@@ -23,6 +23,18 @@
</p>
</li>
</ul>
<ul v-else class="flex justify-center">
<li>
<p class="ml-2 text-sm font-medium text-gray-500 dark:text-gray-400">
{{ ratingType }}:&nbsp;
</p>
</li>
<li>
<p class="ml-2 text-sm font-medium text-gray-500 dark:text-gray-400">
Rating ikke tilgjengelig
</p>
</li>
</ul>
</template>
<script>
......
......@@ -4,7 +4,7 @@ import { tokenHeader } from "./token-utils";
const API_URL = process.env.VUE_APP_BASEURL;
export function doLogin(loginRequest) {
const auth = {isLoggedIn: false, token: ""};
const auth = { isLoggedIn: false, token: "" };
return axios
.post(API_URL + "login/authentication", loginRequest)
.then((response) => {
......@@ -48,7 +48,7 @@ export async function getUser(userid) {
export function getRenterRating(userid) {
return axios
.get(API_URL + "users/" + userid + "", {
.get(API_URL + "rating/" + userid + "/as_owner", {
headers: tokenHeader(),
})
.then((response) => {
......@@ -61,7 +61,7 @@ export function getRenterRating(userid) {
export function getOwnerRating(userid) {
return axios
.get(API_URL + "users/" + userid + "", {
.get(API_URL + "rating/" + userid + "/as_renter", {
headers: tokenHeader(),
})
.then((response) => {
......
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