feat: migrate activity page to server component

This commit is contained in:
swve 2023-05-22 18:01:36 +00:00
parent 9b224a4331
commit b6e5b1b616
6 changed files with 369 additions and 303 deletions

View file

@ -1,5 +1,5 @@
import { getAPIUrl } from "@services/config/config";
import { RequestBody, RequestBodyForm } from "@services/utils/ts/requests";
import { RequestBody, RequestBodyForm, RequestBodyWithAuthHeader } from "@services/utils/ts/requests";
export async function createActivity(data: any, chapter_id: any, org_id: any) {
data.content = {};
@ -40,14 +40,20 @@ export async function createExternalVideoActivity(data: any, activity: any, chap
// add coursechapter_id to data
data.coursechapter_id = chapter_id;
data.activity_id = activity.id;
const result = await fetch(`${getAPIUrl()}activities/external_video?coursechapter_id=${chapter_id}`, RequestBody("POST", data, null));
const res = await result.json();
return res;
}
export async function getActivity(activity_id: any, next: any) {
const result = await fetch(`${getAPIUrl()}activities/${activity_id}`, RequestBody("GET", null,next));
const result = await fetch(`${getAPIUrl()}activities/${activity_id}`, RequestBody("GET", null, next));
const res = await result.json();
return res;
}
export async function getActivityWithAuthHeader(activity_id: any, next: any, access_token: string) {
const result = await fetch(`${getAPIUrl()}activities/activity_${activity_id}`, RequestBodyWithAuthHeader("GET", null, next, access_token));
const res = await result.json();
return res;
}