export const dynamic = 'force-dynamic'; import { Metadata } from 'next'; import { getUriWithOrg } from "@services/config/config"; import { getOrgCoursesWithAuthHeader } from "@services/courses/courses"; import Link from "next/link"; import { getOrgCollectionsWithAuthHeader } from "@services/courses/collections"; import { getOrganizationContextInfo } from '@services/organizations/orgs'; import { cookies } from 'next/headers'; import GeneralWrapperStyled from '@components/StyledElements/Wrappers/GeneralWrapper'; import TypeOfContentTitle from '@components/StyledElements/Titles/TypeOfContentTitle'; import { getAccessTokenFromRefreshTokenCookie } from '@services/auth/auth'; import CourseThumbnail from '@components/Objects/Other/CourseThumbnail'; import CollectionThumbnail from '@components/Objects/Other/CollectionThumbnail'; import AuthenticatedClientElement from '@components/Security/AuthenticatedClientElement'; import { Plus, PlusCircle } from 'lucide-react'; import NewCourseButton from '@components/StyledElements/Buttons/NewCourseButton'; import NewCollectionButton from '@components/StyledElements/Buttons/NewCollectionButton'; 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 cookieStore = cookies(); const access_token = await getAccessTokenFromRefreshTokenCookie(cookieStore) const courses = await getOrgCoursesWithAuthHeader(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 getOrgCollectionsWithAuthHeader(org.id, access_token ? access_token : null, { revalidate: 0, tags: ['courses'] }); return (
{/* Collections */}
{collections.map((collection: any) => (
))} {collections.length == 0 &&

No collections yet

Create a collection to group courses together

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

No courses yet

Create a course to add content

}
); }; export default OrgHomePage;