diff --git a/frontend/src/app/(cabinet)/courses/[id]/page.tsx b/frontend/src/app/(cabinet)/courses/[id]/page.tsx new file mode 100644 index 0000000..a3f98c2 --- /dev/null +++ b/frontend/src/app/(cabinet)/courses/[id]/page.tsx @@ -0,0 +1,75 @@ +import React from "react"; +import ClientCoursePage from "@/components/cabinet/ClientCoursePage"; + +interface Module { + id: string; + title: string; + content: string; +} + +interface Course { + id: string; + name: string; + description: string; + modules: Module[]; +} + +interface CoursePageProps { + course: Course; +} + +const CoursePage: React.FC = ({ course }) => { + return ( +
+

{ course.name }

+

{ course.description }

+ +
+ ); +}; + +// Fetch data at build time +export async function generateStaticParams() { + // Replace this with your data fetching logic to get all course IDs + const courses = [ + { id: "1" }, + { id: "2" }, + { id: "3" } + ]; + + return courses.map((course) => ({ + id: course.id + })); +} + +async function getData(id: string) { + // Replace this with your data fetching logic + return { + id, + name: `Course ${ id }`, + description: `This is the description for Course ${ id }.`, + modules: [ + { + id: "module1", + title: "Module 1", + content: "Content for module 1" + }, + { + id: "module2", + title: "Module 2", + content: "Content for module 2" + } + // Add more modules as needed + ] + }; +} + +export default async function Page({ params }: { params: { id: string } }) { + const course = await getData(params.id); + + if (!course) { + return

Course not found

; + } + + return ; +} diff --git a/frontend/src/app/(cabinet)/courses/page.tsx b/frontend/src/app/(cabinet)/courses/page.tsx index c8683c8..2e5a4a6 100644 --- a/frontend/src/app/(cabinet)/courses/page.tsx +++ b/frontend/src/app/(cabinet)/courses/page.tsx @@ -1,28 +1,51 @@ "use client"; -import React from "react"; +import React, { useState } from "react"; import { useProfile } from "@/hooks/useProfile"; import { LuLoader } from "react-icons/lu"; -import { Container, Row, Col, Card } from "react-bootstrap"; // Import Bootstrap components +import { Container, Row, Col, Card, Dropdown, ButtonGroup } from "react-bootstrap"; +import { COURSES_PAGE } from "@/constants/pages-url.constants"; +import Link from "next/link"; -const courses = [ +const newCourses = [ { - name: "Вс тело за 1 час", + name: "Всe тело за 1 час", price: "$350", date: "20/08/2024", category: "Full-body" }, { - name: "Название курса", + name: "Утренняя зарядка", price: "$350", date: "20/08/2024", - category: "Coding" + category: "Разминки" } - // Add more courses as needed + // Add more new courses as needed +]; + +const initialAppliedCourses = [ + { + name: "Advanced React", + price: "$500", + date: "01/09/2024", + category: "Programming" + }, + { + name: "Data Science Bootcamp", + price: "$800", + date: "15/09/2024", + category: "Data Science" + } + // Add more applied courses as needed ]; const Courses: React.FC = () => { const { user } = useProfile(); + const [ appliedCourses, setAppliedCourses ] = useState(initialAppliedCourses); + + const handleUnsubscribe = (courseIndex: number) => { + setAppliedCourses(appliedCourses.filter((_, index) => index !== courseIndex)); + }; return ( @@ -36,12 +59,16 @@ const Courses: React.FC = () => { + +

Поиск новых курсов

- { courses.map((course, index) => ( + { newCourses.map((course, index) => ( -
{ course.category }
+
+ { course.category } +
Курс: { course.name }
Цена: { course.price }
Дата: { course.date }
@@ -50,6 +77,34 @@ const Courses: React.FC = () => { )) }
+ +

Управление подписками

+ + { appliedCourses.map((course, index) => ( + + + +
+ +
+ { course.category } +
+
Курс: { course.name }
+
Цена: { course.price }
+
Дата: { course.date }
+ + + + + handleUnsubscribe(index) }>Отписаться + + +
+
+
+ + )) } +
); }; diff --git a/frontend/src/app/globals.css b/frontend/src/app/globals.css index 70ca9f6..538412b 100644 --- a/frontend/src/app/globals.css +++ b/frontend/src/app/globals.css @@ -127,4 +127,28 @@ a { .landing-section { height: 80dvh; -} \ No newline at end of file +} + +/* Add this to your global CSS file */ + +.apply-section { + margin-top: 50px; +} + +.course-header { + text-align: center; + margin-top: 50px; +} + +.course-content { + margin-top: 50px; +} + +.modules-list { + list-style: none; + padding: 0; +} + +.module-content { + margin-top: 20px; +} diff --git a/frontend/src/components/cabinet/ClientCoursePage.tsx b/frontend/src/components/cabinet/ClientCoursePage.tsx new file mode 100644 index 0000000..ad9d1ca --- /dev/null +++ b/frontend/src/components/cabinet/ClientCoursePage.tsx @@ -0,0 +1,80 @@ +"use client"; // Ensure this is a client component + +import React, { useState } from "react"; +import { Button, Row, Col, Card, ListGroup } from "react-bootstrap"; // Import Bootstrap components + +interface Module { + id: string; + title: string; + content: string; +} + +interface Course { + id: string; + name: string; + description: string; + modules: Module[]; +} + +interface ClientCoursePageProps { + course: Course; +} + +const ClientCoursePage: React.FC = ({ course }) => { + const [ applied, setApplied ] = useState(false); + const [ currentModule, setCurrentModule ] = useState(null); + + const handleApply = () => { + setApplied(true); + setCurrentModule(course.modules[0]); + }; + + return ( +
+ { !applied ? ( +
+ +
+ ) : ( +
+ + + { currentModule ? ( + + + { currentModule.title } + { currentModule.content } + + + ) : ( + + + Выберите модуль для просмотра его содержимого + + + ) } + + +

Modules

+ + { course.modules.map((module) => ( + setCurrentModule(module) } + > + { module.title } + + )) } + + +
+
+ ) } +
+ ); +}; + +export default ClientCoursePage;