refactor: почистил фронтенд

This commit is contained in:
2026-05-24 22:33:40 +03:00
parent 90300b0644
commit a8a20f9b0b
6 changed files with 51 additions and 72 deletions
+2 -13
View File
@@ -1,15 +1,14 @@
import { defineStore } from 'pinia'
import { computed, ref } from 'vue'
import { lecturesApi, usersApi } from '@/api'
import { mapApiLecture, mapApiReview } from '@/api/mappers'
import type { Lecture, Review } from '@/types'
import { mapApiLecture } from '@/api/mappers'
import type { Lecture } from '@/types'
import type { LectureQuery } from '@/api/types'
import { useUserStore } from './user'
export const useLecturesStore = defineStore('lectures', () => {
const lectures = ref<Lecture[]>([])
const registered = ref<string[]>([])
const reviewsByLecture = ref<Record<string, Review[]>>({})
const loading = ref(false)
const error = ref<string | null>(null)
@@ -65,14 +64,6 @@ export const useLecturesStore = defineStore('lectures', () => {
}
}
async function fetchReviews(lectureId: string) {
try {
reviewsByLecture.value[lectureId] = (await lecturesApi.reviews(lectureId)).map(mapApiReview)
} catch {
reviewsByLecture.value[lectureId] = []
}
}
async function register(lectureId: string) {
const lecture = lectures.value.find(item => item.id === lectureId)
if (!lecture || lecture.freeSeats === 0 || lecture.registrationClosed || registered.value.includes(lectureId)) return
@@ -111,7 +102,6 @@ export const useLecturesStore = defineStore('lectures', () => {
return {
lectures,
registered,
reviewsByLecture,
loading,
error,
all,
@@ -120,7 +110,6 @@ export const useLecturesStore = defineStore('lectures', () => {
fetchLectures,
fetchLecture,
fetchRegisteredForCurrentUser,
fetchReviews,
register,
unregister,
isRegistered,