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