Skip to content

Commit

Permalink
fix render box layout issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed-Ramadan1 committed Jun 4, 2024
1 parent dc66267 commit 4bad405
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ const CurrentVideoInformation = ({ selectVideoInformation }) => {
// console.log(selectVideoInformation || "");
return (
<div className="flex justify-between items-center h-full mt-3">
<div>{selectVideoInformation.title || ""}</div>
<div className="font-bold text-xl">
{selectVideoInformation.title || ""}
</div>
<TakeVideoNoteModal videoInformation={selectVideoInformation} />
</div>
);
Expand Down
6 changes: 4 additions & 2 deletions src/components/courses/courseContent/RenderBox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { customFetch } from "../../../utils/customFetch";
import VideoBox from "./VideoBox";
import VideoItem from "./VideoItem";

import { LoadingSpinner } from "../../../components";

const fakeUrl =
"https://res.cloudinary.com/dfjwny742/video/upload/v1715258237/Learn_HTML_In_Arabic_2021_-__03_-_First_Project_And_First_Page_720P_HD_uldnxx.mp4";

Expand All @@ -14,7 +16,7 @@ const RenderBox = ({ courseId }) => {
const [selectedVideo, setSelectedVideo] = useState(null);

const handleVideoClick = (course) => {
setSelectedVideo(course); // Update selected video state on click
setSelectedVideo(course);
};

useEffect(() => {
Expand All @@ -36,7 +38,7 @@ const RenderBox = ({ courseId }) => {
{initialVideo ? (
<VideoBox selectedVideoInformation={initialVideo} />
) : (
<div>Loading...</div>
<LoadingSpinner />
)}
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const TakeVideoNoteModal = ({ videoInformation }) => {
<div>
{/* You can open the modal using document.getElementById('ID').showModal() method */}
<button
className="btn text-2xl italic bg-blue-500 mt-2 hover:bg-blue-800 text-white font-bold py-2 px-4 rounded-[10px] focus:outline-none focus:shadow-outline"
className="btn text-xl italic bg-blue-500 mt-2 hover:bg-blue-800 text-white font-bold py-2 px-4 rounded-[10px] focus:outline-none focus:shadow-outline"
onClick={() => document.getElementById("my_modal_3").showModal()}
>
Take Note
Expand Down
24 changes: 14 additions & 10 deletions src/components/courses/courseReviews/ReviewElement.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,27 @@ const ReviewElement = ({ fullReview, currentUser, token, setIsChanged }) => {
return (
<div class="bg-white p-4 rounded-lg shadow-md mt-5">
<div>
<h3 class="text-lg font-bold">{user[0].name}</h3>
<p class="text-gray-700 text-sm mb-2">Posted on {formatDate}</p>
<div className="flex justify-between">
<h3 class="text-lg font-bold">{user[0].name}</h3>
<p class="text-gray-700 text-l mb-2">Posted on {formatDate}</p>
</div>
<p class="text-gray-700 text-l f">
Rating:{" "}
Rating:
<span className="text-blue-800 font-bold text-xl">{rating}</span>
</p>

<p class="text-gray-700">{review}</p>
</div>
{currentUser._id === user[0]._id && (
<button
onClick={handleDeleteReview}
type="button"
className="bg-red-500 mt-5 text-white p-1.5 rounded hover:bg-red-800"
>
Delete
</button>
<div className="flex justify-end ">
<button
onClick={handleDeleteReview}
type="button"
className="bg-red-500 mt-5 text-white p-1.5 rounded hover:bg-red-800 w-20 text-center"
>
Delete
</button>
</div>
)}
</div>
);
Expand Down
7 changes: 2 additions & 5 deletions src/components/courses/courseReviews/ReviewsContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { customFetch } from "../../../utils/customFetch";
import { Pagination } from "../../../components/";
import AddRatingForm from "./AddRatingForm";
import ReviewElement from "./ReviewElement";

import { LoadingSpinner } from "../../../components";
const ReviewsContainer = () => {
const [isChanged, setIsChanged] = useState(false);
const [reviews, setReviews] = useState([]);
Expand Down Expand Up @@ -40,7 +40,6 @@ const ReviewsContainer = () => {
setLoading(false);
setIsMorePages(false);
}
// console.log(res.data.data.reviews);
} catch (error) {
console.log(error.response.data.message);
}
Expand All @@ -65,9 +64,7 @@ const ReviewsContainer = () => {
setIsChanged={setIsChanged}
/>
))}
{loading && (
<p className="text-3xl text-bold text-center">No reviews found</p>
)}
{loading && <LoadingSpinner />}
{reviews.length === 0 && !loading && (
<p className="text-3xl text-bold text-center">No reviews found</p>
)}
Expand Down
4 changes: 4 additions & 0 deletions src/components/courses/coursesOverview/CourseCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const CourseCard = ({ course }) => {
photo,
language,
paymentModel,
financialAid,
category,
} = course;

Expand Down Expand Up @@ -42,6 +43,9 @@ const CourseCard = ({ course }) => {
<h3 className="text-sm font-bold text-[#333] max-md:text-base">
{category}
</h3>
<h3 className="text-sm font-bold text-blue-500 max-md:text-base">
{financialAid && "Financial Aid Available"}
</h3>
<p className="text-base font-medium text-[#6e6e6e] max-md:font-light max-md:truncate max-md:max-w-[200px]">
{description}
</p>
Expand Down
17 changes: 15 additions & 2 deletions src/components/courses/coursesOverview/OptionList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ const OptionList = ({ titleCheckList, setCourses, clearFilters }) => {
/>
))}
</FilterOptionsBox>

{/* skill level */}
<FilterOptionsBox
label="Skill Level"
Expand All @@ -135,7 +134,6 @@ const OptionList = ({ titleCheckList, setCourses, clearFilters }) => {
<FilterOptionItem key={level} value={level} OptionText={level} />
))}
</FilterOptionsBox>

{/*languages options */}
<FilterOptionsBox
label="Language"
Expand All @@ -158,6 +156,21 @@ const OptionList = ({ titleCheckList, setCourses, clearFilters }) => {
<FilterOptionItem key={el} value={el} OptionText={el} />
))}
</FilterOptionsBox>

