modified: main_dc/BB/bbvue/src/App.vue
new file: main_dc/BB/bbvue/src/components/EventCard.vue new file: main_dc/BB/bbvue/src/components/RegistrationCard.vue modified: main_dc/BB/bbvue/src/router/index.js new file: main_dc/BB/bbvue/src/stores/event.js modified: main_dc/BB/bbvue/src/stores/helpers/api.js new file: main_dc/BB/bbvue/src/stores/personalBests.js new file: main_dc/BB/bbvue/src/stores/stats.js new file: main_dc/BB/bbvue/src/views/DetailedStats.vue new file: main_dc/BB/bbvue/src/views/Events.vue new file: main_dc/BB/bbvue/src/views/PersonalBests.vue modified: main_dc/BB/bbvue/src/views/Profile.vue add pages for stats, best-personal and stores
This commit is contained in:
@@ -42,7 +42,7 @@
|
||||
|
||||
<script>
|
||||
import NavigationMenu from './components/NavigationMenu.vue'
|
||||
import { useAuthStore } from '@/src/stores/auth'
|
||||
import { useAuthStore } from '@/src/stores/auth' // Добавлен импорт
|
||||
|
||||
export default {
|
||||
name: 'App',
|
||||
@@ -90,32 +90,8 @@ export default {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.menu-box-item {
|
||||
height: fit-content;
|
||||
padding: 0 1rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.r-link {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
.r-link:hover {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
.profile-icon {
|
||||
color: rgb(17, 17, 17);
|
||||
filter: drop-shadow(2px 2px 3px rgb(255, 255, 255));
|
||||
}
|
||||
|
||||
.h-menu {
|
||||
padding: 0;
|
||||
|
||||
@@ -0,0 +1,341 @@
|
||||
<template>
|
||||
<div class="event-card" :class="{ registered: isRegistered, past: isPast }">
|
||||
<div class="event-image" :style="imageStyle">
|
||||
<div class="event-type-badge" :class="event.type">
|
||||
{{ eventTypeLabel }}
|
||||
</div>
|
||||
<div v-if="isPast" class="event-status past">Прошедшее</div>
|
||||
<div v-else-if="!event.registration_open" class="event-status closed">Регистрация закрыта</div>
|
||||
<div v-else-if="isFull" class="event-status full">Мест нет</div>
|
||||
</div>
|
||||
|
||||
<div class="event-content">
|
||||
<h3 class="event-title">{{ event.title }}</h3>
|
||||
|
||||
<div class="event-meta">
|
||||
<div class="meta-item">
|
||||
<span class="icon">📅</span>
|
||||
<span>{{ formatDate(event.date) }}</span>
|
||||
</div>
|
||||
<div class="meta-item">
|
||||
<span class="icon">📍</span>
|
||||
<span>{{ event.location }}</span>
|
||||
</div>
|
||||
<div v-if="event.distance" class="meta-item">
|
||||
<span class="icon">🏃</span>
|
||||
<span>{{ event.distance }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="event-description">{{ truncateDescription(event.description) }}</p>
|
||||
|
||||
<div class="event-stats">
|
||||
<div class="stat">
|
||||
<span class="label">Участников:</span>
|
||||
<span class="value">{{ event.participants_count }}{{ event.max_participants > 0 ? `/${event.max_participants}` : '' }}</span>
|
||||
</div>
|
||||
<div v-if="isRegistered" class="registration-status confirmed">
|
||||
✅ Вы зарегистрированы
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="event-actions">
|
||||
<button
|
||||
v-if="showActions && !isPast && event.registration_open && !isFull && !isRegistered"
|
||||
class="btn btn-primary btn-sm"
|
||||
@click="$emit('register', event)"
|
||||
>
|
||||
🎫 Зарегистрироваться
|
||||
</button>
|
||||
|
||||
<button
|
||||
v-if="showActions && isRegistered"
|
||||
class="btn btn-danger btn-sm"
|
||||
@click="$emit('cancel', event.registration_id)"
|
||||
>
|
||||
❌ Отменить
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="btn btn-outline btn-sm"
|
||||
@click="$emit('view-details', event.id)"
|
||||
>
|
||||
👀 Подробнее
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { computed } from 'vue'
|
||||
|
||||
export default {
|
||||
name: 'EventCard',
|
||||
props: {
|
||||
event: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
userRegistrations: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
showActions: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
},
|
||||
emits: ['register', 'cancel', 'view-details'],
|
||||
setup(props) {
|
||||
const isRegistered = computed(() => {
|
||||
return props.userRegistrations.some(reg =>
|
||||
reg.event_id === props.event.id &&
|
||||
(reg.status === 'confirmed' || reg.status === 'pending')
|
||||
)
|
||||
})
|
||||
|
||||
const isPast = computed(() => {
|
||||
return new Date(props.event.date) <= new Date()
|
||||
})
|
||||
|
||||
const isFull = computed(() => {
|
||||
return props.event.max_participants > 0 &&
|
||||
props.event.participants_count >= props.event.max_participants
|
||||
})
|
||||
|
||||
const eventTypeLabel = computed(() => {
|
||||
const labels = {
|
||||
'race': 'Забег',
|
||||
'training': 'Тренировка',
|
||||
'social': 'Встреча',
|
||||
'workshop': 'Семинар'
|
||||
}
|
||||
return labels[props.event.type] || props.event.type
|
||||
})
|
||||
|
||||
const imageStyle = computed(() => {
|
||||
if (props.event.image) {
|
||||
return {
|
||||
backgroundImage: `url(${props.event.image})`
|
||||
}
|
||||
}
|
||||
// Градиенты по умолчанию для разных типов событий
|
||||
const gradients = {
|
||||
'race': 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
|
||||
'training': 'linear-gradient(135deg, #f093fb 0%, #f5576c 100%)',
|
||||
'social': 'linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)',
|
||||
'workshop': 'linear-gradient(135deg, #43e97b 0%, #38f9d7 100%)'
|
||||
}
|
||||
return {
|
||||
background: gradients[props.event.type] || 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)'
|
||||
}
|
||||
})
|
||||
|
||||
const formatDate = (dateString) => {
|
||||
return new Date(dateString).toLocaleDateString('ru-RU', {
|
||||
day: 'numeric',
|
||||
month: 'long',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit'
|
||||
})
|
||||
}
|
||||
|
||||
const truncateDescription = (description) => {
|
||||
if (description.length > 120) {
|
||||
return description.substring(0, 120) + '...'
|
||||
}
|
||||
return description
|
||||
}
|
||||
|
||||
return {
|
||||
isRegistered,
|
||||
isPast,
|
||||
isFull,
|
||||
eventTypeLabel,
|
||||
imageStyle,
|
||||
formatDate,
|
||||
truncateDescription
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.event-card {
|
||||
background: white;
|
||||
border-radius: 15px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||
transition: all 0.3s ease;
|
||||
border: 2px solid transparent;
|
||||
}
|
||||
|
||||
.event-card:hover {
|
||||
transform: translateY(-5px);
|
||||
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.event-card.registered {
|
||||
border-color: #28a745;
|
||||
}
|
||||
|
||||
.event-card.past {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.event-image {
|
||||
height: 160px;
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.event-type-badge {
|
||||
padding: 0.5rem 1rem;
|
||||
border-radius: 20px;
|
||||
color: white;
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.event-type-badge.race {
|
||||
background: rgba(102, 126, 234, 0.9);
|
||||
}
|
||||
|
||||
.event-type-badge.training {
|
||||
background: rgba(240, 147, 251, 0.9);
|
||||
}
|
||||
|
||||
.event-type-badge.social {
|
||||
background: rgba(79, 172, 254, 0.9);
|
||||
}
|
||||
|
||||
.event-type-badge.workshop {
|
||||
background: rgba(67, 233, 123, 0.9);
|
||||
}
|
||||
|
||||
.event-status {
|
||||
padding: 0.5rem 1rem;
|
||||
border-radius: 20px;
|
||||
color: white;
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
background: rgba(0, 0, 0, 0.7);
|
||||
}
|
||||
|
||||
.event-status.past {
|
||||
background: rgba(108, 117, 125, 0.9);
|
||||
}
|
||||
|
||||
.event-status.closed {
|
||||
background: rgba(220, 53, 69, 0.9);
|
||||
}
|
||||
|
||||
.event-status.full {
|
||||
background: rgba(253, 126, 20, 0.9);
|
||||
}
|
||||
|
||||
.event-content {
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
.event-title {
|
||||
margin: 0 0 1rem;
|
||||
font-size: 1.2rem;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.event-meta {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.meta-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
color: #666;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.meta-item .icon {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.event-description {
|
||||
margin: 0 0 1rem;
|
||||
color: #555;
|
||||
line-height: 1.5;
|
||||
font-size: 0.95rem;
|
||||
}
|
||||
|
||||
.event-stats {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 1rem;
|
||||
padding-top: 1rem;
|
||||
border-top: 1px solid #e9ecef;
|
||||
}
|
||||
|
||||
.stat {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.stat .label {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.stat .value {
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.registration-status {
|
||||
padding: 0.25rem 0.75rem;
|
||||
border-radius: 12px;
|
||||
font-size: 0.8rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.registration-status.confirmed {
|
||||
background: #d4edda;
|
||||
color: #155724;
|
||||
}
|
||||
|
||||
.event-actions {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.btn-sm {
|
||||
padding: 0.5rem 1rem;
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
/* Адаптивность */
|
||||
@media (max-width: 480px) {
|
||||
.event-actions {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.event-stats {
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
align-items: flex-start;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,227 @@
|
||||
<template>
|
||||
<div class="registration-card" :class="registration.status">
|
||||
<div class="registration-header">
|
||||
<h4>{{ registration.event.title }}</h4>
|
||||
<span class="status-badge" :class="registration.status">
|
||||
{{ statusLabel }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="registration-details">
|
||||
<div class="detail">
|
||||
<span class="label">Дата:</span>
|
||||
<span class="value">{{ formatDate(registration.event.date) }}</span>
|
||||
</div>
|
||||
<div class="detail">
|
||||
<span class="label">Место:</span>
|
||||
<span class="value">{{ registration.event.location }}</span>
|
||||
</div>
|
||||
<div v-if="registration.notes" class="detail">
|
||||
<span class="label">Заметки:</span>
|
||||
<span class="value">{{ registration.notes }}</span>
|
||||
</div>
|
||||
<div v-if="registration.result_time" class="detail">
|
||||
<span class="label">Результат:</span>
|
||||
<span class="value result-time">{{ registration.result_time }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="registration-actions">
|
||||
<button
|
||||
v-if="registration.status === 'pending'"
|
||||
class="btn btn-danger btn-sm"
|
||||
@click="$emit('cancel', registration.id)"
|
||||
>
|
||||
❌ Отменить заявку
|
||||
</button>
|
||||
<button
|
||||
v-else-if="registration.status === 'confirmed' && !isPast"
|
||||
class="btn btn-danger btn-sm"
|
||||
@click="$emit('cancel', registration.id)"
|
||||
>
|
||||
❌ Отменить участие
|
||||
</button>
|
||||
|
||||
<span v-if="isPast && !registration.result_time" class="no-result">
|
||||
⏳ Результат ожидается
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { computed } from 'vue'
|
||||
|
||||
export default {
|
||||
name: 'RegistrationCard',
|
||||
props: {
|
||||
registration: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
emits: ['cancel'],
|
||||
setup(props) {
|
||||
const statusLabel = computed(() => {
|
||||
const labels = {
|
||||
'pending': '⏳ Ожидает подтверждения',
|
||||
'confirmed': '✅ Подтверждено',
|
||||
'cancelled': '❌ Отменено',
|
||||
'completed': '🏁 Завершено'
|
||||
}
|
||||
return labels[props.registration.status] || props.registration.status
|
||||
})
|
||||
|
||||
const isPast = computed(() => {
|
||||
return new Date(props.registration.event.date) <= new Date()
|
||||
})
|
||||
|
||||
const formatDate = (dateString) => {
|
||||
return new Date(dateString).toLocaleDateString('ru-RU', {
|
||||
day: 'numeric',
|
||||
month: 'long',
|
||||
year: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit'
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
statusLabel,
|
||||
isPast,
|
||||
formatDate
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.registration-card {
|
||||
background: white;
|
||||
padding: 1.5rem;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||
border-left: 4px solid #6c757d;
|
||||
}
|
||||
|
||||
.registration-card.pending {
|
||||
border-left-color: #ffc107;
|
||||
}
|
||||
|
||||
.registration-card.confirmed {
|
||||
border-left-color: #28a745;
|
||||
}
|
||||
|
||||
.registration-card.cancelled {
|
||||
border-left-color: #dc3545;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.registration-card.completed {
|
||||
border-left-color: #007bff;
|
||||
}
|
||||
|
||||
.registration-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.registration-header h4 {
|
||||
margin: 0;
|
||||
color: #333;
|
||||
flex: 1;
|
||||
margin-right: 1rem;
|
||||
}
|
||||
|
||||
.status-badge {
|
||||
padding: 0.25rem 0.75rem;
|
||||
border-radius: 12px;
|
||||
font-size: 0.8rem;
|
||||
font-weight: 500;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.status-badge.pending {
|
||||
background: #fff3cd;
|
||||
color: #856404;
|
||||
}
|
||||
|
||||
.status-badge.confirmed {
|
||||
background: #d4edda;
|
||||
color: #155724;
|
||||
}
|
||||
|
||||
.status-badge.cancelled {
|
||||
background: #f8d7da;
|
||||
color: #721c24;
|
||||
}
|
||||
|
||||
.status-badge.completed {
|
||||
background: #cce7ff;
|
||||
color: #004085;
|
||||
}
|
||||
|
||||
.registration-details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.detail {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.detail .label {
|
||||
color: #666;
|
||||
font-weight: 500;
|
||||
min-width: 80px;
|
||||
}
|
||||
|
||||
.detail .value {
|
||||
color: #333;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.detail .result-time {
|
||||
font-weight: bold;
|
||||
color: #2e8b57;
|
||||
}
|
||||
|
||||
.registration-actions {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.no-result {
|
||||
color: #666;
|
||||
font-style: italic;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
/* Адаптивность */
|
||||
@media (max-width: 768px) {
|
||||
.registration-header {
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.registration-header h4 {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.detail {
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
.detail .label {
|
||||
min-width: auto;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -5,6 +5,18 @@ import { useAuthStore } from '../stores/auth'
|
||||
const router = createRouter({
|
||||
history: createWebHistory(import.meta.env.BASE_URL),
|
||||
routes: [
|
||||
{
|
||||
path: '/stats/detailed',
|
||||
name: 'DetailedStats',
|
||||
component: () => import('../views/DetailedStats.vue'),
|
||||
meta: { requiresAuth: true }
|
||||
},
|
||||
{
|
||||
path: '/stats/personal-bests',
|
||||
name: 'PersonalBests',
|
||||
component: () => import('../views/PersonalBests.vue'),
|
||||
meta: { requiresAuth: true }
|
||||
},
|
||||
{
|
||||
path: '/verify-email',
|
||||
name: 'VerifyEmail',
|
||||
@@ -102,6 +114,17 @@ const router = createRouter({
|
||||
path: '/logout',
|
||||
name: 'Logout',
|
||||
component: () => import('../views/Logout.vue')
|
||||
},
|
||||
{
|
||||
path: '/events',
|
||||
name: 'Events',
|
||||
component: () => import('../views/Events.vue')
|
||||
},
|
||||
// Можно добавить маршрут для детальной страницы события
|
||||
{
|
||||
path: '/events/:id',
|
||||
name: 'EventDetails',
|
||||
component: () => import('../views/DetailedStats.vue') // Создайте при необходимости
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
@@ -0,0 +1,313 @@
|
||||
// stores/events.js
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref, computed } from 'vue'
|
||||
import { apiClient, withLoading } from './helpers/api'
|
||||
|
||||
export const useEventsStore = defineStore('events', () => {
|
||||
// State
|
||||
const events = ref([])
|
||||
const userRegistrations = ref([])
|
||||
const eventDetails = ref(null)
|
||||
const loading = ref(false)
|
||||
const error = ref('')
|
||||
|
||||
// Getters
|
||||
const upcomingEvents = computed(() =>
|
||||
events.value
|
||||
.filter(event => new Date(event.date) > new Date())
|
||||
.sort((a, b) => new Date(a.date) - new Date(b.date))
|
||||
)
|
||||
|
||||
const pastEvents = computed(() =>
|
||||
events.value
|
||||
.filter(event => new Date(event.date) <= new Date())
|
||||
.sort((a, b) => new Date(b.date) - new Date(a.date))
|
||||
)
|
||||
|
||||
const registeredEvents = computed(() =>
|
||||
userRegistrations.value
|
||||
.filter(reg => reg.status === 'confirmed')
|
||||
.map(reg => ({
|
||||
...reg.event,
|
||||
registration_status: reg.status,
|
||||
registration_id: reg.id,
|
||||
result_time: reg.result_time
|
||||
}))
|
||||
)
|
||||
|
||||
const pendingRegistrations = computed(() =>
|
||||
userRegistrations.value.filter(reg => reg.status === 'pending')
|
||||
)
|
||||
|
||||
const eventTypes = {
|
||||
'race': 'Забег',
|
||||
'training': 'Тренировка',
|
||||
'social': 'Встреча',
|
||||
'workshop': 'Семинар'
|
||||
}
|
||||
|
||||
// Actions
|
||||
const fetchEvents = async (params = {}) => {
|
||||
return withLoading({ loading, error }, async () => {
|
||||
try {
|
||||
const queryString = new URLSearchParams(params).toString()
|
||||
const response = await apiClient.get(`/events?${queryString}`)
|
||||
events.value = response.data
|
||||
return { success: true, data: response.data }
|
||||
} catch (error) {
|
||||
console.warn('Events endpoint not available, using mock data', error)
|
||||
events.value = generateMockEvents()
|
||||
return { success: true, data: events.value }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const fetchUpcomingEvents = async () => {
|
||||
return withLoading({ loading, error }, async () => {
|
||||
try {
|
||||
const response = await apiClient.get('/events/upcoming')
|
||||
events.value = response.data
|
||||
return { success: true, data: response.data }
|
||||
} catch (error) {
|
||||
console.warn('Upcoming events endpoint not available', error)
|
||||
return { success: true, data: upcomingEvents.value }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const fetchEventDetails = async (eventId) => {
|
||||
return withLoading({ loading, error }, async () => {
|
||||
try {
|
||||
const response = await apiClient.get(`/events/${eventId}`)
|
||||
eventDetails.value = response.data
|
||||
return { success: true, data: response.data }
|
||||
} catch (error) {
|
||||
console.warn('Event details endpoint not available', error)
|
||||
eventDetails.value = events.value.find(event => event.id === parseInt(eventId)) || null
|
||||
return { success: true, data: eventDetails.value }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const fetchUserRegistrations = async () => {
|
||||
return withLoading({ loading, error }, async () => {
|
||||
try {
|
||||
const response = await apiClient.get('/events/my/registrations')
|
||||
userRegistrations.value = response.data
|
||||
return { success: true, data: response.data }
|
||||
} catch (error) {
|
||||
console.warn('User registrations endpoint not available, using mock data', error)
|
||||
userRegistrations.value = generateMockRegistrations()
|
||||
return { success: true, data: userRegistrations.value }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const registerForEvent = async (eventId, notes = '') => {
|
||||
return withLoading({ loading, error }, async () => {
|
||||
try {
|
||||
const response = await apiClient.post('/events/register', {
|
||||
event_id: eventId,
|
||||
notes: notes
|
||||
})
|
||||
|
||||
// Обновляем список регистраций
|
||||
await fetchUserRegistrations()
|
||||
return { success: true, data: response.data }
|
||||
} catch (error) {
|
||||
return { success: false, error: error.message }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const cancelRegistration = async (registrationId) => {
|
||||
return withLoading({ loading, error }, async () => {
|
||||
try {
|
||||
await apiClient.delete(`/events/registrations/${registrationId}`)
|
||||
|
||||
// Обновляем список регистраций
|
||||
await fetchUserRegistrations()
|
||||
return { success: true }
|
||||
} catch (error) {
|
||||
return { success: false, error: error.message }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const checkEventAvailability = async (eventId) => {
|
||||
return withLoading({ loading, error }, async () => {
|
||||
try {
|
||||
const response = await apiClient.get(`/events/${eventId}/availability`)
|
||||
return { success: true, data: response.data }
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
console.warn('Event availability endpoint not available')
|
||||
const event = events.value.find(e => e.id === parseInt(eventId))
|
||||
const available = event &&
|
||||
event.registration_open &&
|
||||
(event.max_participants === 0 || event.participants_count < event.max_participants)
|
||||
return { success: true, data: { available, remaining_spots: event.max_participants - event.participants_count } }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const createEvent = async (eventData) => {
|
||||
return withLoading({ loading, error }, async () => {
|
||||
try {
|
||||
const response = await apiClient.post('/events', eventData)
|
||||
events.value.push(response.data)
|
||||
return { success: true, data: response.data }
|
||||
} catch (error) {
|
||||
return { success: false, error: error.message }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const updateEvent = async (eventId, eventData) => {
|
||||
return withLoading({ loading, error }, async () => {
|
||||
try {
|
||||
const response = await apiClient.put(`/events/${eventId}`, eventData)
|
||||
const index = events.value.findIndex(event => event.id === parseInt(eventId))
|
||||
if (index !== -1) {
|
||||
events.value[index] = response.data
|
||||
}
|
||||
return { success: true, data: response.data }
|
||||
} catch (error) {
|
||||
return { success: false, error: error.message }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Вспомогательные функции для mock данных
|
||||
const generateMockEvents = () => {
|
||||
return [
|
||||
{
|
||||
id: 1,
|
||||
title: 'Весенний марафон 2024',
|
||||
description: 'Ежегодный весенний марафон по живописному маршруту через городской парк и набережную. Дистанции: 5км, 10км, полумарафон.',
|
||||
date: '2024-04-15T09:00:00',
|
||||
location: 'Городской парк, Центральный вход',
|
||||
type: 'race',
|
||||
distance: '5км, 10км, 21.1км',
|
||||
participants_count: 45,
|
||||
max_participants: 100,
|
||||
registration_open: true,
|
||||
image: '/images/spring-marathon.jpg',
|
||||
created_at: '2024-01-15T10:00:00'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
title: 'Тренировка для начинающих',
|
||||
description: 'Групповая тренировка для тех, кто только начинает бегать. Основы техники, дыхания и планирования тренировок.',
|
||||
date: '2024-03-20T18:30:00',
|
||||
location: 'Стадион "Спартак"',
|
||||
type: 'training',
|
||||
distance: '',
|
||||
participants_count: 12,
|
||||
max_participants: 20,
|
||||
registration_open: true,
|
||||
image: '/images/beginner-training.jpg',
|
||||
created_at: '2024-02-01T14:30:00'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
title: 'Встреча бегового клуба',
|
||||
description: 'Ежемесячная встреча участников бегового клуба. Обсуждение планов, обмен опытом, совместная пробежка.',
|
||||
date: '2024-03-25T19:00:00',
|
||||
location: 'Кафе "Бегун"',
|
||||
type: 'social',
|
||||
distance: '',
|
||||
participants_count: 8,
|
||||
max_participants: 0,
|
||||
registration_open: true,
|
||||
image: '/images/running-club.jpg',
|
||||
created_at: '2024-02-10T11:20:00'
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
title: 'Семинар по питанию для бегунов',
|
||||
description: 'Эксперт расскажет о правильном питании до, во время и после тренировок и соревнований.',
|
||||
date: '2024-04-05T17:00:00',
|
||||
location: 'Фитнес-центр "Актив"',
|
||||
type: 'workshop',
|
||||
distance: '',
|
||||
participants_count: 25,
|
||||
max_participants: 30,
|
||||
registration_open: true,
|
||||
image: '/images/nutrition-workshop.jpg',
|
||||
created_at: '2024-01-20T16:45:00'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
const generateMockRegistrations = () => {
|
||||
return [
|
||||
{
|
||||
id: 1,
|
||||
user_id: 1,
|
||||
event_id: 1,
|
||||
status: 'confirmed',
|
||||
notes: 'Участвую в полумарафоне',
|
||||
result_time: '',
|
||||
created_at: '2024-02-15T10:00:00',
|
||||
event: {
|
||||
id: 1,
|
||||
title: 'Весенний марафон 2024',
|
||||
date: '2024-04-15T09:00:00',
|
||||
location: 'Городской парк'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
user_id: 1,
|
||||
event_id: 2,
|
||||
status: 'pending',
|
||||
notes: '',
|
||||
result_time: '',
|
||||
created_at: '2024-03-01T14:20:00',
|
||||
event: {
|
||||
id: 2,
|
||||
title: 'Тренировка для начинающих',
|
||||
date: '2024-03-20T18:30:00',
|
||||
location: 'Стадион "Спартак"'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
const resetEventsStore = () => {
|
||||
events.value = []
|
||||
userRegistrations.value = []
|
||||
eventDetails.value = null
|
||||
loading.value = false
|
||||
error.value = ''
|
||||
}
|
||||
|
||||
return {
|
||||
// State
|
||||
events,
|
||||
userRegistrations,
|
||||
eventDetails,
|
||||
loading,
|
||||
error,
|
||||
|
||||
// Getters
|
||||
upcomingEvents,
|
||||
pastEvents,
|
||||
registeredEvents,
|
||||
pendingRegistrations,
|
||||
eventTypes,
|
||||
|
||||
// Actions
|
||||
fetchEvents,
|
||||
fetchUpcomingEvents,
|
||||
fetchEventDetails,
|
||||
fetchUserRegistrations,
|
||||
registerForEvent,
|
||||
cancelRegistration,
|
||||
checkEventAvailability,
|
||||
createEvent,
|
||||
updateEvent,
|
||||
resetEventsStore
|
||||
}
|
||||
})
|
||||
@@ -76,5 +76,6 @@ export const createLoadingHandler = (store) => {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const api = apiClient;
|
||||
export default apiClient;
|
||||
@@ -0,0 +1,245 @@
|
||||
// stores/personalBests.js
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref, computed } from 'vue'
|
||||
import { apiClient, withLoading } from './helpers/api'
|
||||
|
||||
export const usePersonalBestsStore = defineStore('personalBests', () => {
|
||||
// State
|
||||
const personalBests = ref([])
|
||||
const bestsSummary = ref(null)
|
||||
const loading = ref(false)
|
||||
const error = ref('')
|
||||
|
||||
// Getters
|
||||
const verifiedBests = computed(() =>
|
||||
personalBests.value.filter(best => best.verified)
|
||||
)
|
||||
|
||||
const pendingBests = computed(() =>
|
||||
personalBests.value.filter(best => !best.verified)
|
||||
)
|
||||
|
||||
const bestsByDistance = computed(() => {
|
||||
const grouped = {}
|
||||
personalBests.value.forEach(best => {
|
||||
if (!grouped[best.distance_type]) {
|
||||
grouped[best.distance_type] = []
|
||||
}
|
||||
grouped[best.distance_type].push(best)
|
||||
})
|
||||
return grouped
|
||||
})
|
||||
|
||||
const currentBests = computed(() => {
|
||||
const bests = {}
|
||||
personalBests.value.forEach(best => {
|
||||
if (!bests[best.distance_type] ||
|
||||
new Date(best.date) > new Date(bests[best.distance_type].date)) {
|
||||
bests[best.distance_type] = best
|
||||
}
|
||||
})
|
||||
return bests
|
||||
})
|
||||
|
||||
const distanceLabels = {
|
||||
'5k': '5 км',
|
||||
'10k': '10 км',
|
||||
'half_marathon': 'Полумарафон (21.1 км)',
|
||||
'marathon': 'Марафон (42.2 км)',
|
||||
'other': 'Другая дистанция'
|
||||
}
|
||||
|
||||
// Actions
|
||||
const fetchPersonalBests = async () => {
|
||||
return withLoading({ loading, error }, async () => {
|
||||
try {
|
||||
const response = await apiClient.get('/user/personal-bests')
|
||||
personalBests.value = response.data
|
||||
return { success: true, data: response.data }
|
||||
} catch (error) {
|
||||
console.warn('Personal bests endpoint not available, using mock data', error)
|
||||
personalBests.value = generateMockPersonalBests()
|
||||
return { success: true, data: personalBests.value }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const fetchBestsSummary = async () => {
|
||||
return withLoading({ loading, error }, async () => {
|
||||
try {
|
||||
const response = await apiClient.get('/user/personal-bests/summary')
|
||||
bestsSummary.value = response.data
|
||||
return { success: true, data: response.data }
|
||||
} catch (error) {
|
||||
console.warn('Personal bests summary endpoint not available', error)
|
||||
bestsSummary.value = generateBestsSummary()
|
||||
return { success: true, data: bestsSummary.value }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const createPersonalBest = async (bestData) => {
|
||||
return withLoading({ loading, error }, async () => {
|
||||
try {
|
||||
const response = await apiClient.post('/user/personal-bests', bestData)
|
||||
personalBests.value.push(response.data)
|
||||
return { success: true, data: response.data }
|
||||
} catch (error) {
|
||||
return { success: false, error: error.message }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const updatePersonalBest = async (id, updateData) => {
|
||||
return withLoading({ loading, error }, async () => {
|
||||
try {
|
||||
const response = await apiClient.put(`/user/personal-bests/${id}`, updateData)
|
||||
const index = personalBests.value.findIndex(best => best.id === id)
|
||||
if (index !== -1) {
|
||||
personalBests.value[index] = response.data
|
||||
}
|
||||
return { success: true, data: response.data }
|
||||
} catch (error) {
|
||||
return { success: false, error: error.message }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const deletePersonalBest = async (id) => {
|
||||
return withLoading({ loading, error }, async () => {
|
||||
try {
|
||||
await apiClient.delete(`/user/personal-bests/${id}`)
|
||||
personalBests.value = personalBests.value.filter(best => best.id !== id)
|
||||
return { success: true }
|
||||
} catch (error) {
|
||||
return { success: false, error: error.message }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const verifyPersonalBest = async (id) => {
|
||||
return withLoading({ loading, error }, async () => {
|
||||
try {
|
||||
const response = await apiClient.patch(`/user/personal-bests/${id}/verify`)
|
||||
const index = personalBests.value.findIndex(best => best.id === id)
|
||||
if (index !== -1) {
|
||||
personalBests.value[index] = response.data
|
||||
}
|
||||
return { success: true, data: response.data }
|
||||
} catch (error) {
|
||||
return { success: false, error: error.message }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const calculatePace = (distance, time) => {
|
||||
// time в формате "HH:MM:SS" или "MM:SS"
|
||||
const timeParts = time.split(':').map(part => parseInt(part))
|
||||
let totalSeconds = 0
|
||||
|
||||
if (timeParts.length === 2) {
|
||||
// MM:SS
|
||||
totalSeconds = timeParts[0] * 60 + timeParts[1]
|
||||
} else if (timeParts.length === 3) {
|
||||
// HH:MM:SS
|
||||
totalSeconds = timeParts[0] * 3600 + timeParts[1] * 60 + timeParts[2]
|
||||
}
|
||||
|
||||
const paceSecondsPerKm = totalSeconds / distance
|
||||
const paceMinutes = Math.floor(paceSecondsPerKm / 60)
|
||||
const paceSeconds = Math.round(paceSecondsPerKm % 60)
|
||||
|
||||
return `${paceMinutes}:${paceSeconds.toString().padStart(2, '0')}`
|
||||
}
|
||||
|
||||
// Вспомогательные функции для mock данных
|
||||
const generateMockPersonalBests = () => {
|
||||
return [
|
||||
{
|
||||
id: 1,
|
||||
distance_type: '5k',
|
||||
time: '23:45',
|
||||
pace: '4:45',
|
||||
date: '2024-03-15',
|
||||
verified: true,
|
||||
event_name: 'Весенний забег',
|
||||
location: 'Городской парк'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
distance_type: '10k',
|
||||
time: '48:15',
|
||||
pace: '4:49',
|
||||
date: '2024-02-20',
|
||||
verified: true,
|
||||
event_name: 'Зимний марафон',
|
||||
location: 'Центральный стадион'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
distance_type: 'half_marathon',
|
||||
time: '1:48:30',
|
||||
pace: '5:08',
|
||||
date: '2024-01-10',
|
||||
verified: true,
|
||||
event_name: 'Новогодний полумарафон',
|
||||
location: 'Набережная'
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
distance_type: '5k',
|
||||
time: '22:30',
|
||||
pace: '4:30',
|
||||
date: '2024-03-20',
|
||||
verified: false,
|
||||
event_name: 'Тренировочный забег',
|
||||
location: 'Лесопарк'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
const generateBestsSummary = () => {
|
||||
return {
|
||||
best_5k: '23:45',
|
||||
best_5k_pace: '4:45',
|
||||
best_10k: '48:15',
|
||||
best_10k_pace: '4:49',
|
||||
best_half_marathon: '1:48:30',
|
||||
best_half_marathon_pace: '5:08',
|
||||
best_marathon: null,
|
||||
best_marathon_pace: null
|
||||
}
|
||||
}
|
||||
|
||||
const resetPersonalBestsStore = () => {
|
||||
personalBests.value = []
|
||||
bestsSummary.value = null
|
||||
loading.value = false
|
||||
error.value = ''
|
||||
}
|
||||
|
||||
return {
|
||||
// State
|
||||
personalBests,
|
||||
bestsSummary,
|
||||
loading,
|
||||
error,
|
||||
|
||||
// Getters
|
||||
verifiedBests,
|
||||
pendingBests,
|
||||
bestsByDistance,
|
||||
currentBests,
|
||||
distanceLabels,
|
||||
|
||||
// Actions
|
||||
fetchPersonalBests,
|
||||
fetchBestsSummary,
|
||||
createPersonalBest,
|
||||
updatePersonalBest,
|
||||
deletePersonalBest,
|
||||
verifyPersonalBest,
|
||||
calculatePace,
|
||||
resetPersonalBestsStore
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,285 @@
|
||||
// stores/stats.js
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref, computed } from 'vue'
|
||||
import { apiClient, withLoading } from './helpers/api'
|
||||
|
||||
export const useStatsStore = defineStore('stats', () => {
|
||||
// State
|
||||
const detailedStats = ref(null)
|
||||
const workoutHistory = ref([])
|
||||
const monthlyStats = ref([])
|
||||
const yearlyStats = ref([])
|
||||
const paceAnalysis = ref(null)
|
||||
const progressTrends = ref([])
|
||||
const loading = ref(false)
|
||||
const error = ref('')
|
||||
|
||||
// Getters
|
||||
const totalWorkouts = computed(() => workoutHistory.value.length)
|
||||
|
||||
const totalDistance = computed(() =>
|
||||
detailedStats.value?.total_distance ||
|
||||
workoutHistory.value.reduce((sum, workout) => sum + (workout.distance_km || 0), 0)
|
||||
)
|
||||
|
||||
const totalTime = computed(() =>
|
||||
detailedStats.value?.total_time_min ||
|
||||
workoutHistory.value.reduce((sum, workout) => sum + (workout.duration_min || 0), 0)
|
||||
)
|
||||
|
||||
const averagePace = computed(() => {
|
||||
if (totalDistance.value === 0 || totalTime.value === 0) return '0:00'
|
||||
|
||||
const totalMinutes = totalTime.value
|
||||
const avgPaceMinPerKm = totalMinutes / totalDistance.value
|
||||
const minutes = Math.floor(avgPaceMinPerKm)
|
||||
const seconds = Math.round((avgPaceMinPerKm - minutes) * 60)
|
||||
return `${minutes}:${seconds.toString().padStart(2, '0')}`
|
||||
})
|
||||
|
||||
const weeklyStats = computed(() => {
|
||||
const last7Days = workoutHistory.value
|
||||
.filter(workout => {
|
||||
const workoutDate = new Date(workout.date)
|
||||
const weekAgo = new Date()
|
||||
weekAgo.setDate(weekAgo.getDate() - 7)
|
||||
return workoutDate >= weekAgo
|
||||
})
|
||||
|
||||
return {
|
||||
workouts: last7Days.length,
|
||||
distance: last7Days.reduce((sum, w) => sum + (w.distance_km || 0), 0),
|
||||
time: last7Days.reduce((sum, w) => sum + (w.duration_min || 0), 0)
|
||||
}
|
||||
})
|
||||
|
||||
// Actions
|
||||
const fetchDetailedStats = async () => {
|
||||
return withLoading({ loading, error }, async () => {
|
||||
try {
|
||||
const response = await apiClient.get('/user/stats/detailed')
|
||||
detailedStats.value = response.data
|
||||
return { success: true, data: response.data }
|
||||
} catch (error) {
|
||||
console.warn('Detailed stats endpoint not available, using fallback', error)
|
||||
// Fallback на базовую статистику
|
||||
return { success: true, data: detailedStats.value }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const fetchWorkoutHistory = async (params = {}) => {
|
||||
return withLoading({ loading, error }, async () => {
|
||||
try {
|
||||
const queryString = new URLSearchParams(params).toString()
|
||||
const response = await apiClient.get(`/user/workouts?${queryString}`)
|
||||
workoutHistory.value = response.data
|
||||
return { success: true, data: response.data }
|
||||
} catch (error) {
|
||||
console.warn('Workout history endpoint not available, using mock data', error)
|
||||
// Mock данные для демонстрации
|
||||
workoutHistory.value = generateMockWorkoutHistory()
|
||||
return { success: true, data: workoutHistory.value }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const fetchMonthlyStats = async () => {
|
||||
return withLoading({ loading, error }, async () => {
|
||||
try {
|
||||
const response = await apiClient.get('/user/stats/monthly')
|
||||
monthlyStats.value = response.data
|
||||
return { success: true, data: response.data }
|
||||
} catch (error) {
|
||||
console.warn('Monthly stats endpoint not available, generating from history', error)
|
||||
monthlyStats.value = generateMonthlyStatsFromHistory()
|
||||
return { success: true, data: monthlyStats.value }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const fetchYearlyStats = async () => {
|
||||
return withLoading({ loading, error }, async () => {
|
||||
try {
|
||||
const response = await apiClient.get('/user/stats/yearly')
|
||||
yearlyStats.value = response.data
|
||||
return { success: true, data: response.data }
|
||||
} catch (error) {
|
||||
console.warn('Yearly stats endpoint not available, generating from history', error)
|
||||
yearlyStats.value = generateYearlyStatsFromHistory()
|
||||
return { success: true, data: yearlyStats.value }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const fetchPaceAnalysis = async () => {
|
||||
return withLoading({ loading, error }, async () => {
|
||||
try {
|
||||
const response = await apiClient.get('/user/stats/pace-analysis')
|
||||
paceAnalysis.value = response.data
|
||||
return { success: true, data: response.data }
|
||||
} catch (error) {
|
||||
console.warn('Pace analysis endpoint not available, generating from history', error)
|
||||
paceAnalysis.value = generatePaceAnalysis()
|
||||
return { success: true, data: paceAnalysis.value }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const fetchProgressTrends = async (period = '6months') => {
|
||||
return withLoading({ loading, error }, async () => {
|
||||
try {
|
||||
const response = await apiClient.get(`/user/stats/progress-trends?period=${period}`)
|
||||
progressTrends.value = response.data
|
||||
return { success: true, data: response.data }
|
||||
} catch (error) {
|
||||
console.warn('Progress trends endpoint not available, generating mock data', error)
|
||||
progressTrends.value = generateProgressTrends(period)
|
||||
return { success: true, data: progressTrends.value }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const exportStats = async (format = 'csv') => {
|
||||
return withLoading({ loading, error }, async () => {
|
||||
try {
|
||||
const response = await apiClient.get(`/user/stats/export?format=${format}`, {
|
||||
responseType: 'blob'
|
||||
})
|
||||
return { success: true, data: response.data }
|
||||
} catch (error) {
|
||||
return { success: false, error: error.message }
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Вспомогательные функции для mock данных
|
||||
const generateMockWorkoutHistory = () => {
|
||||
const types = ['easy', 'tempo', 'interval', 'long', 'recovery']
|
||||
const history = []
|
||||
|
||||
for (let i = 0; i < 30; i++) {
|
||||
const date = new Date()
|
||||
date.setDate(date.getDate() - i * 2)
|
||||
|
||||
const type = types[Math.floor(Math.random() * types.length)]
|
||||
const distance = type === 'long' ?
|
||||
(8 + Math.random() * 12) :
|
||||
(3 + Math.random() * 7)
|
||||
|
||||
const pace = type === 'interval' ? '4:30' :
|
||||
type === 'tempo' ? '5:00' : '5:30'
|
||||
|
||||
history.push({
|
||||
id: i + 1,
|
||||
type,
|
||||
distance_km: parseFloat(distance.toFixed(1)),
|
||||
duration_min: Math.round(distance * (pace === '4:30' ? 4.5 : pace === '5:00' ? 5 : 5.5) * 60),
|
||||
pace,
|
||||
calories: Math.round(distance * 60),
|
||||
date: date.toISOString().split('T')[0],
|
||||
notes: i % 5 === 0 ? 'Хорошая тренировка' : ''
|
||||
})
|
||||
}
|
||||
|
||||
return history
|
||||
}
|
||||
|
||||
const generateMonthlyStatsFromHistory = () => {
|
||||
const months = []
|
||||
for (let i = 0; i < 6; i++) {
|
||||
const date = new Date()
|
||||
date.setMonth(date.getMonth() - i)
|
||||
months.push({
|
||||
month: date.toLocaleDateString('ru-RU', { month: 'long', year: 'numeric' }),
|
||||
distance_km: parseFloat((25 + Math.random() * 50).toFixed(1)),
|
||||
workouts: Math.floor(8 + Math.random() * 12),
|
||||
total_time_min: Math.floor(1500 + Math.random() * 3000)
|
||||
})
|
||||
}
|
||||
return months.reverse()
|
||||
}
|
||||
|
||||
const generateYearlyStatsFromHistory = () => {
|
||||
const years = []
|
||||
const currentYear = new Date().getFullYear()
|
||||
|
||||
for (let i = 0; i < 3; i++) {
|
||||
years.push({
|
||||
year: currentYear - i,
|
||||
distance_km: parseFloat((300 + Math.random() * 500).toFixed(1)),
|
||||
workouts: Math.floor(100 + Math.random() * 150),
|
||||
total_time_min: Math.floor(18000 + Math.random() * 20000)
|
||||
})
|
||||
}
|
||||
return years.reverse()
|
||||
}
|
||||
|
||||
const generatePaceAnalysis = () => {
|
||||
return {
|
||||
easy: '5:45',
|
||||
tempo: '5:15',
|
||||
interval: '4:45',
|
||||
long: '5:30',
|
||||
recovery: '6:00',
|
||||
overall_trend: 'improving',
|
||||
best_pace: '4:30',
|
||||
best_pace_date: '2024-03-15'
|
||||
}
|
||||
}
|
||||
|
||||
const generateProgressTrends = (period) => {
|
||||
const trends = []
|
||||
const points = period === '6months' ? 6 : 12
|
||||
|
||||
for (let i = 0; i < points; i++) {
|
||||
trends.push({
|
||||
period: `Период ${i + 1}`,
|
||||
distance: parseFloat((20 + Math.random() * 30).toFixed(1)),
|
||||
pace: parseFloat((5.0 + Math.random() * 1.0).toFixed(2)),
|
||||
workouts: Math.floor(8 + Math.random() * 8)
|
||||
})
|
||||
}
|
||||
return trends
|
||||
}
|
||||
|
||||
const resetStatsStore = () => {
|
||||
detailedStats.value = null
|
||||
workoutHistory.value = []
|
||||
monthlyStats.value = []
|
||||
yearlyStats.value = []
|
||||
paceAnalysis.value = null
|
||||
progressTrends.value = []
|
||||
loading.value = false
|
||||
error.value = ''
|
||||
}
|
||||
|
||||
return {
|
||||
// State
|
||||
detailedStats,
|
||||
workoutHistory,
|
||||
monthlyStats,
|
||||
yearlyStats,
|
||||
paceAnalysis,
|
||||
progressTrends,
|
||||
loading,
|
||||
error,
|
||||
|
||||
// Getters
|
||||
totalWorkouts,
|
||||
totalDistance,
|
||||
totalTime,
|
||||
averagePace,
|
||||
weeklyStats,
|
||||
|
||||
// Actions
|
||||
fetchDetailedStats,
|
||||
fetchWorkoutHistory,
|
||||
fetchMonthlyStats,
|
||||
fetchYearlyStats,
|
||||
fetchPaceAnalysis,
|
||||
fetchProgressTrends,
|
||||
exportStats,
|
||||
resetStatsStore
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,525 @@
|
||||
<template>
|
||||
<div class="page detailed-stats">
|
||||
<div class="page-header">
|
||||
<button class="btn btn-back" @click="$router.go(-1)">← Назад</button>
|
||||
<h1>📊 Подробная статистика</h1>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="loading">Загрузка статистики...</div>
|
||||
|
||||
<div v-else class="stats-content">
|
||||
<!-- Общая сводка -->
|
||||
<div class="stats-summary">
|
||||
<h2>Общая сводка</h2>
|
||||
<div class="summary-grid">
|
||||
<div class="summary-card">
|
||||
<h3>🏃 Всего пробег</h3>
|
||||
<p class="value">{{ totalDistance }} км</p>
|
||||
</div>
|
||||
<div class="summary-card">
|
||||
<h3>⏱️ Общее время</h3>
|
||||
<p class="value">{{ formatTime(totalTime) }}</p>
|
||||
</div>
|
||||
<div class="summary-card">
|
||||
<h3>📅 Тренировок</h3>
|
||||
<p class="value">{{ totalWorkouts }}</p>
|
||||
</div>
|
||||
<div class="summary-card">
|
||||
<h3>⚡ Средний темп</h3>
|
||||
<p class="value">{{ averagePace }}/км</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Статистика за неделю -->
|
||||
<div class="stats-section">
|
||||
<h2>📅 Статистика за неделю</h2>
|
||||
<div class="weekly-stats">
|
||||
<div class="stat-item">
|
||||
<span class="label">Пробег:</span>
|
||||
<span class="value">{{ weeklyStats.distance }} км</span>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<span class="label">Тренировки:</span>
|
||||
<span class="value">{{ weeklyStats.workouts }}</span>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<span class="label">Время:</span>
|
||||
<span class="value">{{ formatTime(weeklyStats.time) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- История тренировок -->
|
||||
<div class="stats-section">
|
||||
<div class="section-header">
|
||||
<h2>📈 История тренировок</h2>
|
||||
<div class="filters">
|
||||
<select v-model="workoutFilter" @change="applyWorkoutFilters">
|
||||
<option value="all">Все типы</option>
|
||||
<option value="easy">Легкие</option>
|
||||
<option value="tempo">Темповые</option>
|
||||
<option value="interval">Интервалы</option>
|
||||
<option value="long">Длинные</option>
|
||||
</select>
|
||||
<select v-model="timeFilter" @change="applyWorkoutFilters">
|
||||
<option value="30">30 дней</option>
|
||||
<option value="90">90 дней</option>
|
||||
<option value="365">Год</option>
|
||||
<option value="all">Все время</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="workout-history">
|
||||
<div v-for="workout in workoutHistory" :key="workout.id" class="workout-card">
|
||||
<div class="workout-header">
|
||||
<span class="workout-type" :class="workout.type">{{ getWorkoutTypeLabel(workout.type) }}</span>
|
||||
<span class="workout-date">{{ formatDate(workout.date) }}</span>
|
||||
</div>
|
||||
<div class="workout-details">
|
||||
<div class="detail">
|
||||
<span class="label">Дистанция:</span>
|
||||
<span class="value">{{ workout.distance_km }} км</span>
|
||||
</div>
|
||||
<div class="detail">
|
||||
<span class="label">Время:</span>
|
||||
<span class="value">{{ formatTime(workout.duration_min) }}</span>
|
||||
</div>
|
||||
<div class="detail">
|
||||
<span class="label">Темп:</span>
|
||||
<span class="value">{{ workout.pace }}/км</span>
|
||||
</div>
|
||||
<div v-if="workout.calories" class="detail">
|
||||
<span class="label">Калории:</span>
|
||||
<span class="value">{{ workout.calories }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="workout.notes" class="workout-notes">
|
||||
{{ workout.notes }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Ежемесячная статистика -->
|
||||
<div class="stats-section">
|
||||
<h2>📊 Ежемесячная статистика</h2>
|
||||
<div class="monthly-stats">
|
||||
<div v-for="month in monthlyStats" :key="month.month" class="month-stat">
|
||||
<h4>{{ month.month }}</h4>
|
||||
<div class="stat-details">
|
||||
<span>{{ month.distance_km }} км</span>
|
||||
<span>{{ month.workouts }} тренировок</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Анализ темпа -->
|
||||
<div v-if="paceAnalysis" class="stats-section">
|
||||
<h2>⚡ Анализ темпа</h2>
|
||||
<div class="pace-analysis">
|
||||
<div class="pace-item">
|
||||
<span>Легкие:</span>
|
||||
<strong>{{ paceAnalysis.easy }}/км</strong>
|
||||
</div>
|
||||
<div class="pace-item">
|
||||
<span>Темповые:</span>
|
||||
<strong>{{ paceAnalysis.tempo }}/км</strong>
|
||||
</div>
|
||||
<div class="pace-item">
|
||||
<span>Интервалы:</span>
|
||||
<strong>{{ paceAnalysis.interval }}/км</strong>
|
||||
</div>
|
||||
<div class="pace-item">
|
||||
<span>Длинные:</span>
|
||||
<strong>{{ paceAnalysis.long }}/км</strong>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Кнопки действий -->
|
||||
<div class="action-buttons">
|
||||
<button class="btn btn-outline" @click="refreshStats">
|
||||
🔄 Обновить статистику
|
||||
</button>
|
||||
<button class="btn btn-secondary" @click="exportStats">
|
||||
📥 Экспорт данных
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="error" class="error-message">
|
||||
{{ error }}
|
||||
<button class="btn-retry" @click="loadStatsData">Попробовать снова</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { useStatsStore } from '../stores/stats'
|
||||
import { ref, onMounted, computed } from 'vue'
|
||||
|
||||
export default {
|
||||
name: 'DetailedStats',
|
||||
setup() {
|
||||
const statsStore = useStatsStore()
|
||||
|
||||
// Фильтры
|
||||
const workoutFilter = ref('all')
|
||||
const timeFilter = ref('30')
|
||||
|
||||
// Загрузка данных
|
||||
const loadStatsData = async () => {
|
||||
await Promise.all([
|
||||
statsStore.fetchDetailedStats(),
|
||||
statsStore.fetchWorkoutHistory(),
|
||||
statsStore.fetchMonthlyStats(),
|
||||
statsStore.fetchPaceAnalysis()
|
||||
])
|
||||
}
|
||||
|
||||
// Применение фильтров
|
||||
const applyWorkoutFilters = () => {
|
||||
const params = {}
|
||||
if (workoutFilter.value !== 'all') {
|
||||
params.type = workoutFilter.value
|
||||
}
|
||||
if (timeFilter.value !== 'all') {
|
||||
params.days = timeFilter.value
|
||||
}
|
||||
statsStore.fetchWorkoutHistory(params)
|
||||
}
|
||||
|
||||
// Экспорт данных
|
||||
const exportStats = async () => {
|
||||
const result = await statsStore.exportStats('csv')
|
||||
if (result.success) {
|
||||
// Создаем временную ссылку для скачивания
|
||||
const url = window.URL.createObjectURL(result.data)
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
link.setAttribute('download', `running_stats_${new Date().toISOString().split('T')[0]}.csv`)
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
link.remove()
|
||||
window.URL.revokeObjectURL(url)
|
||||
}
|
||||
}
|
||||
|
||||
// Обновление статистики
|
||||
const refreshStats = async () => {
|
||||
await loadStatsData()
|
||||
}
|
||||
|
||||
// Форматирование времени
|
||||
const formatTime = (minutes) => {
|
||||
if (!minutes) return '0 мин'
|
||||
const hours = Math.floor(minutes / 60)
|
||||
const mins = minutes % 60
|
||||
return hours > 0 ? `${hours}ч ${mins}мин` : `${mins} мин`
|
||||
}
|
||||
|
||||
// Форматирование даты
|
||||
const formatDate = (dateString) => {
|
||||
return new Date(dateString).toLocaleDateString('ru-RU')
|
||||
}
|
||||
|
||||
// Метки типов тренировок
|
||||
const getWorkoutTypeLabel = (type) => {
|
||||
const labels = {
|
||||
'easy': 'Легкая',
|
||||
'tempo': 'Темповая',
|
||||
'interval': 'Интервалы',
|
||||
'long': 'Длинная',
|
||||
'recovery': 'Восстановительная'
|
||||
}
|
||||
return labels[type] || type
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadStatsData()
|
||||
})
|
||||
|
||||
return {
|
||||
loading: computed(() => statsStore.loading),
|
||||
error: computed(() => statsStore.error),
|
||||
totalDistance: computed(() => statsStore.totalDistance),
|
||||
totalTime: computed(() => statsStore.totalTime),
|
||||
totalWorkouts: computed(() => statsStore.totalWorkouts),
|
||||
averagePace: computed(() => statsStore.averagePace),
|
||||
weeklyStats: computed(() => statsStore.weeklyStats),
|
||||
workoutHistory: computed(() => statsStore.workoutHistory),
|
||||
monthlyStats: computed(() => statsStore.monthlyStats),
|
||||
paceAnalysis: computed(() => statsStore.paceAnalysis),
|
||||
workoutFilter,
|
||||
timeFilter,
|
||||
applyWorkoutFilters,
|
||||
exportStats,
|
||||
refreshStats,
|
||||
formatTime,
|
||||
formatDate,
|
||||
getWorkoutTypeLabel,
|
||||
loadStatsData
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.detailed-stats {
|
||||
max-width: 1000px;
|
||||
margin: 0 auto;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.btn-back {
|
||||
background: #6c757d;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 0.5rem 1rem;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.btn-back:hover {
|
||||
background: #545b62;
|
||||
}
|
||||
|
||||
.stats-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2rem;
|
||||
}
|
||||
|
||||
.stats-summary {
|
||||
background: white;
|
||||
padding: 1.5rem;
|
||||
border-radius: 15px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.summary-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: 1rem;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.summary-card {
|
||||
background: linear-gradient(135deg, #f8f9fa, #e9ecef);
|
||||
padding: 1.5rem;
|
||||
border-radius: 12px;
|
||||
text-align: center;
|
||||
border: 2px solid #e9ecef;
|
||||
}
|
||||
|
||||
.summary-card h3 {
|
||||
margin: 0 0 0.5rem;
|
||||
color: #555;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.summary-card .value {
|
||||
margin: 0;
|
||||
font-size: 1.5rem;
|
||||
font-weight: bold;
|
||||
color: #2e8b57;
|
||||
}
|
||||
|
||||
.stats-section {
|
||||
background: white;
|
||||
padding: 1.5rem;
|
||||
border-radius: 15px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.section-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.filters {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.filters select {
|
||||
padding: 0.5rem;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 6px;
|
||||
background: white;
|
||||
}
|
||||
|
||||
.weekly-stats {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 1rem;
|
||||
background: #f8f9fa;
|
||||
border-radius: 8px;
|
||||
border-left: 4px solid #2e8b57;
|
||||
}
|
||||
|
||||
.workout-history {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
max-height: 400px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.workout-card {
|
||||
background: #f8f9fa;
|
||||
padding: 1rem;
|
||||
border-radius: 10px;
|
||||
border-left: 4px solid #2e8b57;
|
||||
}
|
||||
|
||||
.workout-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.workout-type {
|
||||
padding: 0.25rem 0.5rem;
|
||||
border-radius: 12px;
|
||||
font-size: 0.8rem;
|
||||
font-weight: 500;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.workout-type.easy { background: #28a745; }
|
||||
.workout-type.tempo { background: #ffc107; color: #000; }
|
||||
.workout-type.interval { background: #dc3545; }
|
||||
.workout-type.long { background: #007bff; }
|
||||
.workout-type.recovery { background: #6c757d; }
|
||||
|
||||
.workout-date {
|
||||
color: #666;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.workout-details {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
|
||||
gap: 0.5rem;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.detail {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.detail .label {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.detail .value {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.workout-notes {
|
||||
padding-top: 0.5rem;
|
||||
border-top: 1px solid #e9ecef;
|
||||
color: #555;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.monthly-stats {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.month-stat {
|
||||
background: #f8f9fa;
|
||||
padding: 1rem;
|
||||
border-radius: 8px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.month-stat h4 {
|
||||
margin: 0 0 0.5rem;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.stat-details {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.pace-analysis {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.pace-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 1rem;
|
||||
background: #f8f9fa;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.btn-retry {
|
||||
background: #2e8b57;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 0.5rem 1rem;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
margin-left: 1rem;
|
||||
}
|
||||
|
||||
.btn-retry:hover {
|
||||
background: #26734d;
|
||||
}
|
||||
|
||||
/* Адаптивность */
|
||||
@media (max-width: 768px) {
|
||||
.section-header {
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.filters {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.summary-grid {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,426 @@
|
||||
<template>
|
||||
<div class="page events-page">
|
||||
<!-- ... остальной код без изменений ... -->
|
||||
|
||||
<!-- Предстоящие события -->
|
||||
<div v-if="activeTab === 'upcoming'" class="events-section">
|
||||
<h2>🔮 Предстоящие события</h2>
|
||||
<div v-if="filteredUpcomingEvents.length === 0" class="empty-state">
|
||||
<p>Нет предстоящих событий</p>
|
||||
<button class="btn btn-primary" @click="refreshEvents">
|
||||
🔄 Обновить
|
||||
</button>
|
||||
</div>
|
||||
<div v-else class="events-grid">
|
||||
<EventCard
|
||||
v-for="event in filteredUpcomingEvents"
|
||||
:key="event.id"
|
||||
:event="event"
|
||||
:user-registrations="userRegistrations"
|
||||
@register="handleRegister"
|
||||
@view-details="viewEventDetails"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ... остальной код без изменений ... -->
|
||||
|
||||
<!-- Модальное окно регистрации -->
|
||||
<div v-if="showRegistrationModal" class="modal-overlay" @click="closeRegistrationModal">
|
||||
<div class="modal-content" @click.stop>
|
||||
<div class="modal-header">
|
||||
<h3>🎫 Регистрация на событие</h3>
|
||||
<button class="btn-close" @click="closeRegistrationModal">×</button>
|
||||
</div>
|
||||
|
||||
<div v-if="selectedEvent" class="event-preview">
|
||||
<h4>{{ selectedEvent.title }}</h4>
|
||||
<div class="event-details">
|
||||
<div class="detail">
|
||||
<span class="icon">📅</span>
|
||||
<span>{{ formatDate(selectedEvent.date) }}</span>
|
||||
</div>
|
||||
<div class="detail">
|
||||
<span class="icon">📍</span>
|
||||
<span>{{ selectedEvent.location }}</span>
|
||||
</div>
|
||||
<div v-if="selectedEvent.distance" class="detail">
|
||||
<span class="icon">🏃</span>
|
||||
<span>{{ selectedEvent.distance }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Проверка доступности -->
|
||||
<div v-if="availabilityCheck" class="availability-info">
|
||||
<div v-if="availabilityCheck.available" class="available">
|
||||
✅ Есть свободные места
|
||||
<span v-if="availabilityCheck.remaining_spots > 0">
|
||||
(осталось: {{ availabilityCheck.remaining_spots }})
|
||||
</span>
|
||||
</div>
|
||||
<div v-else class="not-available">
|
||||
❌ Регистрация закрыта или нет свободных мест
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form @submit.prevent="confirmRegistration">
|
||||
<div class="form-group">
|
||||
<label>Дополнительные заметки (необязательно)</label>
|
||||
<textarea
|
||||
v-model="registrationNotes"
|
||||
placeholder="Например: Участвую в дистанции 10км, особые пожелания, диетические ограничения..."
|
||||
rows="4"
|
||||
maxlength="500"
|
||||
></textarea>
|
||||
<div class="char-count">{{ registrationNotes.length }}/500</div>
|
||||
</div>
|
||||
|
||||
<div class="form-info">
|
||||
<p>📝 После регистрации вы получите подтверждение на email и сможете отслеживать статус в разделе "Мои регистрации".</p>
|
||||
</div>
|
||||
|
||||
<div class="modal-actions">
|
||||
<button
|
||||
type="submit"
|
||||
class="btn btn-primary"
|
||||
:disabled="registering || !availabilityCheck?.available"
|
||||
>
|
||||
{{ registering ? '⏳ Регистрируем...' : '✅ Зарегистрироваться' }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-outline"
|
||||
@click="closeRegistrationModal"
|
||||
:disabled="registering"
|
||||
>
|
||||
Отмена
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Уведомление об успехе -->
|
||||
<div v-if="showSuccessNotification" class="notification success">
|
||||
<div class="notification-content">
|
||||
<span>✅ Вы успешно зарегистрировались на событие!</span>
|
||||
<button class="btn-close" @click="showSuccessNotification = false">×</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { useEventsStore } from '../stores/events'
|
||||
import { ref, onMounted, computed, watch } from 'vue'
|
||||
import EventCard from '../components/EventCard.vue'
|
||||
|
||||
export default {
|
||||
// eslint-disable-next-line vue/multi-word-component-names
|
||||
name: 'Events',
|
||||
components: {
|
||||
EventCard,
|
||||
},
|
||||
setup() {
|
||||
const eventsStore = useEventsStore()
|
||||
|
||||
// Состояние
|
||||
const activeTab = ref('upcoming')
|
||||
const typeFilter = ref('')
|
||||
const showRegistrationModal = ref(false)
|
||||
const selectedEvent = ref(null)
|
||||
const registrationNotes = ref('')
|
||||
const registering = ref(false)
|
||||
const availabilityCheck = ref(null)
|
||||
const showSuccessNotification = ref(false)
|
||||
|
||||
// Computed
|
||||
const filteredUpcomingEvents = computed(() => {
|
||||
let events = eventsStore.upcomingEvents
|
||||
if (typeFilter.value) {
|
||||
events = events.filter(event => event.type === typeFilter.value)
|
||||
}
|
||||
return events
|
||||
})
|
||||
|
||||
// Watch для проверки доступности при выборе события
|
||||
watch(selectedEvent, async (newEvent) => {
|
||||
if (newEvent) {
|
||||
const result = await eventsStore.checkEventAvailability(newEvent.id)
|
||||
if (result.success) {
|
||||
availabilityCheck.value = result.data
|
||||
}
|
||||
} else {
|
||||
availabilityCheck.value = null
|
||||
}
|
||||
})
|
||||
|
||||
// Методы
|
||||
const loadEventsData = async () => {
|
||||
await Promise.all([
|
||||
eventsStore.fetchEvents(),
|
||||
eventsStore.fetchUserRegistrations()
|
||||
])
|
||||
}
|
||||
|
||||
const refreshEvents = async () => {
|
||||
await loadEventsData()
|
||||
}
|
||||
|
||||
const applyFilters = () => {
|
||||
// Фильтры применяются в computed свойствах
|
||||
}
|
||||
|
||||
const handleRegister = async (event) => {
|
||||
selectedEvent.value = event
|
||||
registrationNotes.value = ''
|
||||
showRegistrationModal.value = true
|
||||
|
||||
// Проверяем доступность
|
||||
const result = await eventsStore.checkEventAvailability(event.id)
|
||||
if (result.success) {
|
||||
availabilityCheck.value = result.data
|
||||
}
|
||||
}
|
||||
|
||||
const confirmRegistration = async () => {
|
||||
if (!selectedEvent.value || !availabilityCheck.value?.available) return
|
||||
|
||||
registering.value = true
|
||||
const result = await eventsStore.registerForEvent(
|
||||
selectedEvent.value.id,
|
||||
registrationNotes.value
|
||||
)
|
||||
registering.value = false
|
||||
|
||||
if (result.success) {
|
||||
closeRegistrationModal()
|
||||
showSuccessNotification.value = true
|
||||
// Автоматически скрываем уведомление через 5 секунд
|
||||
setTimeout(() => {
|
||||
showSuccessNotification.value = false
|
||||
}, 5000)
|
||||
|
||||
// Переключаемся на вкладку "Мои регистрации"
|
||||
activeTab.value = 'my'
|
||||
} else {
|
||||
alert('Ошибка при регистрации: ' + result.error)
|
||||
}
|
||||
}
|
||||
|
||||
const handleCancelRegistration = async (registrationId) => {
|
||||
if (confirm('Вы уверены, что хотите отменить регистрацию?')) {
|
||||
const result = await eventsStore.cancelRegistration(registrationId)
|
||||
if (result.success) {
|
||||
// Показываем уведомление об отмене
|
||||
alert('Регистрация успешно отменена')
|
||||
} else {
|
||||
alert('Ошибка при отмене регистрации: ' + result.error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const viewEventDetails = (eventId) => {
|
||||
// Переход на страницу деталей события
|
||||
// Можно реализовать позже отдельную страницу
|
||||
const event = eventsStore.events.find(e => e.id === parseInt(eventId))
|
||||
if (event) {
|
||||
alert(`Детали события: ${event.title}\n\n${event.description}`)
|
||||
}
|
||||
}
|
||||
|
||||
const closeRegistrationModal = () => {
|
||||
if (!registering.value) {
|
||||
showRegistrationModal.value = false
|
||||
selectedEvent.value = null
|
||||
registrationNotes.value = ''
|
||||
availabilityCheck.value = null
|
||||
}
|
||||
}
|
||||
|
||||
const formatDate = (dateString) => {
|
||||
return new Date(dateString).toLocaleDateString('ru-RU', {
|
||||
day: 'numeric',
|
||||
month: 'long',
|
||||
year: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit'
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadEventsData()
|
||||
})
|
||||
|
||||
return {
|
||||
loading: computed(() => eventsStore.loading),
|
||||
error: computed(() => eventsStore.error),
|
||||
upcomingEvents: computed(() => eventsStore.upcomingEvents),
|
||||
pastEvents: computed(() => eventsStore.pastEvents),
|
||||
registeredEvents: computed(() => eventsStore.registeredEvents),
|
||||
pendingRegistrations: computed(() => eventsStore.pendingRegistrations),
|
||||
userRegistrations: computed(() => eventsStore.userRegistrations),
|
||||
activeTab,
|
||||
typeFilter,
|
||||
showRegistrationModal,
|
||||
selectedEvent,
|
||||
registrationNotes,
|
||||
registering,
|
||||
availabilityCheck,
|
||||
showSuccessNotification,
|
||||
filteredUpcomingEvents,
|
||||
loadEventsData,
|
||||
refreshEvents,
|
||||
applyFilters,
|
||||
handleRegister,
|
||||
confirmRegistration,
|
||||
handleCancelRegistration,
|
||||
viewEventDetails,
|
||||
closeRegistrationModal,
|
||||
formatDate
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* ... существующие стили ... */
|
||||
|
||||
.modal-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.modal-header h3 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.btn-close {
|
||||
background: none;
|
||||
border: none;
|
||||
font-size: 1.5rem;
|
||||
cursor: pointer;
|
||||
color: #666;
|
||||
padding: 0;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.btn-close:hover {
|
||||
background: #f8f9fa;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.event-details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
margin: 1rem 0;
|
||||
}
|
||||
|
||||
.detail {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.detail .icon {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.availability-info {
|
||||
margin: 1rem 0;
|
||||
padding: 0.75rem;
|
||||
border-radius: 8px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.availability-info .available {
|
||||
color: #155724;
|
||||
background: #d4edda;
|
||||
padding: 0.5rem;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.availability-info .not-available {
|
||||
color: #721c24;
|
||||
background: #f8d7da;
|
||||
padding: 0.5rem;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.char-count {
|
||||
text-align: right;
|
||||
font-size: 0.8rem;
|
||||
color: #666;
|
||||
margin-top: 0.25rem;
|
||||
}
|
||||
|
||||
.form-info {
|
||||
background: #e7f3ff;
|
||||
padding: 0.75rem;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 1.5rem;
|
||||
font-size: 0.9rem;
|
||||
color: #004085;
|
||||
}
|
||||
|
||||
.form-info p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.notification {
|
||||
position: fixed;
|
||||
top: 20px;
|
||||
right: 20px;
|
||||
z-index: 1001;
|
||||
animation: slideIn 0.3s ease;
|
||||
}
|
||||
|
||||
.notification.success {
|
||||
background: #d4edda;
|
||||
color: #155724;
|
||||
border: 1px solid #c3e6cb;
|
||||
}
|
||||
|
||||
.notification-content {
|
||||
padding: 1rem 1.5rem;
|
||||
border-radius: 8px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
@keyframes slideIn {
|
||||
from {
|
||||
transform: translateX(100%);
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
transform: translateX(0);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Адаптивность */
|
||||
@media (max-width: 768px) {
|
||||
.notification {
|
||||
left: 20px;
|
||||
right: 20px;
|
||||
top: 10px;
|
||||
}
|
||||
|
||||
.notification-content {
|
||||
padding: 0.75rem 1rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,693 @@
|
||||
<template>
|
||||
<div class="page personal-bests">
|
||||
<div class="page-header">
|
||||
<button class="btn btn-back" @click="$router.go(-1)">← Назад</button>
|
||||
<h1>⭐ Мои рекорды</h1>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="loading">Загрузка рекордов...</div>
|
||||
|
||||
<div v-else class="bests-content">
|
||||
<!-- Сводка лучших результатов -->
|
||||
<div class="bests-summary">
|
||||
<h2>🏆 Лучшие результаты</h2>
|
||||
<div class="summary-grid">
|
||||
<div v-for="(best, distance) in currentBests" :key="distance" class="best-summary-card">
|
||||
<h3>{{ distanceLabels[distance] }}</h3>
|
||||
<p class="time">{{ best.time }}</p>
|
||||
<p class="pace">Темп: {{ best.pace }}/км</p>
|
||||
<p class="date">{{ formatDate(best.date) }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Подтвержденные рекорды -->
|
||||
<div class="bests-section">
|
||||
<h2>✅ Подтвержденные рекорды</h2>
|
||||
<div class="bests-list">
|
||||
<div v-for="best in verifiedBests" :key="best.id" class="best-card verified">
|
||||
<div class="best-header">
|
||||
<h3>{{ distanceLabels[best.distance_type] }}</h3>
|
||||
<span class="verification-badge">✅ Подтверждено</span>
|
||||
</div>
|
||||
<div class="best-details">
|
||||
<div class="time">{{ best.time }}</div>
|
||||
<div class="pace">Темп: {{ best.pace }}/км</div>
|
||||
<div class="event">{{ best.event_name }}</div>
|
||||
<div class="date-location">
|
||||
<span>{{ formatDate(best.date) }}</span>
|
||||
<span v-if="best.location"> • {{ best.location }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="best-actions">
|
||||
<button class="btn btn-outline" @click="editBest(best)">
|
||||
✏️ Редактировать
|
||||
</button>
|
||||
<button class="btn btn-danger" @click="deleteBest(best.id)">
|
||||
🗑️ Удалить
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Ожидающие подтверждения -->
|
||||
<div v-if="pendingBests.length > 0" class="bests-section">
|
||||
<h2>⏳ Ожидают подтверждения</h2>
|
||||
<div class="bests-list">
|
||||
<div v-for="best in pendingBests" :key="best.id" class="best-card pending">
|
||||
<div class="best-header">
|
||||
<h3>{{ distanceLabels[best.distance_type] }}</h3>
|
||||
<span class="verification-badge pending">⏳ Ожидает</span>
|
||||
</div>
|
||||
<div class="best-details">
|
||||
<div class="time">{{ best.time }}</div>
|
||||
<div class="pace">Темп: {{ best.pace }}/км</div>
|
||||
<div class="event">{{ best.event_name }}</div>
|
||||
<div class="date-location">
|
||||
<span>{{ formatDate(best.date) }}</span>
|
||||
<span v-if="best.location"> • {{ best.location }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="best-actions">
|
||||
<button class="btn btn-success" @click="verifyBest(best.id)">
|
||||
✅ Подтвердить
|
||||
</button>
|
||||
<button class="btn btn-outline" @click="editBest(best)">
|
||||
✏️ Редактировать
|
||||
</button>
|
||||
<button class="btn btn-danger" @click="deleteBest(best.id)">
|
||||
🗑️ Удалить
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Добавление нового рекорда -->
|
||||
<div class="bests-section">
|
||||
<div class="section-header">
|
||||
<h2>➕ Добавить новый рекорд</h2>
|
||||
</div>
|
||||
<form @submit.prevent="addNewBest" class="add-best-form">
|
||||
<div class="form-grid">
|
||||
<div class="form-group">
|
||||
<label>Дистанция *</label>
|
||||
<select v-model="newBest.distance_type" required>
|
||||
<option value="">Выберите дистанцию</option>
|
||||
<option value="5k">5 км</option>
|
||||
<option value="10k">10 км</option>
|
||||
<option value="half_marathon">Полумарафон (21.1 км)</option>
|
||||
<option value="marathon">Марафон (42.2 км)</option>
|
||||
<option value="other">Другая дистанция</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Время *</label>
|
||||
<input
|
||||
v-model="newBest.time"
|
||||
type="text"
|
||||
placeholder="MM:SS или HH:MM:SS"
|
||||
required
|
||||
@input="calculatePace"
|
||||
>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Темп</label>
|
||||
<input v-model="newBest.pace" type="text" readonly>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Дата *</label>
|
||||
<input v-model="newBest.date" type="date" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Название забега/события</label>
|
||||
<input v-model="newBest.event_name" type="text" placeholder="Например: Весенний марафон">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Место проведения</label>
|
||||
<input v-model="newBest.location" type="text" placeholder="Например: Центральный стадион">
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-primary" :disabled="addingBest">
|
||||
{{ addingBest ? 'Добавление...' : '➕ Добавить рекорд' }}
|
||||
</button>
|
||||
<button type="button" class="btn btn-outline" @click="resetForm">
|
||||
Очистить
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Кнопки действий -->
|
||||
<div class="action-buttons">
|
||||
<button class="btn btn-outline" @click="refreshBests">
|
||||
🔄 Обновить рекорды
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Модальное окно редактирования -->
|
||||
<div v-if="editingBest" class="modal-overlay" @click="closeModal">
|
||||
<div class="modal-content" @click.stop>
|
||||
<h3>✏️ Редактировать рекорд</h3>
|
||||
<form @submit.prevent="updateBest">
|
||||
<div class="form-grid">
|
||||
<div class="form-group">
|
||||
<label>Дистанция</label>
|
||||
<select v-model="editingBest.distance_type" required>
|
||||
<option value="5k">5 км</option>
|
||||
<option value="10k">10 км</option>
|
||||
<option value="half_marathon">Полумарафон (21.1 км)</option>
|
||||
<option value="marathon">Марафон (42.2 км)</option>
|
||||
<option value="other">Другая дистанция</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Время</label>
|
||||
<input
|
||||
v-model="editingBest.time"
|
||||
type="text"
|
||||
required
|
||||
@input="calculatePaceForEdit"
|
||||
>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Темп</label>
|
||||
<input v-model="editingBest.pace" type="text" readonly>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Дата</label>
|
||||
<input v-model="editingBest.date" type="date" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Название забега/события</label>
|
||||
<input v-model="editingBest.event_name" type="text">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Место проведения</label>
|
||||
<input v-model="editingBest.location" type="text">
|
||||
</div>
|
||||
|
||||
<div class="modal-actions">
|
||||
<button type="submit" class="btn btn-primary" :disabled="updatingBest">
|
||||
{{ updatingBest ? 'Сохранение...' : '💾 Сохранить' }}
|
||||
</button>
|
||||
<button type="button" class="btn btn-outline" @click="closeModal">
|
||||
Отмена
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="error" class="error-message">
|
||||
{{ error }}
|
||||
<button class="btn-retry" @click="loadBestsData">Попробовать снова</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { usePersonalBestsStore } from '../stores/personalBests'
|
||||
import { ref, onMounted, computed } from 'vue'
|
||||
|
||||
export default {
|
||||
name: 'PersonalBests',
|
||||
setup() {
|
||||
const personalBestsStore = usePersonalBestsStore()
|
||||
|
||||
// Состояние формы
|
||||
const newBest = ref({
|
||||
distance_type: '',
|
||||
time: '',
|
||||
pace: '',
|
||||
date: new Date().toISOString().split('T')[0],
|
||||
event_name: '',
|
||||
location: ''
|
||||
})
|
||||
|
||||
const editingBest = ref(null)
|
||||
const addingBest = ref(false)
|
||||
const updatingBest = ref(false)
|
||||
|
||||
// Загрузка данных
|
||||
const loadBestsData = async () => {
|
||||
await Promise.all([
|
||||
personalBestsStore.fetchPersonalBests(),
|
||||
personalBestsStore.fetchBestsSummary()
|
||||
])
|
||||
}
|
||||
|
||||
// Добавление нового рекорда
|
||||
const addNewBest = async () => {
|
||||
addingBest.value = true
|
||||
const result = await personalBestsStore.createPersonalBest(newBest.value)
|
||||
addingBest.value = false
|
||||
|
||||
if (result.success) {
|
||||
resetForm()
|
||||
} else {
|
||||
alert('Ошибка при добавлении рекорда: ' + result.error)
|
||||
}
|
||||
}
|
||||
|
||||
// Редактирование рекорда
|
||||
const editBest = (best) => {
|
||||
editingBest.value = { ...best }
|
||||
}
|
||||
|
||||
const updateBest = async () => {
|
||||
if (!editingBest.value) return
|
||||
|
||||
updatingBest.value = true
|
||||
const result = await personalBestsStore.updatePersonalBest(
|
||||
editingBest.value.id,
|
||||
editingBest.value
|
||||
)
|
||||
updatingBest.value = false
|
||||
|
||||
if (result.success) {
|
||||
closeModal()
|
||||
} else {
|
||||
alert('Ошибка при обновлении рекорда: ' + result.error)
|
||||
}
|
||||
}
|
||||
|
||||
// Удаление рекорда
|
||||
const deleteBest = async (id) => {
|
||||
if (confirm('Вы уверены, что хотите удалить этот рекорд?')) {
|
||||
const result = await personalBestsStore.deletePersonalBest(id)
|
||||
if (!result.success) {
|
||||
alert('Ошибка при удалении рекорда: ' + result.error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Подтверждение рекорда
|
||||
const verifyBest = async (id) => {
|
||||
const result = await personalBestsStore.verifyPersonalBest(id)
|
||||
if (!result.success) {
|
||||
alert('Ошибка при подтверждении рекорда: ' + result.error)
|
||||
}
|
||||
}
|
||||
|
||||
// Расчет темпа
|
||||
const calculatePace = () => {
|
||||
if (!newBest.value.distance_type || !newBest.value.time) return
|
||||
|
||||
const distance = getDistanceInKm(newBest.value.distance_type)
|
||||
if (distance) {
|
||||
newBest.value.pace = personalBestsStore.calculatePace(distance, newBest.value.time)
|
||||
}
|
||||
}
|
||||
|
||||
const calculatePaceForEdit = () => {
|
||||
if (!editingBest.value?.distance_type || !editingBest.value.time) return
|
||||
|
||||
const distance = getDistanceInKm(editingBest.value.distance_type)
|
||||
if (distance) {
|
||||
editingBest.value.pace = personalBestsStore.calculatePace(distance, editingBest.value.time)
|
||||
}
|
||||
}
|
||||
|
||||
// Получение дистанции в км
|
||||
const getDistanceInKm = (distanceType) => {
|
||||
const distances = {
|
||||
'5k': 5,
|
||||
'10k': 10,
|
||||
'half_marathon': 21.1,
|
||||
'marathon': 42.2
|
||||
}
|
||||
return distances[distanceType]
|
||||
}
|
||||
|
||||
// Сброс формы
|
||||
const resetForm = () => {
|
||||
newBest.value = {
|
||||
distance_type: '',
|
||||
time: '',
|
||||
pace: '',
|
||||
date: new Date().toISOString().split('T')[0],
|
||||
event_name: '',
|
||||
location: ''
|
||||
}
|
||||
}
|
||||
|
||||
// Закрытие модального окна
|
||||
const closeModal = () => {
|
||||
editingBest.value = null
|
||||
}
|
||||
|
||||
// Обновление данных
|
||||
const refreshBests = async () => {
|
||||
await loadBestsData()
|
||||
}
|
||||
|
||||
// Форматирование даты
|
||||
const formatDate = (dateString) => {
|
||||
return new Date(dateString).toLocaleDateString('ru-RU')
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadBestsData()
|
||||
})
|
||||
|
||||
return {
|
||||
loading: computed(() => personalBestsStore.loading),
|
||||
error: computed(() => personalBestsStore.error),
|
||||
verifiedBests: computed(() => personalBestsStore.verifiedBests),
|
||||
pendingBests: computed(() => personalBestsStore.pendingBests),
|
||||
currentBests: computed(() => personalBestsStore.currentBests),
|
||||
distanceLabels: computed(() => personalBestsStore.distanceLabels),
|
||||
newBest,
|
||||
editingBest,
|
||||
addingBest,
|
||||
updatingBest,
|
||||
addNewBest,
|
||||
editBest,
|
||||
updateBest,
|
||||
deleteBest,
|
||||
verifyBest,
|
||||
calculatePace,
|
||||
calculatePaceForEdit,
|
||||
resetForm,
|
||||
closeModal,
|
||||
refreshBests,
|
||||
formatDate,
|
||||
loadBestsData
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.personal-bests {
|
||||
max-width: 1000px;
|
||||
margin: 0 auto;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.btn-back {
|
||||
background: #6c757d;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 0.5rem 1rem;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.btn-back:hover {
|
||||
background: #545b62;
|
||||
}
|
||||
|
||||
.bests-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2rem;
|
||||
}
|
||||
|
||||
.bests-summary {
|
||||
background: white;
|
||||
padding: 1.5rem;
|
||||
border-radius: 15px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.summary-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
||||
gap: 1rem;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.best-summary-card {
|
||||
background: linear-gradient(135deg, #fff3cd, #ffeaa7);
|
||||
padding: 1.5rem;
|
||||
border-radius: 12px;
|
||||
text-align: center;
|
||||
border: 2px solid #ffd43b;
|
||||
}
|
||||
|
||||
.best-summary-card h3 {
|
||||
margin: 0 0 0.5rem;
|
||||
color: #856404;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.best-summary-card .time {
|
||||
margin: 0.5rem 0;
|
||||
font-size: 1.5rem;
|
||||
font-weight: bold;
|
||||
color: #e67700;
|
||||
}
|
||||
|
||||
.best-summary-card .pace {
|
||||
margin: 0.25rem 0;
|
||||
color: #856404;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.best-summary-card .date {
|
||||
margin: 0.25rem 0;
|
||||
color: #666;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.bests-section {
|
||||
background: white;
|
||||
padding: 1.5rem;
|
||||
border-radius: 15px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.bests-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.best-card {
|
||||
background: #f8f9fa;
|
||||
padding: 1.5rem;
|
||||
border-radius: 10px;
|
||||
border-left: 4px solid;
|
||||
}
|
||||
|
||||
.best-card.verified {
|
||||
border-left-color: #28a745;
|
||||
}
|
||||
|
||||
.best-card.pending {
|
||||
border-left-color: #ffc107;
|
||||
}
|
||||
|
||||
.best-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.best-header h3 {
|
||||
margin: 0;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.verification-badge {
|
||||
padding: 0.25rem 0.5rem;
|
||||
border-radius: 12px;
|
||||
font-size: 0.8rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.verification-badge:not(.pending) {
|
||||
background: #d4edda;
|
||||
color: #155724;
|
||||
}
|
||||
|
||||
.verification-badge.pending {
|
||||
background: #fff3cd;
|
||||
color: #856404;
|
||||
}
|
||||
|
||||
.best-details {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.best-details .time {
|
||||
font-size: 1.5rem;
|
||||
font-weight: bold;
|
||||
color: #2e8b57;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.best-details .pace {
|
||||
color: #666;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.best-details .event {
|
||||
font-weight: 500;
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.best-details .date-location {
|
||||
color: #666;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.best-actions {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.add-best-form {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.form-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: 1rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.form-group label {
|
||||
margin-bottom: 0.5rem;
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.form-group input,
|
||||
.form-group select {
|
||||
padding: 0.75rem;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 6px;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.form-group input:focus,
|
||||
.form-group select:focus {
|
||||
outline: none;
|
||||
border-color: #2e8b57;
|
||||
box-shadow: 0 0 0 2px rgba(46, 139, 87, 0.2);
|
||||
}
|
||||
|
||||
.form-actions {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.modal-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
background: white;
|
||||
padding: 2rem;
|
||||
border-radius: 15px;
|
||||
width: 90%;
|
||||
max-width: 500px;
|
||||
max-height: 90vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.modal-content h3 {
|
||||
margin: 0 0 1.5rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.modal-actions {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
justify-content: center;
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.btn-retry {
|
||||
background: #2e8b57;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 0.5rem 1rem;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
margin-left: 1rem;
|
||||
}
|
||||
|
||||
.btn-retry:hover {
|
||||
background: #26734d;
|
||||
}
|
||||
|
||||
/* Адаптивность */
|
||||
@media (max-width: 768px) {
|
||||
.summary-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.best-header {
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.best-actions {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.form-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.form-actions {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
width: 95%;
|
||||
padding: 1rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -176,7 +176,7 @@
|
||||
<div class="profile-actions">
|
||||
<button class="btn" @click="editProfile">✏️ Редактировать профиль</button>
|
||||
<button class="btn" @click="viewDetailedStats">📊 Подробная статистика</button>
|
||||
<button class="btn" @click="$router.push('/personal-bests')">⭐ Мои рекорды</button>
|
||||
<button class="btn" @click="$router.push('/stats/personal-bests')">⭐ Мои рекорды</button>
|
||||
<button class="btn" @click="$router.push('/events')">📅 События</button>
|
||||
<button class="btn btn-logout" @click="handleLogout" :disabled="authLoading">
|
||||
{{ authLoading ? 'Выход...' : '🚪 Выйти' }}
|
||||
@@ -191,6 +191,8 @@
|
||||
|
||||
<button class="btn btn-secondary" @click="$router.push('/')">← На главную</button>
|
||||
</div>
|
||||
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
Reference in New Issue
Block a user