diff --git a/frontend/src/pages/MyPoints.vue b/frontend/src/pages/MyPoints.vue index 4e34d5f6..8d8cc9c0 100644 --- a/frontend/src/pages/MyPoints.vue +++ b/frontend/src/pages/MyPoints.vue @@ -166,10 +166,15 @@ const differencePoints = computed(() => todayPoints.value - yesterdayPoints.value ) -const weeklyPoints = computed(() => - getPointsByDate(dayjs().subtract(7, 'day').format('YYYY-MM-DD')) -) +const weeklyPoints = computed(() => { + if (!Array.isArray(energyPoints.data)) return 0 + const weekAgo = dayjs().subtract(7, 'day').startOf('day') + + return energyPoints.data + .filter(item => dayjs(item.creation).isAfter(weekAgo)) + .reduce((sum, item) => sum + (item.points || 0), 0) +}) onMounted(() => { if ($user.data) { energyPoints.fetch()