Skip to content

Commit

Permalink
created my courses components for instructor dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
amitamrutiya committed Nov 8, 2023
1 parent d1c0313 commit 0c75741
Showing 1 changed file with 36 additions and 0 deletions.
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>
);
}

0 comments on commit 0c75741

Please sign in to comment.