mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: org scope collections
This commit is contained in:
parent
759a144fe9
commit
d4497e03fb
6 changed files with 126 additions and 54 deletions
|
|
@ -9,10 +9,7 @@ import React from 'react'
|
|||
const CollectionAdminEditsArea = (props: any) => {
|
||||
const org_roles_values = ["admin", "owner"];
|
||||
const user_roles_values = ["role_admin"];
|
||||
console.log("props: ", props);
|
||||
|
||||
const auth: any = React.useContext(AuthContext);
|
||||
console.log("auth: ", auth);
|
||||
|
||||
|
||||
// this is amazingly terrible code, but gotta release that MVP
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ export async function generateMetadata(
|
|||
const access_token_cookie: any = cookieStore.get('access_token_cookie');
|
||||
// Get Org context information
|
||||
const org = await getOrganizationContextInfo(params.orgslug, { revalidate: 1800, tags: ['organizations'] });
|
||||
|
||||
return {
|
||||
title: `Collections — ${org.name}`,
|
||||
description: `Collections of courses from ${org.name}`,
|
||||
|
|
@ -38,10 +37,9 @@ const CollectionsPage = async (params: any) => {
|
|||
const cookieStore = cookies();
|
||||
const access_token_cookie: any = cookieStore.get('access_token_cookie');
|
||||
const orgslug = params.params.orgslug;
|
||||
const collections = await getOrgCollectionsWithAuthHeader(access_token_cookie ? access_token_cookie.value : null);
|
||||
|
||||
|
||||
|
||||
const org = await getOrganizationContextInfo(orgslug, { revalidate: 1800, tags: ['organizations'] });
|
||||
const org_id = org.org_id;
|
||||
const collections = await getOrgCollectionsWithAuthHeader(org_id, access_token_cookie ? access_token_cookie.value : null);
|
||||
|
||||
return (
|
||||
<div className="max-w-7xl mx-auto px-4 py-10" >
|
||||
|
|
|
|||
|
|
@ -35,7 +35,8 @@ const OrgHomePage = async (params: any) => {
|
|||
const access_token_cookie: any = cookieStore.get('access_token_cookie');
|
||||
|
||||
const courses = await getOrgCoursesWithAuthHeader(orgslug, { revalidate: 0, tags: ['courses'] }, access_token_cookie ? access_token_cookie.value : null);
|
||||
const collections = await getOrgCollectionsWithAuthHeader(access_token_cookie ? access_token_cookie.value : null);
|
||||
const org = await getOrganizationContextInfo(orgslug, { revalidate: 1800, tags: ['organizations'] });
|
||||
const collections = await getOrgCollectionsWithAuthHeader(org.org_id, access_token_cookie ? access_token_cookie.value : null);
|
||||
|
||||
|
||||
// function to remove "course_" from the course_id
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ export async function createCollection(collection: any) {
|
|||
return res;
|
||||
}
|
||||
|
||||
|
||||
// Get a colletion by id
|
||||
export async function getCollectionById(collection_id: any) {
|
||||
const result: any = await fetch(`${getAPIUrl()}collections/${collection_id}`, { next: { revalidate: 10 } });
|
||||
|
|
@ -41,8 +40,8 @@ export async function getOrgCollections() {
|
|||
return res;
|
||||
}
|
||||
|
||||
export async function getOrgCollectionsWithAuthHeader(access_token: string) {
|
||||
const result: any = await fetch(`${getAPIUrl()}collections/page/1/limit/10`, RequestBodyWithAuthHeader("GET", null, { revalidate: 3 }, access_token));
|
||||
export async function getOrgCollectionsWithAuthHeader(org_id: string, access_token: string) {
|
||||
const result: any = await fetch(`${getAPIUrl()}collections/org_id/${org_id}/page/1/limit/10`, RequestBodyWithAuthHeader("GET", null, { revalidate: 3 }, access_token));
|
||||
const res = await errorHandling(result);
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue