diff --git a/src/components/BottomNavigation.tsx b/src/components/BottomNavigation.tsx index b6831ad..da87a22 100644 --- a/src/components/BottomNavigation.tsx +++ b/src/components/BottomNavigation.tsx @@ -3,6 +3,10 @@ import type React from "react" import { useHistory, useLocation } from "react-router-dom" +import { getRouteHome } from "../shared/consts/router" +import { getRouteCourses } from "../shared/consts/router" +import { getRouteCourseExercises } from "../shared/consts/router" +import { getRouteSettings } from "../shared/consts/router" const BottomNavigation: React.FC = () => { const history = useHistory() @@ -80,15 +84,15 @@ const BottomNavigation: React.FC = () => { ) const navItems = [ - { path: "/home", icon: HomeIcon, label: "Домой" }, - { path: "/courses", icon: CoursesIcon, label: "Курсы" }, - { path: "/course/${courseId}/exercises", icon: ExerciseIcon, label: "Тренировка" }, - { path: "/settings", icon: SettingsIcon, label: "Меню" }, + { path: getRouteHome(), icon: HomeIcon, label: "Домой" }, + { path: getRouteCourses(), icon: CoursesIcon, label: "Курсы" }, + { path: getRouteCourseExercises(':id'), icon: ExerciseIcon, label: "Тренировка" }, + { path: getRouteSettings(), icon: SettingsIcon, label: "Меню" }, ] const isActive = (path: string) => { - if (path === "/exercise/1") return location.pathname.includes("/exercise") - return location.pathname === path + // Проверка на совпадение или включение + return location.pathname === path || location.pathname.startsWith(path); } return ( diff --git a/src/components/CourseCard.tsx b/src/components/CourseCard.tsx index d7a7d3e..0d1c686 100644 --- a/src/components/CourseCard.tsx +++ b/src/components/CourseCard.tsx @@ -2,6 +2,7 @@ import type React from "react" import { useHistory } from "react-router-dom" +import { getRouteCourseExercises } from "../shared/consts/router" interface CourseCardProps { id: number @@ -14,21 +15,23 @@ interface CourseCardProps { } const CourseCard: React.FC = ({ - id, name, progress, color, icon, }) => { - const history = useHistory() + + + const history = useHistory(); + history.push(getRouteCourseExercises(':id')); return ( - +
history.push(`/course/${id}/exercises`)} + onClick={() => history.push(getRouteCourseExercises(':id'))} className="bg-white/30 backdrop-blur-2xl rounded-3xl p-6 border border-white/20 shadow-xl cursor-pointer hover:shadow-2xl transition-all duration-300 transform hover:scale-[1.02]" >
diff --git a/src/pages/CourseComplete.tsx b/src/pages/CourseComplete.tsx index ca3c188..179e192 100644 --- a/src/pages/CourseComplete.tsx +++ b/src/pages/CourseComplete.tsx @@ -6,6 +6,9 @@ import { useHistory } from "react-router-dom" import confetti from "../assets/Confetti.gif" +import { getRouteCourses } from "../shared/consts/router" +import { getRouteHome } from "../shared/consts/router" + const CourseComplete: React.FC = () => { const history = useHistory() const [animationPhase, setAnimationPhase] = useState(0) @@ -87,13 +90,13 @@ animationPhase >= 2 ? "scale-80" : "scale-100"} ${animationPhase >= 3 ? "-transl }`} >
diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx index 2cb0811..7cda209 100644 --- a/src/pages/Home.tsx +++ b/src/pages/Home.tsx @@ -7,6 +7,11 @@ import { useHistory, Link } from "react-router-dom" import HeaderNav from "../components/HeaderNav" import BottomNavigation from "../components/BottomNavigation" import CircularProgressDisplay from "../components/CircularProgressDisplay" +import { getRouteExercise } from "../shared/consts/router" +import { getRouteCourses } from "../shared/consts/router" + + +import { getRouteCourseExercises } from "../shared/consts/router" export default function Home() { const history = useHistory() @@ -98,7 +103,7 @@ export default function Home() {
-
history.push("/exercise/1")} className="px-4 sm:px-6 space-y-6 "> +
history.push(getRouteExercise(':id'))} className="px-4 sm:px-6 space-y-6 "> {/* Current Exercise */}
{/* Заголовок и статус */} @@ -142,7 +147,7 @@ export default function Home() {
{/* Quick Stats (Total Exercises & Total Courses) */}
-
history.push("/courses")} className="glass-morphism rounded-3xl text-left border border-white/50 shadow-lg backdrop-blur-xl p-6 text-white transition-transform transform hover:scale-105 duration-300 overflow-hidden"> +
history.push(getRouteCourses())} className="glass-morphism rounded-3xl text-left border border-white/50 shadow-lg backdrop-blur-xl p-6 text-white transition-transform transform hover:scale-105 duration-300 overflow-hidden"> Курсы
все назначенные
-
history.push("/course/${courseId}/exercises")} className="glass-morphism rounded-3xl text-left border border-white/50 shadow-lg backdrop-blur-xl p-6 text-white transition-transform transform hover:scale-105 duration-300 overflow-hidden"> +
history.push(getRouteCourseExercises(':id'))} className="glass-morphism rounded-3xl text-left border border-white/50 shadow-lg backdrop-blur-xl p-6 text-white transition-transform transform hover:scale-105 duration-300 overflow-hidden"> { const history = useHistory() const handleLogout = () => { localStorage.clear() - history.push("/login") + history.push(getRouteLogin()) } return (