From d1d6361c91f23a17e066898e09d824af0938850a Mon Sep 17 00:00:00 2001 From: valitovgaziz Date: Mon, 20 Oct 2025 21:25:46 +0500 Subject: [PATCH] modified: serv_nginx/bbvue/src/stores/user.js add export useStore --- serv_nginx/bbvue/src/stores/user.js | 71 +++++++++++++++-------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/serv_nginx/bbvue/src/stores/user.js b/serv_nginx/bbvue/src/stores/user.js index 2cd1dc7..4161677 100644 --- a/serv_nginx/bbvue/src/stores/user.js +++ b/serv_nginx/bbvue/src/stores/user.js @@ -16,11 +16,11 @@ export const useUserStore = defineStore('user', () => { const error = ref('') // Getters - const completedAchievements = computed(() => + const completedAchievements = computed(() => userAchievements.value.filter(achievement => achievement.verified || achievement.achieved) ) - - const pendingAchievements = computed(() => + + const pendingAchievements = computed(() => userAchievements.value.filter(achievement => !(achievement.verified || achievement.achieved)) ) @@ -29,19 +29,19 @@ export const useUserStore = defineStore('user', () => { return Math.round((completedAchievements.value.length / userAchievements.value.length) * 100) }) - const verifiedPersonalBests = computed(() => + const verifiedPersonalBests = computed(() => personalBests.value.filter(best => best.verified) ) - const confirmedEvents = computed(() => + const confirmedEvents = computed(() => upcomingEvents.value.filter(event => event.registrationStatus === 'confirmed') ) - const totalWorkouts = computed(() => + const totalWorkouts = computed(() => userStats.value?.workoutsCount || workoutHistory.value.length ) - const totalCalories = computed(() => + const totalCalories = computed(() => workoutHistory.value.reduce((sum, workout) => sum + (workout.calories || 0), 0) ) @@ -102,46 +102,46 @@ export const useUserStore = defineStore('user', () => { } catch (error) { console.warn('Achievements endpoint not available, using mock data', error) userAchievements.value = [ - { - id: 1, + { + id: 1, type: 'distance', - title: 'Первый забег', - description: 'Пробежать первую 5км', - verified: true, + title: 'Первый забег', + description: 'Пробежать первую 5км', + verified: true, date: '2024-01-20', badgeImage: '/badges/first-run.png' }, - { - id: 2, + { + id: 2, type: 'consistency', - title: 'Неделя тренировок', - description: 'Тренироваться 7 дней подряд', - verified: true, + title: 'Неделя тренировок', + description: 'Тренироваться 7 дней подряд', + verified: true, date: '2024-02-15', badgeImage: '/badges/week-streak.png' }, - { - id: 3, + { + id: 3, type: 'distance', - title: '100 км', - description: 'Пробежать 100 км', - verified: true, + title: '100 км', + description: 'Пробежать 100 км', + verified: true, date: '2024-03-01', badgeImage: '/badges/100km.png' }, - { - id: 4, + { + id: 4, type: 'distance', - title: 'Полумарафон', - description: 'Пробежать 21.1 км', + title: 'Полумарафон', + description: 'Пробежать 21.1 км', verified: false, badgeImage: '/badges/half-marathon.png' }, - { - id: 5, + { + id: 5, type: 'speed', - title: 'Скорость', - description: 'Пробежать 5км быстрее 25 минут', + title: 'Скорость', + description: 'Пробежать 5км быстрее 25 минут', verified: false, badgeImage: '/badges/speedster.png' } @@ -152,7 +152,7 @@ export const useUserStore = defineStore('user', () => { } // Новые actions для дополнительных данных - const fetchPersonalBests = async () => { + const fetchPersonalBests = async () => { return withStoreLoading(async () => { try { const response = await apiClient.get('/user/personal-bests') @@ -353,7 +353,7 @@ export const useUserStore = defineStore('user', () => { workoutHistory, loading, error, - + // Getters completedAchievements, pendingAchievements, @@ -362,7 +362,7 @@ export const useUserStore = defineStore('user', () => { confirmedEvents, totalWorkouts, totalCalories, - + // Actions fetchUserStats, fetchUserAchievements, @@ -376,4 +376,7 @@ export const useUserStore = defineStore('user', () => { completeWorkout, resetUserStore } -}) \ No newline at end of file +}) + + +export const userStore = useUserStore \ No newline at end of file