feat: add elements

This commit is contained in:
swve 2022-11-11 20:36:09 +01:00
parent 938cfcb4b3
commit 6f2cc5bdc6
23 changed files with 241 additions and 104 deletions

View file

@ -1,5 +1,5 @@
import { initialData } from "../components/drags/data";
import { getAPIUrl } from "./config";
import { initialData } from "../../components/drags/data";
import { getAPIUrl } from "../config";
export async function getCourseChaptersMetadata(course_id: any) {
const HeadersConfig = new Headers({ "Content-Type": "application/json" });

View file

@ -1,4 +1,4 @@
import { getAPIUrl } from "./config";
import { getAPIUrl } from "../config";
export async function getOrgCourses(org_id: number) {
const HeadersConfig = new Headers({ "Content-Type": "application/json" });

View file

@ -0,0 +1,27 @@
import { getAPIUrl } from "../config";
export async function createElement(data: any, chapter_id: any) {
data.content = {}
console.log("data", data, chapter_id);
// remove chapter_id from data
delete data.chapterId;
const HeadersConfig = new Headers({ "Content-Type": "application/json" });
const requestOptions: any = {
method: "POST",
headers: HeadersConfig,
redirect: "follow",
credentials: "include",
body: JSON.stringify(data),
};
const result: any = await fetch(`${getAPIUrl()}elements/?coursechapter_id=${chapter_id}`, requestOptions)
.then((result) => result.json())
.catch((error) => console.log("error", error));
console.log("result", result);
return result;
}