исправлены ошибки в консоли
This commit is contained in:
parent
90267942d7
commit
8af5f78d11
@ -52,16 +52,8 @@ const BottomNavigation: React.FC = () => {
|
||||
try {
|
||||
let targetCourse: Course | null = null
|
||||
|
||||
console.log("[v0] BottomNav - Всего курсов:", courses.length)
|
||||
console.log(
|
||||
"[v0] BottomNav - Список курсов:",
|
||||
courses.map((c) => ({ id: c.id, title: c.title })),
|
||||
)
|
||||
|
||||
// Проходим по всем курсам и ищем незавершенный
|
||||
for (const course of courses) {
|
||||
console.log("[v0] BottomNav - Проверяем курс:", course.id, course.title)
|
||||
|
||||
// Загружаем упражнения для каждого курса
|
||||
const response = await connect.get(`/pacient/${course.id}`, {
|
||||
headers: {
|
||||
@ -71,7 +63,6 @@ const BottomNavigation: React.FC = () => {
|
||||
})
|
||||
|
||||
const exercises = response.data.course_exercises || []
|
||||
console.log("[v0] BottomNav - Упражнений в курсе", course.id, ":", exercises.length)
|
||||
|
||||
if (exercises.length === 0) continue // Пропускаем курсы без упражнений
|
||||
|
||||
@ -97,20 +88,9 @@ const BottomNavigation: React.FC = () => {
|
||||
}
|
||||
}
|
||||
|
||||
console.log(
|
||||
"[v0] BottomNav - Курс",
|
||||
course.id,
|
||||
"- завершено упражнений:",
|
||||
completedCount,
|
||||
"из",
|
||||
exercises.length,
|
||||
)
|
||||
console.log("[v0] BottomNav - Курс", course.id, "- есть незавершенные:", hasIncompleteExercises)
|
||||
|
||||
// Если в курсе есть незавершенные упражнения, выбираем его
|
||||
if (hasIncompleteExercises) {
|
||||
targetCourse = course
|
||||
console.log("[v0] BottomNav - Выбран курс как незавершенный:", course.id, course.title)
|
||||
break // Берем первый найденный незавершенный курс
|
||||
}
|
||||
}
|
||||
@ -118,16 +98,12 @@ const BottomNavigation: React.FC = () => {
|
||||
// Если все курсы завершены, берем последний курс
|
||||
if (!targetCourse && courses.length > 0) {
|
||||
targetCourse = courses[courses.length - 1]
|
||||
console.log("[v0] BottomNav - Все курсы завершены, берем последний:", targetCourse.id, targetCourse.title)
|
||||
}
|
||||
|
||||
if (!targetCourse) {
|
||||
console.log("[v0] BottomNav - Не найден подходящий курс")
|
||||
return null
|
||||
}
|
||||
|
||||
console.log("[v0] BottomNav - Итоговый выбранный курс:", targetCourse.id, targetCourse.title)
|
||||
|
||||
// Загружаем упражнения выбранного курса
|
||||
const response = await connect.get(`/pacient/${targetCourse.id}`, {
|
||||
headers: {
|
||||
@ -206,7 +182,7 @@ const BottomNavigation: React.FC = () => {
|
||||
|
||||
return foundExercise
|
||||
} catch (error) {
|
||||
console.error("[v0] BottomNav - Ошибка при получении текущего упражнения:", error)
|
||||
console.error("Ошибка при получении текущего упражнения:", error)
|
||||
return null
|
||||
}
|
||||
}
|
||||
@ -237,7 +213,7 @@ const BottomNavigation: React.FC = () => {
|
||||
setCourses(allCourses)
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("[v0] BottomNav - Ошибка при загрузке курсов:", error)
|
||||
console.error("Ошибка при загрузке курсов:", error)
|
||||
})
|
||||
}, [token])
|
||||
|
||||
|
@ -21,7 +21,6 @@ import { getRouteCourseExercises } from "../shared/consts/router"
|
||||
|
||||
import type { Course, User, CoursesApiResponse } from "../types/course"
|
||||
|
||||
|
||||
interface CourseExercises {
|
||||
id_exercise: number
|
||||
day: number
|
||||
@ -156,6 +155,7 @@ export default function Home() {
|
||||
|
||||
// Проверяем, есть ли незавершенные упражнения в этом курсе
|
||||
let hasIncompleteExercises = false
|
||||
let completedCount = 0
|
||||
|
||||
for (const exercise of exercises) {
|
||||
const storageKey = `exerciseProgress_${course.id}_${exercise.id_exercise}_day_${exercise.day}`
|
||||
@ -168,9 +168,10 @@ export default function Home() {
|
||||
progress.status === 1 && progress.completedSets && progress.completedSets.length >= exercise.count
|
||||
}
|
||||
|
||||
if (!isCompleted) {
|
||||
if (isCompleted) {
|
||||
completedCount++
|
||||
} else {
|
||||
hasIncompleteExercises = true
|
||||
break // Нашли незавершенное упражнение, можно остановиться
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user