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:
@@ -8,6 +8,7 @@ import FilterChips from '@/components/ui/FilterChips.vue'
|
||||
import EmptyState from '@/components/ui/EmptyState.vue'
|
||||
import DataTable from '@/components/ui/DataTable.vue'
|
||||
import ModalDialog from '@/components/ui/ModalDialog.vue'
|
||||
import EnrollmentLimitModal from '@/components/ui/EnrollmentLimitModal.vue'
|
||||
|
||||
const lecturesStore = useLecturesStore()
|
||||
const search = ref('')
|
||||
@@ -19,6 +20,7 @@ const building = ref('Все корпуса')
|
||||
const format = ref<'all' | 'online' | 'offline'>('all')
|
||||
const onlyFree = ref(false)
|
||||
const filtersOpen = ref(false)
|
||||
const enrollmentLimitModalOpen = ref(false)
|
||||
const addToast = inject('addToast') as ((message: string, type?: 'success' | 'error' | 'info') => void) | undefined
|
||||
|
||||
onMounted(() => {
|
||||
@@ -101,11 +103,19 @@ const calendarGroups = computed(() => {
|
||||
return Object.entries(groups)
|
||||
})
|
||||
|
||||
function isEnrollmentLimitError(err: unknown) {
|
||||
return err instanceof Error && err.message.includes('Лимит записей достигнут')
|
||||
}
|
||||
|
||||
async function registerLecture(id: string) {
|
||||
try {
|
||||
await lecturesStore.register(id)
|
||||
addToast?.('Вы записаны на лекцию.', 'success')
|
||||
} catch (err) {
|
||||
if (isEnrollmentLimitError(err)) {
|
||||
enrollmentLimitModalOpen.value = true
|
||||
return
|
||||
}
|
||||
addToast?.(err instanceof Error ? err.message : 'Не удалось записаться на лекцию.', 'error')
|
||||
}
|
||||
}
|
||||
@@ -297,6 +307,8 @@ function isRegistered(id: string) {
|
||||
<button class="btn-primary" @click="filtersOpen = false">Применить</button>
|
||||
</template>
|
||||
</ModalDialog>
|
||||
|
||||
<EnrollmentLimitModal v-model="enrollmentLimitModalOpen" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user