Skip to content
Snippets Groups Projects
Commit 7d756eb0 authored by Anders Høvik's avatar Anders Høvik
Browse files

Change array-type of goals

parent 1721d77c
No related branches found
No related tags found
1 merge request!86Feature/history endpoint
<script setup lang="ts"> <script setup lang="ts">
import {useRoute, useRouter} from "vue-router"; import {useRoute, useRouter} from "vue-router";
import {onMounted, ref} from "vue"; import {onMounted, type Ref, ref, type UnwrapRef} from "vue";
import {UserService, type ProfileDTO, GoalService} from "@/api"; import {UserService, type ProfileDTO, GoalService, type GoalDTO} from "@/api";
let numberOfHistory = 6; let numberOfHistory = 6;
...@@ -12,7 +12,7 @@ let cardTitles = ["Spain tour", "Food waste", "Coffee", "Concert", "New book", " ...@@ -12,7 +12,7 @@ let cardTitles = ["Spain tour", "Food waste", "Coffee", "Concert", "New book", "
let hasHistory = ref(true) let hasHistory = ref(true)
let firstname = ref(); let firstname = ref();
let lastname = ref(); let lastname = ref();
let goals = ref([]); let goals: Ref<UnwrapRef<GoalDTO[]>> = ref([]);
let username = ref() let username = ref()
...@@ -41,7 +41,7 @@ function toRoadmap(){ ...@@ -41,7 +41,7 @@ function toRoadmap(){
//todo Make a store of a friend-instance //todo Make a store of a friend-instance
onMounted(async () => { onMounted(async () => {
try { try {
goals = await UserService.getProfile({ let response = await UserService.getProfile({
userId: id.value.id userId: id.value.id
}) })
profile = response; profile = response;
...@@ -62,13 +62,17 @@ function addFriend() { ...@@ -62,13 +62,17 @@ function addFriend() {
} }
async function getGoals() { async function getGoals() {
let response = await GoalService.getGoals(); try {
console.log("number of goals: ", response.length ) goals.value = await GoalService.getGoals();
if(response.length > 0) { console.log("number of goals: ", goals.value.length)
hasHistory.value = true if (goals.value.length > 0) {
}else{ hasHistory.value = true
hasHistory.value = false } else {
console.log('No history') hasHistory.value = false
console.log('No history')
}
}catch (error){
console.error("Something went wrong getting the goals: " , error)
} }
} }
......
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