diff --git a/src/components/courses/courseDetails/CourseContentDetails.jsx b/src/components/courses/courseDetails/CourseContentDetails.jsx index 97fc3eb..18284c1 100644 --- a/src/components/courses/courseDetails/CourseContentDetails.jsx +++ b/src/components/courses/courseDetails/CourseContentDetails.jsx @@ -6,23 +6,38 @@ import CourseRequirementSection from "./CourseRequirementSection"; import CourseInstructorDetails from "./CourseInstructorDetails"; import CourseDetails from "./CourseDetails"; import { MdAttachMoney } from "react-icons/md"; - -const CourseContentDetails = ({ - title, - description, - duration, - totalReviews, - averageRating, - updatedAt, - language, - learningObjectives, - videos, - instructor, - prerequisites, - financialAid, - paymentModel, -}) => { +import { useEffect, useState } from "react"; +import PaymentDetailsModal from "./PaymentDetailsModal"; +const CourseContentDetails = ({ course }) => { + const { + title, + description, + duration, + totalReviews, + averageRating, + updatedAt, + language, + learningObjectives, + videos, + prerequisites, + financialAid, + paymentModel, + } = course; + const instructor = course.instructor[0]; const formatUpdatedDate = new Date(updatedAt).toLocaleDateString(); + const [isLargeScreen, setIsLargeScreen] = useState(false); + + useEffect(() => { + const handleResize = () => { + setIsLargeScreen(window.innerWidth > 970); + }; + handleResize(); + window.addEventListener("resize", handleResize); + return () => { + window.removeEventListener("resize", handleResize); + }; + }, []); + return (
@@ -38,6 +53,11 @@ const CourseContentDetails = ({

{description}

+ {!isLargeScreen && ( +
+ +
+ )}
diff --git a/src/components/courses/courseDetails/CourseEnrollmentDetails.jsx b/src/components/courses/courseDetails/CourseEnrollmentDetails.jsx index 37e001d..d773c30 100644 --- a/src/components/courses/courseDetails/CourseEnrollmentDetails.jsx +++ b/src/components/courses/courseDetails/CourseEnrollmentDetails.jsx @@ -69,7 +69,7 @@ const CourseEnrollmentDetails = ({ }, [courseId, token, user, isChanged]); //max-md:flex-col return ( -
+
{paymentModel === "free" ? ( diff --git a/src/components/courses/courseDetails/PaymentDetailsModal.jsx b/src/components/courses/courseDetails/PaymentDetailsModal.jsx new file mode 100644 index 0000000..e253385 --- /dev/null +++ b/src/components/courses/courseDetails/PaymentDetailsModal.jsx @@ -0,0 +1,36 @@ +import CourseEnrollmentDetails from "./CourseEnrollmentDetails"; +const PaymentDetailsModal = ({ course }) => { + const { duration, price, paymentModel, _id, videos, financialAid } = course; + return ( + <> + + +
+

Course Enrollment information

+

+ +

+
+
+ +
+
+
+
+ + ); +}; + +export default PaymentDetailsModal; diff --git a/src/components/payment/PaymentForm.jsx b/src/components/payment/PaymentForm.jsx index 0c8c6e6..bbb3184 100644 --- a/src/components/payment/PaymentForm.jsx +++ b/src/components/payment/PaymentForm.jsx @@ -39,8 +39,6 @@ const PaymentForm = ({ coursePrice, courseDiscount, courseId }) => { } ); toast.success("Payment and enrollment Successfull"); - // window.location.reload(); - // navigate(`/courses/${courseId}`); navigate(`/courses/${courseId}`, { replace: true }); } catch (error) { console.log(error); diff --git a/src/pages/mainLayout/CourseDetails.jsx b/src/pages/mainLayout/CourseDetails.jsx index 51f4970..37facc3 100644 --- a/src/pages/mainLayout/CourseDetails.jsx +++ b/src/pages/mainLayout/CourseDetails.jsx @@ -14,8 +14,13 @@ const DetailsCourse = () => { const [enrollments, setEnrollments] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(""); + const [isLargeScreen, setIsLargeScreen] = useState(false); useEffect(() => { + const handleResize = () => { + setIsLargeScreen(window.innerWidth > 970); + }; + const fetchCourse = async () => { try { const response = await customFetch.get(`/courses/${courseId}`); @@ -29,8 +34,19 @@ const DetailsCourse = () => { } }; fetchCourse(); + handleResize(); + + window.addEventListener("resize", handleResize); + return () => { + window.removeEventListener("resize", handleResize); + }; }, [courseId]); - if (loading) return

Loading...

; + if (loading) + return ( +

+ Loading... +

+ ); if (error) return

{error}

; return (
@@ -44,30 +60,18 @@ const DetailsCourse = () => {
- + - + {isLargeScreen && ( + + )}
@@ -75,3 +79,17 @@ const DetailsCourse = () => { }; export default DetailsCourse; + +// title={course.title} +// description={course.description} +// duration={course.duration} +// totalReviews={course.totalReviews} +// averageRating={course.averageRating} +// updatedAt={course.updatedAt} +// language={course.language} +// learningObjectives={course.learningObjectives} +// videos={course.videos} +// instructor={course.instructor[0]} +// prerequisites={course.prerequisites} +// financialAid={course.financialAid} +// paymentModel={course.paymentModel}