diff --git a/src/components/MilestonePath/MilestonePath.vue b/src/components/MilestonePath/MilestonePath.vue index 8cc39d4acc90884d9c8930a626288de706d4eb30..b3f49167beee667fa2c42fd6190565876b34f28d 100644 --- a/src/components/MilestonePath/MilestonePath.vue +++ b/src/components/MilestonePath/MilestonePath.vue @@ -9,7 +9,7 @@ const props = defineProps({ totalSaved: Number }); -const totalNodes = ref(props.totalToSave ? Math.ceil(props.totalToSave / 250) : 0); +const totalNodes = ref(50) const remainingNodes = ref( totalNodes.value && props.totalSaved && props.totalToSave ? Math.ceil(totalNodes.value - (totalNodes.value * (props.totalSaved / props.totalToSave))) @@ -30,6 +30,9 @@ const nodes = Array.from({ length: totalNodes.value }, (_, index) => ({ const nodeForegroundColors = ref(['#CCCCCF', '#A4ED45', '#FCBD47']) const nodeBackgroundColors = ref(['#A4A4A6', '#6AB40A', '#FFA600']) +console.log("Total to Save: " + props.totalToSave) +console.log("Total saved: " + props.totalSaved) + </script> <template> diff --git a/src/stores/currentMilestone.ts b/src/stores/currentMilestone.ts index 8fb30b0cd66ff42befe6ebcd0ad90d2808b79c13..23bf999f4aa03f88c5a84c6130cc7b7ce2a7dc1c 100644 --- a/src/stores/currentMilestone.ts +++ b/src/stores/currentMilestone.ts @@ -2,10 +2,11 @@ import { ref } from 'vue' import { defineStore } from 'pinia' export const useMilestoneStore = defineStore('milestoneId', () => { - const milestoneId = ref<number>(); + const milestoneId = ref<number>(0); function setMilestoneId(id: number){ milestoneId.value = id + console.log(id) } return { milestoneId, setMilestoneId} diff --git a/src/utils/MilestonePathUtils.ts b/src/utils/MilestonePathUtils.ts index e71a818a78a60500401d440be74f18211fffb3a2..1d53c81e49723773a25f297bd3d2776dd9be321a 100644 --- a/src/utils/MilestonePathUtils.ts +++ b/src/utils/MilestonePathUtils.ts @@ -1,4 +1,5 @@ import axios from 'axios' +import {useTokenStore} from '@/stores/token' export async function getMilestoneDetails(id: number){ @@ -7,9 +8,9 @@ export async function getMilestoneDetails(id: number){ const config = { headers: { 'Content-Type': 'Application/json', - //'Authorization': 'Bearer ' + TokenStore().getToken() + 'Authorization': 'Bearer ' + useTokenStore().getJwtToken } } - return await axios.post("http://Localhost:8080/milestone/id", id, config); + return await axios.get("http://Localhost:8080/milestone/" + id, config); } \ No newline at end of file diff --git a/src/views/HomePage/MilestonePathView.vue b/src/views/HomePage/MilestonePathView.vue index a83a5c587bb6ebbedb987912d504e148c7b41219..0c3660f9313260007fb923bf0f833d4a5387d175 100644 --- a/src/views/HomePage/MilestonePathView.vue +++ b/src/views/HomePage/MilestonePathView.vue @@ -1,16 +1,17 @@ <script setup lang="ts"> import MilestoneProgress from '@/components/MilestonePath/MilestoneProgress.vue' -import { ref } from 'vue' +import { onMounted, ref } from 'vue' import DirectTransfer from '@/components/MilestonePath/DirectTransfer.vue' import MilestoneDescription from '@/components/MilestonePath/MilestoneDescription.vue' import MilestonePath from '@/components/MilestonePath/MilestonePath.vue' import { getMilestoneDetails } from '@/utils/MilestonePathUtils' +import { useMilestoneStore } from '@/stores/currentMilestone' const pathName = ref("PathNameHere") const pathDescription = ref("PathDescriptionHere") -const totalToSave = ref(2000) +const totalToSave = ref(3000) const totalSaved = ref(0) const showPath = ref(true); @@ -37,12 +38,17 @@ function showPathField(){ checkScreenWidth() -//Re-add when token store is up and running -//const response = getMilestoneDetails(1) -//pathName.value = response//data//milestoneTitle -//pathDescription.value = response//data//milestoneDescription -//totalToSave.value = response//data//milestoneGoalSum -//totalSaved.value = response//data//milestoneCurrentSum +onMounted( async () =>{ + const milestoneId = useMilestoneStore().milestoneId; + console.log(milestoneId) + const response = await getMilestoneDetails(milestoneId) + pathName.value = response.data.milestoneTitle + pathDescription.value = response.data.milestoneDescription + totalToSave.value = response.data.milestoneGoalSum + totalSaved.value = response.data.milestoneCurrentSum + milestonePathKey.value++; +}) + function updateTotalSaved(value: number) { totalSaved.value += value;