From dd7ea94d98f6b183abc1a5b30fae860f1c27bd63 Mon Sep 17 00:00:00 2001 From: Tatyana Date: Tue, 9 Sep 2025 16:14:31 +0300 Subject: [PATCH] =?UTF-8?q?=D1=80=D0=B0=D0=B7=D0=BC=D0=B5=D1=89=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=B2=20CIT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Exercise.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/pages/Exercise.tsx b/src/pages/Exercise.tsx index 658e778..da440ff 100644 --- a/src/pages/Exercise.tsx +++ b/src/pages/Exercise.tsx @@ -36,6 +36,8 @@ interface RouteParams { exerciseIndex?: string // Added exerciseIndex parameter } + + export const Exercise = () => { const history = useHistory() const { courseId, exerciseId, exerciseIndex } = useParams() @@ -132,9 +134,11 @@ export const Exercise = () => { console.log("Загружаем упражнение. ID курса:", courseId, "ID упражнения:", actualExerciseId) + setLoading(true); + // загрузка упражнения connect .get(`pacient/${courseId}/${actualExerciseId}`) - .then((response) => { + .then(async (response) => { const exerciseData = response.data console.log("Данные упражнения получены:", exerciseData) @@ -170,6 +174,11 @@ export const Exercise = () => { console.log("Установлено количество подходов:", exerciseData.count) } + // Загрузка прогресса после получения упражнения + //await говорит, что нужно подождать, пока эта асинхронная функция (которая, возможно, делает сетевой запрос) завершится, прежде чем перейти к следующей строке кода. Это важно, чтобы результат загрузки был получен до того, как дальше попадёшь к другим действиям. + await loadProgressFromServer(); + + setLoading(false) }) .catch((error) => {