"use client" import type React from "react" import { useState, useEffect } from "react" import { IonContent, IonPage, IonCard, IonCardContent, IonCardHeader, IonCardTitle, IonButton, IonIcon, IonProgressBar, IonBadge, } from "@ionic/react" import { playOutline, pauseOutline, stopOutline, timerOutline, fitnessOutline, trophyOutline } from "ionicons/icons" interface Exercise { id: number name: string duration: number // в секундах description: string difficulty: "easy" | "medium" | "hard" completed: boolean } const Home: React.FC = () => { const [currentExercise, setCurrentExercise] = useState(null) const [timeLeft, setTimeLeft] = useState(0) const [isRunning, setIsRunning] = useState(false) const [isPaused, setIsPaused] = useState(false) const exercises: Exercise[] = [ { id: 1, name: "Разминка плечевого сустава", duration: 300, // 5 минут description: "Медленные круговые движения плечами для восстановления подвижности", difficulty: "easy", completed: true, }, { id: 2, name: "Упражнения для кисти", duration: 600, // 10 минут description: "Сжимание и разжимание кулака, вращения кистью", difficulty: "medium", completed: false, }, { id: 3, name: "Растяжка мышц руки", duration: 450, // 7.5 минут description: "Статические упражнения на растяжку поврежденных мышц", difficulty: "hard", completed: false, }, ] const [exerciseList, setExerciseList] = useState(exercises) useEffect(() => { let interval: NodeJS.Timeout if (isRunning && !isPaused && timeLeft > 0) { interval = setInterval(() => { setTimeLeft(timeLeft - 1) }, 1000) } else if (timeLeft === 0 && currentExercise) { // Упражнение завершено setIsRunning(false) setCurrentExercise(null) // Отмечаем упражнение как выполненное setExerciseList((prev) => prev.map((ex) => (ex.id === currentExercise.id ? { ...ex, completed: true } : ex))) } return () => clearInterval(interval) }, [isRunning, isPaused, timeLeft, currentExercise]) const startExercise = (exercise: Exercise) => { setCurrentExercise(exercise) setTimeLeft(exercise.duration) setIsRunning(true) setIsPaused(false) } const pauseExercise = () => { setIsPaused(!isPaused) } const stopExercise = () => { setIsRunning(false) setIsPaused(false) setCurrentExercise(null) setTimeLeft(0) } const formatTime = (seconds: number) => { const mins = Math.floor(seconds / 60) const secs = seconds % 60 return `${mins.toString().padStart(2, "0")}:${secs.toString().padStart(2, "0")}` } const getDifficultyColor = (difficulty: string) => { switch (difficulty) { case "easy": return "text-emerald-400" case "medium": return "text-yellow-400" case "hard": return "text-red-400" default: return "text-slate-400" } } const getDifficultyBg = (difficulty: string) => { switch (difficulty) { case "easy": return "bg-emerald-500/20 border-emerald-500/30" case "medium": return "bg-yellow-500/20 border-yellow-500/30" case "hard": return "bg-red-500/20 border-red-500/30" default: return "bg-slate-500/20 border-slate-500/30" } } const completedCount = exerciseList.filter((ex) => ex.completed).length const totalCount = exerciseList.length const progressPercentage = (completedCount / totalCount) * 100 return (
{/* Приветствие и статистика */}

Добро пожаловать, Иван!

Продолжайте восстановление. Вы на правильном пути!

{/* Общий прогресс */} Общий прогресс
Выполнено упражнений {completedCount}/{totalCount}
{progressPercentage.toFixed(0)}% завершено
{/* Текущее упражнение (если активно) */} {currentExercise && ( Текущее упражнение

{currentExercise.name}

{formatTime(timeLeft)}
{isPaused ? "Продолжить" : "Пауза"} Остановить
)} {/* Список упражнений */}

Сегодняшние упражнения

{exerciseList.map((exercise) => (

{exercise.name}

{exercise.description}

{exercise.completed && ( Выполнено )}
{formatTime(exercise.duration)} {exercise.difficulty === "easy" ? "Легко" : exercise.difficulty === "medium" ? "Средне" : "Сложно"}
{!exercise.completed && !currentExercise && ( startExercise(exercise)} className="bg-gradient-to-r from-teal-500 to-cyan-500" > Начать )}
))}
) } export default Home