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

This commit is contained in:
2026-05-21 19:34:08 +03:00
parent 32b8bdfd24
commit 2e7ce6c2e8
21 changed files with 569 additions and 23 deletions
+19 -1
View File
@@ -1,7 +1,10 @@
<script setup lang="ts">
import type { Lecture } from '@/types'
import { computed, ref } from 'vue'
import { useRouter } from 'vue-router'
import { useUserStore } from '@/stores/user'
import AppIcon from '@/components/ui/AppIcon.vue'
import EnrollmentLimitModal from '@/components/ui/EnrollmentLimitModal.vue'
const props = defineProps<{
lecture: Lecture
@@ -10,6 +13,11 @@ const props = defineProps<{
}>()
const emit = defineEmits<{ register: [id: string] }>()
const router = useRouter()
const userStore = useUserStore()
const enrollmentLimitModalOpen = ref(false)
const isRegistrationLimitReached = computed(() =>
!props.registered && !userStore.hasEnrollmentSlotAvailable
)
function formatDate(d: string) {
const date = new Date(d)
@@ -24,6 +32,15 @@ function starsHtml(rating: number) {
function goDetail() {
router.push(`/lecture/${props.lecture.id}`)
}
function register() {
if (isRegistrationLimitReached.value) {
enrollmentLimitModalOpen.value = true
return
}
emit('register', props.lecture.id)
}
</script>
<template>
@@ -98,7 +115,7 @@ function goDetail() {
<button
v-else-if="lecture.freeSeats > 0 && !lecture.registrationClosed"
class="btn-primary btn-sm"
@click.stop="emit('register', lecture.id)"
@click.stop="register"
>
Записаться
</button>
@@ -106,6 +123,7 @@ function goDetail() {
{{ lecture.registrationClosed ? 'Запись закрыта' : 'Мест нет' }}
</button>
</div>
<EnrollmentLimitModal v-model="enrollmentLimitModalOpen" />
</div>
</template>