- try to fix bug of sum points
This commit is contained in:
Alexandrina-Kuzeleva
2025-11-20 15:23:59 +03:00
parent 0037c01beb
commit 22de38c72b

View File

@@ -84,14 +84,15 @@ const energyPoints = createResource({
order_by: 'creation desc',
limit_page_length: 1000
},
auto: true,
auto: false,
onSuccess(data) {
console.log('Баллы загружены:', data.length, 'записей')
}
})
const totalPoints = computed(() => {
return energyPoints.data?.reduce((sum, item) => sum + (item.points || 0), 0) || 0
const list = Array.isArray(energyPoints.data) ? energyPoints.data : []
return list.reduce((sum, item) => sum + (item.points || 0), 0)
})
const additionalPoints = computed(() => {
@@ -100,7 +101,7 @@ const additionalPoints = computed(() => {
})
const breadcrumbs = computed(() => [
{ label: 'Главная', route: '/app' },
{ label: 'Главная', route: '/' },
{ label: 'Мои баллы' }
])