feat: добавил ограничение записи на лекции
Backend CI / build-and-test (push) Failing after 32s
Frontend CI / build-and-check (push) Failing after 5m5s
🚀 Create and publish a Docker image / Detect changes in backend and frontend (push) Successful in 6s
🚀 Create and publish a Docker image / Build & publish backend image (push) Failing after 1m28s
🚀 Create and publish a Docker image / Build & publish frontend image (push) Failing after 19s
🚀 Create and publish a Docker image / Update stack on Portainer (push) Has been skipped
Backend CI / build-and-test (push) Failing after 32s
Frontend CI / build-and-check (push) Failing after 5m5s
🚀 Create and publish a Docker image / Detect changes in backend and frontend (push) Successful in 6s
🚀 Create and publish a Docker image / Build & publish backend image (push) Failing after 1m28s
🚀 Create and publish a Docker image / Build & publish frontend image (push) Failing after 19s
🚀 Create and publish a Docker image / Update stack on Portainer (push) Has been skipped
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted } from 'vue'
|
||||
import { computed, inject, onMounted, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { useLecturesStore } from '@/stores/lectures'
|
||||
@@ -11,12 +11,15 @@ import ProgressBar from '@/components/ui/ProgressBar.vue'
|
||||
import AchievementBadge from '@/components/ui/AchievementBadge.vue'
|
||||
import EmptyState from '@/components/ui/EmptyState.vue'
|
||||
import AppIcon from '@/components/ui/AppIcon.vue'
|
||||
import EnrollmentLimitModal from '@/components/ui/EnrollmentLimitModal.vue'
|
||||
import { formatUserName } from '@/utils/formatUserName'
|
||||
|
||||
const auth = useAuthStore()
|
||||
const lectures = useLecturesStore()
|
||||
const userStore = useUserStore()
|
||||
const router = useRouter()
|
||||
const enrollmentLimitModalOpen = ref(false)
|
||||
const addToast = inject('addToast') as ((message: string, type?: 'success' | 'error' | 'info') => void) | undefined
|
||||
|
||||
const user = computed(() => auth.user!)
|
||||
|
||||
@@ -60,6 +63,19 @@ onMounted(async () => {
|
||||
])
|
||||
await lectures.fetchRegisteredForCurrentUser()
|
||||
})
|
||||
|
||||
async function registerLecture(id: string) {
|
||||
try {
|
||||
await lectures.register(id)
|
||||
addToast?.('Вы записаны на лекцию.', 'success')
|
||||
} catch (err) {
|
||||
if (err instanceof Error && err.message.includes('Лимит записей достигнут')) {
|
||||
enrollmentLimitModalOpen.value = true
|
||||
return
|
||||
}
|
||||
addToast?.(err instanceof Error ? err.message : 'Не удалось записаться на лекцию.', 'error')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -128,7 +144,7 @@ onMounted(async () => {
|
||||
<h2 class="section-title">
|
||||
<span class="title-with-icon">
|
||||
<AppIcon class="title-icon" icon="sparkles" :size="18" />
|
||||
Рекомендуемые лекции
|
||||
Ближайшие лекции
|
||||
</span>
|
||||
</h2>
|
||||
<button class="link-btn" @click="router.push('/catalog')">Все лекции →</button>
|
||||
@@ -140,7 +156,7 @@ onMounted(async () => {
|
||||
:key="l.id"
|
||||
:lecture="l"
|
||||
:registered="lectures.registeredIds.includes(l.id)"
|
||||
@register="lectures.register"
|
||||
@register="registerLecture"
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
@@ -182,6 +198,8 @@ onMounted(async () => {
|
||||
</div>
|
||||
</GlassCard>
|
||||
</section>
|
||||
|
||||
<EnrollmentLimitModal v-model="enrollmentLimitModalOpen" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user