export const dynamic = 'force-dynamic' import { Metadata } from 'next' import { getUriWithOrg } from '@services/config/config' import { getOrgCourses } from '@services/courses/courses' import Link from 'next/link' import { getOrganizationContextInfo } from '@services/organizations/orgs' import GeneralWrapperStyled from '@components/StyledElements/Wrappers/GeneralWrapper' import TypeOfContentTitle from '@components/StyledElements/Titles/TypeOfContentTitle' import CourseThumbnail from '@components/Objects/Thumbnails/CourseThumbnail' import CollectionThumbnail from '@components/Objects/Thumbnails/CollectionThumbnail' import AuthenticatedClientElement from '@components/Security/AuthenticatedClientElement' import NewCourseButton from '@components/StyledElements/Buttons/NewCourseButton' import NewCollectionButton from '@components/StyledElements/Buttons/NewCollectionButton' import ContentPlaceHolderIfUserIsNotAdmin from '@components/ContentPlaceHolder' import { getOrgCollections } from '@services/courses/collections' import { getServerSession } from 'next-auth' import { nextAuthOptions } from 'app/auth/options' type MetadataProps = { params: { orgslug: string } searchParams: { [key: string]: string | string[] | undefined } } export async function generateMetadata({ params, }: MetadataProps): Promise { // Get Org context information const org = await getOrganizationContextInfo(params.orgslug, { revalidate: 1800, tags: ['organizations'], }) // SEO return { title: `Home — ${org.name}`, description: org.description, robots: { index: true, follow: true, nocache: true, googleBot: { index: true, follow: true, 'max-image-preview': 'large', }, }, openGraph: { title: `Home — ${org.name}`, description: org.description, type: 'website', }, } } const OrgHomePage = async (params: any) => { const orgslug = params.params.orgslug const session = await getServerSession(nextAuthOptions) const access_token = session?.tokens?.access_token const courses = await getOrgCourses( orgslug, { revalidate: 0, tags: ['courses'] }, access_token ? access_token : null ) const org = await getOrganizationContextInfo(orgslug, { revalidate: 1800, tags: ['organizations'], }) const org_id = org.id const collections = await getOrgCollections( org.id, access_token ? access_token : null, { revalidate: 0, tags: ['courses'] } ) return (
{/* Collections */}
{collections.map((collection: any) => (
))} {collections.length == 0 && (

No collections yet

)}
{/* Courses */}
{courses.map((course: any) => (
))} {courses.length == 0 && (

No courses yet

)}
) } export default OrgHomePage