поправила вывод курса в шапку
This commit is contained in:
parent
a1d945b854
commit
17ee7354dc
@ -1,7 +1,7 @@
|
||||
"use client"
|
||||
|
||||
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 BottomNavigation from "../components/BottomNavigation";
|
||||
@ -11,8 +11,9 @@ import { connect } from '../confconnect';
|
||||
import { getRouteExercise } from "../shared/consts/router";
|
||||
import { ArrowIcon } from "../components/icons/ArrowIcon";
|
||||
|
||||
import type { Course } from "../pages/Courses";
|
||||
|
||||
interface CourseExercises {
|
||||
export interface CourseExercises {
|
||||
id_course: number;
|
||||
id_exercise: number;
|
||||
exercise: Exercise;
|
||||
@ -25,8 +26,6 @@ interface CourseExercises {
|
||||
interface Exercise {
|
||||
id: number;
|
||||
title: string;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -34,6 +33,11 @@ export const CourseExercises = () => {
|
||||
const history = useHistory();
|
||||
const { id } = useParams<{ id: string }>();
|
||||
|
||||
|
||||
const location = useLocation<{ course?: Course }>();
|
||||
const course = location.state?.course;
|
||||
|
||||
|
||||
// const [pacientData, setPacientData] = useState(null);
|
||||
|
||||
const [course_exercises, setExercises] = useState<CourseExercises[]>([]);
|
||||
@ -41,6 +45,8 @@ export const CourseExercises = () => {
|
||||
|
||||
const token = localStorage.getItem('authToken');
|
||||
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
console.log(token)
|
||||
if (!token) {
|
||||
@ -99,7 +105,9 @@ export const CourseExercises = () => {
|
||||
|
||||
<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">
|
||||
|
||||
|
@ -16,6 +16,8 @@ export interface Course {
|
||||
url_file_img: string;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const ProgressLine = () => {
|
||||
return (
|
||||
<div
|
||||
@ -88,6 +90,7 @@ export const Courses = () => {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
setCourses(allCourses);
|
||||
})
|
||||
.catch(error => {
|
||||
@ -106,7 +109,6 @@ export const Courses = () => {
|
||||
|
||||
|
||||
|
||||
|
||||
// Генерируем случайный прогресс для каждого курса
|
||||
const getRandomProgress = () => Math.floor(Math.random() * 100);
|
||||
|
||||
@ -115,7 +117,7 @@ export const Courses = () => {
|
||||
"from-gray-400 to-cyan-800",
|
||||
];
|
||||
|
||||
//item.exercise.title
|
||||
//item.exercise.title
|
||||
|
||||
|
||||
return (
|
||||
@ -146,7 +148,7 @@ export const Courses = () => {
|
||||
return (
|
||||
<div
|
||||
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]"
|
||||
>
|
||||
<div className="flex items-center space-x-5">
|
||||
|
@ -389,7 +389,7 @@ export const Exercise = () => {
|
||||
onTouchStart={() => setIsActive(true)}
|
||||
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
|
||||
className="w-6 h-6"
|
||||
|
Loading…
x
Reference in New Issue
Block a user