diff --git a/src/components/TestModal.tsx b/src/components/TestModal.tsx index a3371fc..ddd9a71 100644 --- a/src/components/TestModal.tsx +++ b/src/components/TestModal.tsx @@ -73,17 +73,6 @@ const TestModal: React.FC = ({ open, onClose, onComplete, showWa return getCurrentAnswer() !== undefined; }; - const handleNext = () => { - if (currentQuestionIndex < shuffledQuestions.length - 1) { - setCurrentQuestionIndex(prev => prev + 1); - } else { - // Проверяем, что все вопросы отвечены - const allAnswered = shuffledQuestions.every(q => - answers.some(a => a.questionId === q.id) - ); - - if (allAnswered) { - onComplete(answers); const areAllQuestionsAnswered = (questions: TestQuestion[], answers: TestAnswer[]): boolean => { return questions.every(q => answers.some(a => a.questionId === q.id)); }; diff --git a/src/components/TestResults.tsx b/src/components/TestResults.tsx index 944a896..0f5216f 100644 --- a/src/components/TestResults.tsx +++ b/src/components/TestResults.tsx @@ -35,6 +35,7 @@ import { } from '@mui/icons-material'; import { FatigueType, TestResult, Activity } from '../types'; import { getScoreInterpretation, shouldShowMedicalWarning, formatTestDate } from '../utils/testUtils'; +import { getActivityTypeByName } from '../utils/helpers'; interface TestResultsProps { open: boolean; diff --git a/src/utils/helpers.ts b/src/utils/helpers.ts index e11d66d..2794420 100644 --- a/src/utils/helpers.ts +++ b/src/utils/helpers.ts @@ -1,4 +1,6 @@ // Утилиты для работы с уведомлениями и PWA +import { ActivityType } from '../types'; +import { PREDEFINED_ACTIVITIES } from '../data/predefinedActivities'; export const formatDate = (date: Date): string => { return date.toLocaleDateString('ru-RU', { @@ -12,6 +14,18 @@ export const validateActivityInput = (name: string, description: string): boolea return name.trim().length > 0 && description.trim().length > 0; }; +export const getActivityTypeByName = (activityName: string): ActivityType => { + // Поиск активности в предопределенных активностях + for (const [type, activities] of Object.entries(PREDEFINED_ACTIVITIES)) { + if (activities.some(activity => activity.name === activityName)) { + return type as ActivityType; + } + } + + // Если не найдено, возвращаем значение по умолчанию + return ActivityType.PASSIVE; +}; + export const generateRecurrenceOptions = (frequency: string): string[] => { const options = []; if (frequency === 'daily') { diff --git a/src/utils/testUtils.ts b/src/utils/testUtils.ts index d49342f..f2522de 100644 --- a/src/utils/testUtils.ts +++ b/src/utils/testUtils.ts @@ -1,6 +1,9 @@ import { TestAnswer, FatigueScores, FatigueType, TestResult } from '../types'; import { fatigueTypeQuestions, fatigueTypeDescriptions } from '../data/testData'; +// Константы для интерпретации результатов теста +const MODERATE_FATIGUE_THRESHOLD = 11; + export const calculateFatigueScores = (answers: TestAnswer[]): FatigueScores => { const scores: FatigueScores = { physical: 0,