mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: course creation/del + file upload
This commit is contained in:
parent
9a8e4e4492
commit
c838b7e9cd
9 changed files with 151 additions and 21 deletions
|
|
@ -4,7 +4,7 @@ import React from "react";
|
|||
import { Header } from "../../../../components/ui/header";
|
||||
import Layout from "../../../../components/ui/layout";
|
||||
import { Title } from "../../../../components/ui/styles/title";
|
||||
import { getOrgCourses } from "../../../../services/courses";
|
||||
import { deleteCourseFromBackend, getOrgCourses } from "../../../../services/courses";
|
||||
import { getOrganizationContextInfo } from "../../../../services/orgs";
|
||||
|
||||
const CoursesIndexPage = () => {
|
||||
|
|
@ -22,6 +22,12 @@ const CoursesIndexPage = () => {
|
|||
setIsLoading(false);
|
||||
}
|
||||
|
||||
async function deleteCourses(course_id: any) {
|
||||
const response = await deleteCourseFromBackend(course_id);
|
||||
const newCourses = courses.filter((course: any) => course.course_id !== course_id);
|
||||
setCourses(newCourses);
|
||||
}
|
||||
|
||||
// function to remove "course_" from the course_id
|
||||
function removeCoursePrefix(course_id: string) {
|
||||
return course_id.replace("course_", "");
|
||||
|
|
@ -55,9 +61,12 @@ const CoursesIndexPage = () => {
|
|||
<div>
|
||||
{courses.map((course: any) => (
|
||||
<div key={course.course_id}>
|
||||
<Link href={"/org/" + orgslug + "/courses/" + removeCoursePrefix(course.course_id)}>
|
||||
<a><h2>{course.name}</h2></a>
|
||||
<Link href={"/org/" + orgslug + "/course/" + removeCoursePrefix(course.course_id)}>
|
||||
<a>
|
||||
<h2>{course.name}</h2>
|
||||
</a>
|
||||
</Link>
|
||||
<button onClick={() => deleteCourses(course.course_id)}>Delete</button>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue