Skip to content
Snippets Groups Projects
Commit 350d151c authored by Sverre Frogner Haugen's avatar Sverre Frogner Haugen
Browse files

Merge branch 'milestone-API' into 'master'

Milestone api

See merge request !57
parents ba0f7b97 c0d122a8
No related branches found
No related tags found
1 merge request!57Milestone api
Pipeline #280579 passed
...@@ -114,14 +114,6 @@ const deleteTheChallenge = () => { ...@@ -114,14 +114,6 @@ const deleteTheChallenge = () => {
gap: 1.0%; gap: 1.0%;
} }
.expiration-date{
font-weight: bold;
}
.sum{
font-weight: bold;
}
.content{ .content{
overflow: scroll; overflow: scroll;
} }
......
...@@ -136,7 +136,7 @@ watch(currentPage, fetchActiveChallenges); ...@@ -136,7 +136,7 @@ watch(currentPage, fetchActiveChallenges);
</div> </div>
<div class="pagination"> <div class="pagination">
<button @click="previousPage" :disabled="currentPage === 0">Forige side</button> <button @click="previousPage" :disabled="currentPage === 0">Forige side</button>
<div v-if="pages>0" class="page-numbers"> <div v-if="pages>1" class="page-numbers">
<button <button
v-for="pageNumber in pages" v-for="pageNumber in pages"
:key="pageNumber-2" :key="pageNumber-2"
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
import ActiveMilestoneDisplay from '@/components/milestone/ActiveMilestoneDisplay.vue' import ActiveMilestoneDisplay from '@/components/milestone/ActiveMilestoneDisplay.vue'
import { onMounted, ref } from 'vue' import { onMounted, ref } from 'vue'
import { useTokenStore } from '@/stores/token' import { useTokenStore } from '@/stores/token'
import { getAllMilestones } from '@/utils/MilestoneUtils' import { getAllMilestonesPaginated } from '@/utils/MilestoneUtils'
interface Milestone{ interface Milestone{
milestoneId: number; milestoneId: number;
...@@ -31,7 +31,7 @@ onMounted( () => { ...@@ -31,7 +31,7 @@ onMounted( () => {
const fetchActiveMilestones = async () => { const fetchActiveMilestones = async () => {
try{ try{
console.log(currentPage.value) console.log(currentPage.value)
const { content, totalPages, number } = await getAllMilestones(token, currentPage.value,SIZE) const { content, totalPages, number } = await getAllMilestonesPaginated(token, currentPage.value,SIZE)
pages.value = totalPages; pages.value = totalPages;
currentPage.value = number; currentPage.value = number;
activeMilestones.value = content; activeMilestones.value = content;
...@@ -60,7 +60,7 @@ const nextPage = () =>{ ...@@ -60,7 +60,7 @@ const nextPage = () =>{
<div class="active-milestone-component"> <div class="active-milestone-component">
<div class="pagination"> <div class="pagination">
<button @click="previousPage" :disabled="currentPage === 0">Forige side</button> <button @click="previousPage" :disabled="currentPage === 0">Forige side</button>
<div v-if="pages>0" class="page-numbers"> <div v-if="pages>1" class="page-numbers">
<button <button
v-for="pageNumber in pages" v-for="pageNumber in pages"
:key="pageNumber-2" :key="pageNumber-2"
......
...@@ -94,7 +94,7 @@ const nextPage = () =>{ ...@@ -94,7 +94,7 @@ const nextPage = () =>{
<div class="pagination"> <div class="pagination">
<button @click="previousPage" :disabled="currentPage === 0">Forige side</button> <button @click="previousPage" :disabled="currentPage === 0">Forige side</button>
<div v-if="pages>0" class="page-numbers"> <div v-if="pages>1" class="page-numbers">
<button <button
v-for="pageNumber in pages" v-for="pageNumber in pages"
:key="pageNumber-2" :key="pageNumber-2"
......
...@@ -34,14 +34,17 @@ watch(currentRoute, () => { ...@@ -34,14 +34,17 @@ watch(currentRoute, () => {
</button> </button>
<button <button
class="menu-button" class="menu-button"
:class="{ 'active': currentRoute.path == '/homepage/milestone' }" :class="{ 'active': currentRoute.path == '/homepage/milestone'
|| currentRoute.path == '/homepage/create-milestone'
|| currentRoute.path == '/homepage/create-milestone'
|| currentRoute.path == 'homepage/pathe'}"
@click="navigateTo('/homepage/milestone')"> @click="navigateTo('/homepage/milestone')">
<img src="/src/components/icons/navigation/piggy-bank.svg" alt="Milestone Icon" class="icon"> <img src="/src/components/icons/navigation/piggy-bank.svg" alt="Milestone Icon" class="icon">
<label class="button-label">Sparemål</label> <label class="button-label">Sparemål</label>
</button> </button>
<button <button
class="menu-button" class="menu-button"
:class="{ 'active': currentRoute.path == '/homepage/challenge' }" :class="{ 'active': currentRoute.path == '/homepage/challenge' || currentRoute.path == '/homepage/create-challenge'}"
@click="navigateTo('/homepage/challenge')"> @click="navigateTo('/homepage/challenge')">
<img src="/src/components/icons/navigation/challenge.svg" alt="Challenge Icon" class="icon"> <img src="/src/components/icons/navigation/challenge.svg" alt="Challenge Icon" class="icon">
<label class="button-label">Utfordringer</label> <label class="button-label">Utfordringer</label>
......
...@@ -31,8 +31,7 @@ onMounted(async () => { ...@@ -31,8 +31,7 @@ onMounted(async () => {
}) })
const fetchAllMilestones = async () =>{ const fetchAllMilestones = async () =>{
try{ try{
const result = await getAllMilestones(token, 0,10) milestones.value = await getAllMilestones(token)
milestones.value = result.content;
chosenMilestone.value = milestones.value[0].milestoneId; chosenMilestone.value = milestones.value[0].milestoneId;
} catch (error){ } catch (error){
......
<script setup lang="ts"> <script setup lang="ts">
import { onMounted, ref } from 'vue'
import { useTokenStore } from '@/stores/token' import { useTokenStore } from '@/stores/token'
import { getAllMilestones } from '@/utils/MilestoneUtils' import { deleteChallenge } from '@/utils/challengeutils'
import { completeChallenge, deleteChallenge } from '@/utils/challengeutils'
interface Milestone{
'milestoneId': number,
'milestoneTitle': string
}
const props = defineProps({ const props = defineProps({
challengeId: Number, challengeId: Number,
......
...@@ -36,8 +36,7 @@ const fetchUserInfo = async () =>{ ...@@ -36,8 +36,7 @@ const fetchUserInfo = async () =>{
const fetchAccountInfo = async () => { const fetchAccountInfo = async () => {
const response = await getUserAccountInfo(token); const response = await getUserAccountInfo(token);
console.log('account info') accounts.value = [];
console.log(response)
for(let i = 0; i < response.length; i++){ for(let i = 0; i < response.length; i++){
console.log(response[i].accountNumber) console.log(response[i].accountNumber)
accounts.value.push(response[i].accountNumber) accounts.value.push(response[i].accountNumber)
......
import axios from 'axios'; import axios from 'axios';
export const getAllMilestones = async(token: string, page:number, size:number) => { export const getAllMilestonesPaginated = async(token: string, page:number, size:number) => {
const config = { const config = {
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
...@@ -11,6 +11,21 @@ export const getAllMilestones = async(token: string, page:number, size:number) = ...@@ -11,6 +11,21 @@ export const getAllMilestones = async(token: string, page:number, size:number) =
'size': size 'size': size
} }
}; };
try {
const response = await axios.get("http://localhost:8080/milestone/user/paginated", config)
return response.data;
} catch (error) {
console.log(error)
}
}
export const getAllMilestones = async(token: string) => {
const config = {
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + token
},
};
try { try {
const response = await axios.get("http://localhost:8080/milestone/user", config) const response = await axios.get("http://localhost:8080/milestone/user", config)
return response.data; return response.data;
......
...@@ -203,7 +203,7 @@ export const updateBankAccountInfo = async ( ...@@ -203,7 +203,7 @@ export const updateBankAccountInfo = async (
}; };
const data = { const data = {
'currentAccount': checkingAccount, 'currentAccount': checkingAccount,
'savingAccount': savingAccount 'savingsAccount': savingAccount
}; };
return await axios.put('http://localhost:8080/users/update',data,config); return await axios.put('http://localhost:8080/users/update',data,config);
} catch (error){ } catch (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