Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions src/components/TestModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,6 @@ const TestModal: React.FC<TestModalProps> = ({ 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));
};
Expand Down
1 change: 1 addition & 0 deletions src/components/TestResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 14 additions & 0 deletions src/utils/helpers.ts
Original file line number Diff line number Diff line change
@@ -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', {
Expand All @@ -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') {
Expand Down
3 changes: 3 additions & 0 deletions src/utils/testUtils.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down