mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: format with prettier
This commit is contained in:
parent
03fb09c3d6
commit
a147ad6610
164 changed files with 11257 additions and 8154 deletions
|
|
@ -1,70 +1,108 @@
|
|||
import { getAPIUrl } from "@services/config/config";
|
||||
import { RequestBody, RequestBodyForm, RequestBodyWithAuthHeader } from "@services/utils/ts/requests";
|
||||
import { getAPIUrl } from '@services/config/config'
|
||||
import {
|
||||
RequestBody,
|
||||
RequestBodyForm,
|
||||
RequestBodyWithAuthHeader,
|
||||
} from '@services/utils/ts/requests'
|
||||
|
||||
export async function createActivity(data: any, chapter_id: any, org_id: any) {
|
||||
data.content = {};
|
||||
data.content = {}
|
||||
// remove chapter_id from data
|
||||
delete data.chapterId;
|
||||
delete data.chapterId
|
||||
|
||||
const result = await fetch(`${getAPIUrl()}activities/?coursechapter_id=${chapter_id}&org_id=${org_id}`, RequestBody("POST", data, null));
|
||||
const res = await result.json();
|
||||
return res;
|
||||
const result = await fetch(
|
||||
`${getAPIUrl()}activities/?coursechapter_id=${chapter_id}&org_id=${org_id}`,
|
||||
RequestBody('POST', data, null)
|
||||
)
|
||||
const res = await result.json()
|
||||
return res
|
||||
}
|
||||
|
||||
export async function createFileActivity(file: File, type: string, data: any, chapter_id: any) {
|
||||
export async function createFileActivity(
|
||||
file: File,
|
||||
type: string,
|
||||
data: any,
|
||||
chapter_id: any
|
||||
) {
|
||||
// Send file thumbnail as form data
|
||||
const formData = new FormData();
|
||||
formData.append("chapter_id", chapter_id);
|
||||
const formData = new FormData()
|
||||
formData.append('chapter_id', chapter_id)
|
||||
|
||||
let endpoint = "";
|
||||
let endpoint = ''
|
||||
|
||||
if (type === "video") {
|
||||
formData.append("name", data.name);
|
||||
formData.append("video_file", file);
|
||||
endpoint = `${getAPIUrl()}activities/video`;
|
||||
} else if (type === "documentpdf") {
|
||||
formData.append("pdf_file", file);
|
||||
formData.append("name", data.name);
|
||||
endpoint = `${getAPIUrl()}activities/documentpdf`;
|
||||
if (type === 'video') {
|
||||
formData.append('name', data.name)
|
||||
formData.append('video_file', file)
|
||||
endpoint = `${getAPIUrl()}activities/video`
|
||||
} else if (type === 'documentpdf') {
|
||||
formData.append('pdf_file', file)
|
||||
formData.append('name', data.name)
|
||||
endpoint = `${getAPIUrl()}activities/documentpdf`
|
||||
} else {
|
||||
// Handle other file types here
|
||||
}
|
||||
|
||||
const result: any = await fetch(endpoint, RequestBodyForm("POST", formData, null));
|
||||
const res = await result.json();
|
||||
return res;
|
||||
const result: any = await fetch(
|
||||
endpoint,
|
||||
RequestBodyForm('POST', formData, null)
|
||||
)
|
||||
const res = await result.json()
|
||||
return res
|
||||
}
|
||||
|
||||
export async function createExternalVideoActivity(data: any, activity: any, chapter_id: any) {
|
||||
export async function createExternalVideoActivity(
|
||||
data: any,
|
||||
activity: any,
|
||||
chapter_id: any
|
||||
) {
|
||||
// add coursechapter_id to data
|
||||
data.chapter_id = chapter_id;
|
||||
data.activity_id = activity.id;
|
||||
data.chapter_id = chapter_id
|
||||
data.activity_id = activity.id
|
||||
|
||||
const result = await fetch(`${getAPIUrl()}activities/external_video`, RequestBody("POST", data, null));
|
||||
const res = await result.json();
|
||||
return res;
|
||||
const result = await fetch(
|
||||
`${getAPIUrl()}activities/external_video`,
|
||||
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 res = await result.json();
|
||||
return res;
|
||||
const result = await fetch(
|
||||
`${getAPIUrl()}activities/${activity_id}`,
|
||||
RequestBody('GET', null, next)
|
||||
)
|
||||
const res = await result.json()
|
||||
return res
|
||||
}
|
||||
|
||||
export async function deleteActivity(activity_id: any) {
|
||||
const result = await fetch(`${getAPIUrl()}activities/${activity_id}`, RequestBody("DELETE", null, null));
|
||||
const res = await result.json();
|
||||
return res;
|
||||
const result = await fetch(
|
||||
`${getAPIUrl()}activities/${activity_id}`,
|
||||
RequestBody('DELETE', null, null)
|
||||
)
|
||||
const res = await result.json()
|
||||
return res
|
||||
}
|
||||
|
||||
export async function getActivityWithAuthHeader(activity_uuid: any, next: any, access_token: string) {
|
||||
const result = await fetch(`${getAPIUrl()}activities/activity_${activity_uuid}`, RequestBodyWithAuthHeader("GET", null, next, access_token));
|
||||
const res = await result.json();
|
||||
return res;
|
||||
export async function getActivityWithAuthHeader(
|
||||
activity_uuid: any,
|
||||
next: any,
|
||||
access_token: string
|
||||
) {
|
||||
const result = await fetch(
|
||||
`${getAPIUrl()}activities/activity_${activity_uuid}`,
|
||||
RequestBodyWithAuthHeader('GET', null, next, access_token)
|
||||
)
|
||||
const res = await result.json()
|
||||
return res
|
||||
}
|
||||
|
||||
export async function updateActivity(data: any, activity_uuid: string) {
|
||||
const result = await fetch(`${getAPIUrl()}activities/${activity_uuid}`, RequestBody("PUT", data, null));
|
||||
const res = await result.json();
|
||||
return res;
|
||||
const result = await fetch(
|
||||
`${getAPIUrl()}activities/${activity_uuid}`,
|
||||
RequestBody('PUT', data, null)
|
||||
)
|
||||
const res = await result.json()
|
||||
return res
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue