-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
created my courses components for instructor dashboard
- Loading branch information
1 parent
d1c0313
commit 0c75741
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
frontend/src/components/core/Dashboard/InstructorCourses/MyCourses.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { useEffect, useState } from "react"; | ||
import { VscAdd } from "react-icons/vsc"; | ||
import { useSelector } from "react-redux"; | ||
import { useNavigate } from "react-router-dom"; | ||
import { fetchInstructorCourses } from "../../../../services/operations/courseDetailsAPI.js"; | ||
import IconBtn from "../../../common/IconBtn.jsx"; | ||
import CoursesTable from "./CoursesTable.jsx"; | ||
|
||
export default function MyCourses() { | ||
const { token } = useSelector((state) => state.auth); | ||
const navigate = useNavigate(); | ||
const [courses, setCourses] = useState([]); | ||
|
||
useEffect(() => { | ||
const fetchCourses = async () => { | ||
const result = await fetchInstructorCourses(token); | ||
if (result) setCourses(result); | ||
}; | ||
fetchCourses(); | ||
}, []); | ||
|
||
return ( | ||
<div> | ||
<div className="mb-14 flex items-center justify-between"> | ||
<h1 className="text-3xl font-medium text-richblack-5">My Courses</h1> | ||
<IconBtn | ||
text="Add Course" | ||
onclick={() => navigate("/dashboard/add-course")} | ||
> | ||
<VscAdd /> | ||
</IconBtn> | ||
</div> | ||
{courses && <CoursesTable courses={courses} setCourses={setCourses} />} | ||
</div> | ||
); | ||
} |