{/* <FilterOptionsBox
label="Financial Aid "
id="financialAid"
value={formData.financialAid}
onChange={handleInputChange}
>
{["available", "not-available"].map((el) => (
<FilterOptionItem
key={el}
value={el === "available" ? true : false}
OptionText={el}
/>
))}
</FilterOptionsBox> */}
</div>
</div>
);
Expand Down
5 changes: 1 addition & 4 deletions src/pages/dashboard/Dashboard.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { useSelector } from "react-redux";
import { useState, useEffect } from "react";
import { customFetch } from "../../utils/customFetch";
import { useEffect } from "react";
import { PageIntro, StatsBox, StatsContainer } from "../../components";
import { LoadingSpinner } from "../../components";
import SyncLoader from "react-spinners/SyncLoader";

import useFetchData from "../../hooks/useFetchData";
function Dashboard() {
Expand All @@ -23,7 +21,6 @@ function Dashboard() {
useEffect(() => {
fetchData();
}, [token]);
console.log(data);
return (
<>
<div className="p-5">
Expand Down
12 changes: 9 additions & 3 deletions src/pages/mainLayout/MyPaiedCourse.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import { useParams, Link } from "react-router-dom";
import { customFetch } from "../../utils/customFetch";
import RenderBox from "../../components/courses/courseContent/RenderBox";
import ReviewsContainer from "../../components/courses/courseReviews/ReviewsContainer";

import { LoadingSpinner } from "../../components";
function MyPaiedCourse() {
const [isEnrolled, setIsEnrolled] = useState(false);
const { courseId } = useParams();
const [loading, setLoading] = useState(true);
const { token, user } = useSelector((state) => state.userReducers);

useEffect(() => {
Expand All @@ -21,21 +22,26 @@ function MyPaiedCourse() {

if (res.data.data.enrollments.user._id === user._id) {
setIsEnrolled(true);
setLoading(false);
}
} catch (error) {
console.log(error);
setLoading(false);
}
};
fetchEnrolledCourse();
}, [courseId, token, user]);
return (
<>
{isEnrolled ? (
{isEnrolled && (
<>
<RenderBox courseId={courseId} />
<ReviewsContainer />
</>
) : (
)}
{loading && <LoadingSpinner />}

{!loading && isEnrolled === false && (
<div className="container flex justify-center items-center h-[80vh] flex-col">
<h1 className="text-4xl ">You are not enrolled in this course</h1>
<Link
Expand Down

0 comments on commit 4bad405

Please sign in to comment.