mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: add elements
This commit is contained in:
parent
938cfcb4b3
commit
6f2cc5bdc6
23 changed files with 241 additions and 104 deletions
|
|
@ -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" });
|
||||
|
|
@ -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" });
|
||||
27
front/services/courses/elements.ts
Normal file
27
front/services/courses/elements.ts
Normal 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue