адаптировала history.push() во всех компонентах
This commit is contained in:
parent
e32ce04bb9
commit
00126080bf
@ -3,6 +3,10 @@
|
|||||||
import type React from "react"
|
import type React from "react"
|
||||||
import { useHistory, useLocation } from "react-router-dom"
|
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 BottomNavigation: React.FC = () => {
|
||||||
const history = useHistory()
|
const history = useHistory()
|
||||||
@ -80,15 +84,15 @@ const BottomNavigation: React.FC = () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
const navItems = [
|
const navItems = [
|
||||||
{ path: "/home", icon: HomeIcon, label: "Домой" },
|
{ path: getRouteHome(), icon: HomeIcon, label: "Домой" },
|
||||||
{ path: "/courses", icon: CoursesIcon, label: "Курсы" },
|
{ path: getRouteCourses(), icon: CoursesIcon, label: "Курсы" },
|
||||||
{ path: "/course/${courseId}/exercises", icon: ExerciseIcon, label: "Тренировка" },
|
{ path: getRouteCourseExercises(':id'), icon: ExerciseIcon, label: "Тренировка" },
|
||||||
{ path: "/settings", icon: SettingsIcon, label: "Меню" },
|
{ path: getRouteSettings(), icon: SettingsIcon, label: "Меню" },
|
||||||
]
|
]
|
||||||
|
|
||||||
const isActive = (path: string) => {
|
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 (
|
return (
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import type React from "react"
|
import type React from "react"
|
||||||
import { useHistory } from "react-router-dom"
|
import { useHistory } from "react-router-dom"
|
||||||
|
import { getRouteCourseExercises } from "../shared/consts/router"
|
||||||
|
|
||||||
interface CourseCardProps {
|
interface CourseCardProps {
|
||||||
id: number
|
id: number
|
||||||
@ -14,13 +15,15 @@ interface CourseCardProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const CourseCard: React.FC<CourseCardProps> = ({
|
const CourseCard: React.FC<CourseCardProps> = ({
|
||||||
id,
|
|
||||||
name,
|
name,
|
||||||
progress,
|
progress,
|
||||||
color,
|
color,
|
||||||
icon,
|
icon,
|
||||||
}) => {
|
}) => {
|
||||||
const history = useHistory()
|
|
||||||
|
|
||||||
|
const history = useHistory();
|
||||||
|
history.push(getRouteCourseExercises(':id'));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
||||||
@ -28,7 +31,7 @@ const CourseCard: React.FC<CourseCardProps> = ({
|
|||||||
|
|
||||||
|
|
||||||
<div
|
<div
|
||||||
onClick={() => 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]"
|
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]"
|
||||||
>
|
>
|
||||||
<div className="flex items-center space-x-5">
|
<div className="flex items-center space-x-5">
|
||||||
|
@ -6,6 +6,9 @@ import { useHistory } from "react-router-dom"
|
|||||||
|
|
||||||
import confetti from "../assets/Confetti.gif"
|
import confetti from "../assets/Confetti.gif"
|
||||||
|
|
||||||
|
import { getRouteCourses } from "../shared/consts/router"
|
||||||
|
import { getRouteHome } from "../shared/consts/router"
|
||||||
|
|
||||||
const CourseComplete: React.FC = () => {
|
const CourseComplete: React.FC = () => {
|
||||||
const history = useHistory()
|
const history = useHistory()
|
||||||
const [animationPhase, setAnimationPhase] = useState(0)
|
const [animationPhase, setAnimationPhase] = useState(0)
|
||||||
@ -87,13 +90,13 @@ animationPhase >= 2 ? "scale-80" : "scale-100"} ${animationPhase >= 3 ? "-transl
|
|||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
onClick={() => history.push("/courses")}
|
onClick={() => history.push(getRouteCourses())}
|
||||||
className="w-full bg-white/20 backdrop-blur-lg hover:bg-white/30 text-white font-semibold py-3 px-6 rounded-xl border border-white/30 transition-all duration-200 transform hover:scale-105"
|
className="w-full bg-white/20 backdrop-blur-lg hover:bg-white/30 text-white font-semibold py-3 px-6 rounded-xl border border-white/30 transition-all duration-200 transform hover:scale-105"
|
||||||
>
|
>
|
||||||
Выбрать новый курс
|
Выбрать новый курс
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={() => history.push("/home")}
|
onClick={() => history.push(getRouteHome())}
|
||||||
className="w-full bg-transparent border-2 border-white/50 hover:bg-white/10 text-white font-semibold py-3 px-6 rounded-xl transition-all duration-200"
|
className="w-full bg-transparent border-2 border-white/50 hover:bg-white/10 text-white font-semibold py-3 px-6 rounded-xl transition-all duration-200"
|
||||||
>
|
>
|
||||||
На главную
|
На главную
|
||||||
|
@ -8,6 +8,9 @@ import HeaderNav from "../components/HeaderNav"
|
|||||||
import BottomNavigation from "../components/BottomNavigation"
|
import BottomNavigation from "../components/BottomNavigation"
|
||||||
import video from "../assets/video.mov"
|
import video from "../assets/video.mov"
|
||||||
|
|
||||||
|
|
||||||
|
import { getRouteExercise } from "../shared/consts/router"
|
||||||
|
|
||||||
const CourseExercises: React.FC = () => {
|
const CourseExercises: React.FC = () => {
|
||||||
const history = useHistory()
|
const history = useHistory()
|
||||||
const { id } = useParams<{ id: string }>();
|
const { id } = useParams<{ id: string }>();
|
||||||
@ -154,7 +157,7 @@ const course = {
|
|||||||
|
|
||||||
|
|
||||||
<button
|
<button
|
||||||
onClick={() => history.push(getExerciseRoute(currentExercise.id))}
|
onClick={() => history.push(getRouteExercise(currentExercise.id))}
|
||||||
className="w-full bg-gradient-to-r bg-orange-400 text-white font-semibold py-4 px-6 rounded-2xl hover:shadow-2xl transition-all duration-300 transform hover:scale-105 shadow-lg backdrop-blur-sm"
|
className="w-full bg-gradient-to-r bg-orange-400 text-white font-semibold py-4 px-6 rounded-2xl hover:shadow-2xl transition-all duration-300 transform hover:scale-105 shadow-lg backdrop-blur-sm"
|
||||||
>
|
>
|
||||||
Начать упражнение
|
Начать упражнение
|
||||||
@ -184,7 +187,7 @@ const course = {
|
|||||||
{course.exercises.map((exercise, index) => (
|
{course.exercises.map((exercise, index) => (
|
||||||
<div
|
<div
|
||||||
key={exercise.id}
|
key={exercise.id}
|
||||||
onClick={() => history.push(`/exercise/${exercise.id}`)}
|
onClick={() => history.push(getRouteExercise(currentExercise.id))}
|
||||||
className={`glass-morphism rounded-2xl p-4 sm:p-6 border border-white/50 shadow-lg cursor-pointer transition-all duration-300 hover:shadow-2xl transform hover:scale-[1.02] backdrop-blur-xl ${index === currentSlide ? "ring-2 ring-[#2BACBE] bg-cyan-50/20" : ""
|
className={`glass-morphism rounded-2xl p-4 sm:p-6 border border-white/50 shadow-lg cursor-pointer transition-all duration-300 hover:shadow-2xl transform hover:scale-[1.02] backdrop-blur-xl ${index === currentSlide ? "ring-2 ring-[#2BACBE] bg-cyan-50/20" : ""
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
|
@ -5,7 +5,7 @@ import BottomNavigation from "../components/BottomNavigation"
|
|||||||
import { useHistory } from "react-router-dom"
|
import { useHistory } from "react-router-dom"
|
||||||
|
|
||||||
import HeaderNav from "../components/HeaderNav"
|
import HeaderNav from "../components/HeaderNav"
|
||||||
|
import { getRouteCourseExercises } from "../shared/consts/router"
|
||||||
|
|
||||||
const Home: React.FC = () => {
|
const Home: React.FC = () => {
|
||||||
const history = useHistory()
|
const history = useHistory()
|
||||||
@ -59,7 +59,7 @@ const Home: React.FC = () => {
|
|||||||
{courses.map((course) => (
|
{courses.map((course) => (
|
||||||
<div
|
<div
|
||||||
key={course.id}
|
key={course.id}
|
||||||
onClick={() => history.push(`/course/${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]"
|
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]"
|
||||||
>
|
>
|
||||||
<div className="flex items-center space-x-5">
|
<div className="flex items-center space-x-5">
|
||||||
|
@ -4,6 +4,7 @@ import { useState, useEffect } from "react"
|
|||||||
import { useHistory } from "react-router-dom"
|
import { useHistory } from "react-router-dom"
|
||||||
|
|
||||||
import BottomNavigation from "../components/BottomNavigation"
|
import BottomNavigation from "../components/BottomNavigation"
|
||||||
|
import { getRouteCourseComplete } from "../shared/consts/router"
|
||||||
import HeaderNav from "../components/HeaderNav"
|
import HeaderNav from "../components/HeaderNav"
|
||||||
import video from "../assets/video.mov"
|
import video from "../assets/video.mov"
|
||||||
|
|
||||||
@ -25,7 +26,7 @@ const Exercise: React.FC = () => {
|
|||||||
if (prev >= totalTime) {
|
if (prev >= totalTime) {
|
||||||
setIsPlaying(false)
|
setIsPlaying(false)
|
||||||
// Show completion animation
|
// Show completion animation
|
||||||
history.push("/course-complete")
|
history.push(getRouteCourseComplete())
|
||||||
return totalTime
|
return totalTime
|
||||||
}
|
}
|
||||||
return prev + 1
|
return prev + 1
|
||||||
|
@ -143,7 +143,7 @@ const handleSubmit = async (e: React.FormEvent) => {
|
|||||||
</div>
|
</div>
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
<p className="text-gray-700/60 text-xs mb-4">Автоматический переход через 3 секунды...</p>
|
<p className="text-gray-700/60 text-xs mb-4">Автоматический переход через 3 секунды...</p>
|
||||||
<button onClick={() => history.push("/login")} className="text-gray-700 font-semibold hover:underline">
|
<button onClick={() => history.push(getRouteLogin())} className="text-gray-700 font-semibold hover:underline">
|
||||||
Вернуться к входу
|
Вернуться к входу
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -7,6 +7,11 @@ import { useHistory, Link } from "react-router-dom"
|
|||||||
import HeaderNav from "../components/HeaderNav"
|
import HeaderNav from "../components/HeaderNav"
|
||||||
import BottomNavigation from "../components/BottomNavigation"
|
import BottomNavigation from "../components/BottomNavigation"
|
||||||
import CircularProgressDisplay from "../components/CircularProgressDisplay"
|
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() {
|
export default function Home() {
|
||||||
const history = useHistory()
|
const history = useHistory()
|
||||||
@ -98,7 +103,7 @@ export default function Home() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div onClick={() => history.push("/exercise/1")} className="px-4 sm:px-6 space-y-6 ">
|
<div onClick={() => history.push(getRouteExercise(':id'))} className="px-4 sm:px-6 space-y-6 ">
|
||||||
{/* Current Exercise */}
|
{/* Current Exercise */}
|
||||||
<div className="bg-gradient-to-r from-[#2BACBE] to-[#1E7F8C] rounded-3xl p-6 shadow-2xl text-white max-w-4xl mx-auto my-8 transition-transform transform hover:scale-105 duration-300">
|
<div className="bg-gradient-to-r from-[#2BACBE] to-[#1E7F8C] rounded-3xl p-6 shadow-2xl text-white max-w-4xl mx-auto my-8 transition-transform transform hover:scale-105 duration-300">
|
||||||
{/* Заголовок и статус */}
|
{/* Заголовок и статус */}
|
||||||
@ -142,7 +147,7 @@ export default function Home() {
|
|||||||
</div>
|
</div>
|
||||||
{/* Quick Stats (Total Exercises & Total Courses) */}
|
{/* Quick Stats (Total Exercises & Total Courses) */}
|
||||||
<div className="grid grid-cols-2 gap-4 md:gap-10">
|
<div className="grid grid-cols-2 gap-4 md:gap-10">
|
||||||
<div onClick={() => 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">
|
<div onClick={() => 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">
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
width={180}
|
width={180}
|
||||||
@ -174,7 +179,7 @@ export default function Home() {
|
|||||||
<div className="text-xl font-bold text-gray-800 mb-1 z-20 relative">Курсы</div>
|
<div className="text-xl font-bold text-gray-800 mb-1 z-20 relative">Курсы</div>
|
||||||
<div className="text-base text-gray-600 z-20 relative">все назначенные</div>
|
<div className="text-base text-gray-600 z-20 relative">все назначенные</div>
|
||||||
</div>
|
</div>
|
||||||
<div onClick={() => 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">
|
<div onClick={() => 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">
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
width={180}
|
width={180}
|
||||||
|
@ -4,12 +4,14 @@ import type React from "react"
|
|||||||
import { useHistory } from "react-router-dom"
|
import { useHistory } from "react-router-dom"
|
||||||
import BottomNavigation from "../components/BottomNavigation"
|
import BottomNavigation from "../components/BottomNavigation"
|
||||||
|
|
||||||
|
import { getRouteLogin } from "../shared/consts/router"
|
||||||
|
|
||||||
const Settings: React.FC = () => {
|
const Settings: React.FC = () => {
|
||||||
const history = useHistory()
|
const history = useHistory()
|
||||||
|
|
||||||
const handleLogout = () => {
|
const handleLogout = () => {
|
||||||
localStorage.clear()
|
localStorage.clear()
|
||||||
history.push("/login")
|
history.push(getRouteLogin())
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user