feat: use swr for activity

This commit is contained in:
swve 2023-01-24 22:21:37 +01:00
parent cad10078ae
commit 007ed6c8ea
6 changed files with 56 additions and 54 deletions

View file

@ -1,5 +1,5 @@
import { RequestBody } from "@services/utils/requests";
import { getAPIUrl } from "../config";
import { getAPIUrl } from "@services/config";
/*
This file includes only POST, PUT, DELETE requests
@ -30,11 +30,3 @@ export async function maskLectureAsComplete(org_id: string, course_id: string, l
return result;
}
// get all activities
export async function getActivities(org_id: string) {
const result: any = await fetch(`${getAPIUrl()}activity/${org_id}/activities`, RequestBody("GET", null))
.then((result) => result.json())
.catch((error) => console.log("error", error));
return result;
}

View file

@ -1,19 +1,9 @@
import { getAPIUrl } from "./config";
import { getAPIUrl } from "@services/config";
export async function getUserOrganizations() {
const HeadersConfig = new Headers({ "Content-Type": "application/json" });
const requestOptions: any = {
method: "GET",
headers: HeadersConfig,
redirect: "follow",
credentials: "include",
};
return fetch(`${getAPIUrl()}orgs/user/page/1/limit/10`, requestOptions)
.then((result) => result.json())
.catch((error) => console.log("error", error));
}
/*
This file includes only POST, PUT, DELETE requests
GET requests are called from the frontend using SWR (https://swr.vercel.app/)
*/
export async function createNewOrganization(body: any) {
const HeadersConfig = new Headers({ "Content-Type": "application/json" });
@ -31,8 +21,6 @@ export async function createNewOrganization(body: any) {
.catch((error) => console.log("error", error));
}
// export async function getOrganizationData(org_id) {}
export async function deleteOrganizationFromBackend(org_id: any) {
const HeadersConfig = new Headers({ "Content-Type": "application/json" });
@ -48,7 +36,6 @@ export async function deleteOrganizationFromBackend(org_id: any) {
.catch((error) => console.log("error", error));
}
// export async function updateOrganization(org_id) {}
export async function getOrganizationContextInfo(org_slug : any){
const HeadersConfig = new Headers({ "Content-Type": "application/json" });