поправила вывод курса в шапку
This commit is contained in:
parent
a1d945b854
commit
17ee7354dc
@ -1,7 +1,7 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { useParams, useHistory } from "react-router-dom";
|
import { useParams, useHistory, useLocation } from "react-router-dom";
|
||||||
|
|
||||||
import HeaderNav from "../components/HeaderNav";
|
import HeaderNav from "../components/HeaderNav";
|
||||||
import BottomNavigation from "../components/BottomNavigation";
|
import BottomNavigation from "../components/BottomNavigation";
|
||||||
@ -11,8 +11,9 @@ import { connect } from '../confconnect';
|
|||||||
import { getRouteExercise } from "../shared/consts/router";
|
import { getRouteExercise } from "../shared/consts/router";
|
||||||
import { ArrowIcon } from "../components/icons/ArrowIcon";
|
import { ArrowIcon } from "../components/icons/ArrowIcon";
|
||||||
|
|
||||||
|
import type { Course } from "../pages/Courses";
|
||||||
|
|
||||||
interface CourseExercises {
|
export interface CourseExercises {
|
||||||
id_course: number;
|
id_course: number;
|
||||||
id_exercise: number;
|
id_exercise: number;
|
||||||
exercise: Exercise;
|
exercise: Exercise;
|
||||||
@ -25,8 +26,6 @@ interface CourseExercises {
|
|||||||
interface Exercise {
|
interface Exercise {
|
||||||
id: number;
|
id: number;
|
||||||
title: string;
|
title: string;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -34,6 +33,11 @@ export const CourseExercises = () => {
|
|||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const { id } = useParams<{ id: string }>();
|
const { id } = useParams<{ id: string }>();
|
||||||
|
|
||||||
|
|
||||||
|
const location = useLocation<{ course?: Course }>();
|
||||||
|
const course = location.state?.course;
|
||||||
|
|
||||||
|
|
||||||
// const [pacientData, setPacientData] = useState(null);
|
// const [pacientData, setPacientData] = useState(null);
|
||||||
|
|
||||||
const [course_exercises, setExercises] = useState<CourseExercises[]>([]);
|
const [course_exercises, setExercises] = useState<CourseExercises[]>([]);
|
||||||
@ -41,6 +45,8 @@ export const CourseExercises = () => {
|
|||||||
|
|
||||||
const token = localStorage.getItem('authToken');
|
const token = localStorage.getItem('authToken');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log(token)
|
console.log(token)
|
||||||
if (!token) {
|
if (!token) {
|
||||||
@ -99,7 +105,9 @@ export const CourseExercises = () => {
|
|||||||
|
|
||||||
<div className="my-36 min-h-screen max-w-4xl mx-auto">
|
<div className="my-36 min-h-screen max-w-4xl mx-auto">
|
||||||
|
|
||||||
<HeaderNav item={'Курс' + ' ' + id} text={'список упражнений'} />
|
<HeaderNav item={course?.title ?? 'Название курса'} text={'курс'} />
|
||||||
|
{/* Это выражение использует оператор опциональной цепочки (?.) и оператор нулевого слияния (??).
|
||||||
|
Если course не null и не undefined, то взять его свойство title, иначе — вернуть undefined*/}
|
||||||
|
|
||||||
<div className="px-6 mb-8">
|
<div className="px-6 mb-8">
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@ export interface Course {
|
|||||||
url_file_img: string;
|
url_file_img: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const ProgressLine = () => {
|
const ProgressLine = () => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@ -88,6 +90,7 @@ export const Courses = () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
setCourses(allCourses);
|
setCourses(allCourses);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
@ -106,7 +109,6 @@ export const Courses = () => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Генерируем случайный прогресс для каждого курса
|
// Генерируем случайный прогресс для каждого курса
|
||||||
const getRandomProgress = () => Math.floor(Math.random() * 100);
|
const getRandomProgress = () => Math.floor(Math.random() * 100);
|
||||||
|
|
||||||
@ -146,7 +148,7 @@ export const Courses = () => {
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={course.ID}
|
key={course.ID}
|
||||||
onClick={() => history.push(getRouteCourseExercises(course.ID.toString()))}
|
onClick={() => history.push(getRouteCourseExercises(course.ID.toString()), { course })}
|
||||||
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">
|
||||||
|
@ -389,7 +389,7 @@ export const Exercise = () => {
|
|||||||
onTouchStart={() => setIsActive(true)}
|
onTouchStart={() => setIsActive(true)}
|
||||||
onTouchEnd={() => setIsActive(false)}
|
onTouchEnd={() => setIsActive(false)}
|
||||||
|
|
||||||
className={`cursor-pointer px-6 py-3 font-bold rounded-xl transition-all duration-700 hover:scale-105 hover:shadow-lg border border-gray-200 flex items-center justify-center ${!isActive ? "bg-white text-cyan-500" : "bg-orange-400 text-white"}`}
|
className={`cursor-pointer px-6 py-3 font-bold rounded-xl transition-all duration-700 hover:scale-105 hover:shadow-lg border border-gray-200 flex items-center justify-center ${!isActive ? "bg-white text-orange-400" : "bg-orange-400 text-white"}`}
|
||||||
>
|
>
|
||||||
<CheckIcon
|
<CheckIcon
|
||||||
className="w-6 h-6"
|
className="w-6 h-6"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user