feat: edit tasks and general improvements

This commit is contained in:
swve 2024-07-14 14:06:25 +02:00
parent acfcea026b
commit 3c41e0ee73
13 changed files with 570 additions and 93 deletions

View file

@ -1,5 +1,6 @@
import { getAPIUrl } from '@services/config/config'
import {
RequestBodyFormWithAuthHeader,
RequestBodyWithAuthHeader,
getResponseMetadata,
} from '@services/utils/ts/requests'
@ -76,3 +77,38 @@ export async function getAssignmentTask(
const res = await getResponseMetadata(result)
return res
}
export async function updateAssignmentTask(
body: any,
assignmentTaskUUID: string,
assignmentUUID: string,
access_token: string
) {
const result: any = await fetch(
`${getAPIUrl()}assignments/${assignmentUUID}/tasks/${assignmentTaskUUID}`,
RequestBodyWithAuthHeader('PUT', body, null, access_token)
)
const res = await getResponseMetadata(result)
return res
}
export async function updateReferenceFile(
file: any,
assignmentTaskUUID: string,
assignmentUUID: string,
access_token: string
) {
// Send file thumbnail as form data
const formData = new FormData()
if (file) {
formData.append('reference_file', file)
}
const result: any = await fetch(
`${getAPIUrl()}assignments/${assignmentUUID}/tasks/${assignmentTaskUUID}/ref_file`,
RequestBodyFormWithAuthHeader('POST', formData, null, access_token)
)
const res = await getResponseMetadata(result)
return res
}