import AuthenticatedClientElement from "@components/Security/AuthenticatedClientElement"; import TypeOfContentTitle from "@components/StyledElements/Titles/TypeOfContentTitle"; import GeneralWrapperStyled from "@components/StyledElements/Wrappers/GeneralWrapper"; import { getBackendUrl, getUriWithOrg } from "@services/config/config"; import { deleteCollection, getOrgCollectionsWithAuthHeader } from "@services/courses/collections"; import { getOrganizationContextInfo } from "@services/organizations/orgs"; import { Metadata } from "next"; import { cookies } from "next/headers"; import Link from "next/link"; import CollectionAdminEditsArea from "./admin"; type MetadataProps = { params: { orgslug: string, courseid: string }; searchParams: { [key: string]: string | string[] | undefined }; }; export async function generateMetadata( { params }: MetadataProps, ): Promise { const cookieStore = cookies(); 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}`, }; } const removeCollectionPrefix = (collectionid: string) => { return collectionid.replace("collection_", "") } const CollectionsPage = async (params: any) => { const cookieStore = cookies(); const access_token_cookie: any = cookieStore.get('access_token_cookie'); const orgslug = params.params.orgslug; 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 (
{collections.map((collection: any) => (

{collection.name}

{collection.courses.slice(0, 3).map((course: any) => ( {course.name} ))}
))}
); } export default CollectionsPage