diff --git a/front/app/orgs/[orgslug]/(withmenu)/collections/admin.tsx b/front/app/orgs/[orgslug]/(withmenu)/collections/admin.tsx
deleted file mode 100644
index 09ad6d53..00000000
--- a/front/app/orgs/[orgslug]/(withmenu)/collections/admin.tsx
+++ /dev/null
@@ -1,48 +0,0 @@
-'use client';
-
-import AuthenticatedClientElement from '@components/Security/AuthenticatedClientElement';
-import { AuthContext } from '@components/Security/AuthProvider';
-import ConfirmationModal from '@components/StyledElements/ConfirmationModal/ConfirmationModal';
-import { getUriWithOrg } from '@services/config/config';
-import { deleteCollection } from '@services/courses/collections';
-import { revalidateTags } from '@services/utils/ts/requests';
-import { Link, Trash, X } from 'lucide-react';
-import { useRouter } from 'next/navigation';
-import React from 'react'
-
-const CollectionAdminEditsArea = (props: any) => {
- const router = useRouter();
-
- const deleteCollectionUI = async (collectionId: number) => {
- await deleteCollection(collectionId);
- await revalidateTags(["collections"], props.orgslug);
- // reload the page
- router.refresh();
- router.push(getUriWithOrg(props.orgslug, "/collections"));
-
- // refresh page (FIX for Next.js BUG)
- //window.location.reload();
- }
-
- return (
-
-
-
-
-
}
- functionToExecute={() => deleteCollectionUI(props.collection_id)}
- status='warning'
- >
-
-
- )
-}
-
-export default CollectionAdminEditsArea;
\ No newline at end of file
diff --git a/front/app/orgs/[orgslug]/(withmenu)/collections/page.tsx b/front/app/orgs/[orgslug]/(withmenu)/collections/page.tsx
index 82399971..9a1c5fa6 100644
--- a/front/app/orgs/[orgslug]/(withmenu)/collections/page.tsx
+++ b/front/app/orgs/[orgslug]/(withmenu)/collections/page.tsx
@@ -7,9 +7,9 @@ import { getOrganizationContextInfo } from "@services/organizations/orgs";
import { Metadata } from "next";
import { cookies } from "next/headers";
import Link from "next/link";
-import CollectionAdminEditsArea from "./admin";
import { getCourseThumbnailMediaDirectory } from "@services/media/media";
import { getAccessTokenFromRefreshTokenCookie, getNewAccessTokenUsingRefreshTokenServer } from "@services/auth/auth";
+import CollectionThumbnail from "@components/Objects/Other/CollectionThumbnail";
type MetadataProps = {
params: { orgslug: string, courseid: string };
@@ -22,7 +22,7 @@ export async function generateMetadata(
const cookieStore = cookies();
// Get Org context information
const org = await getOrganizationContextInfo(params.orgslug, { revalidate: 1800, tags: ['organizations'] });
-
+
// SEO
return {
title: `Collections — ${org.name}`,
@@ -45,10 +45,6 @@ export async function generateMetadata(
};
}
-const removeCollectionPrefix = (collectionid: string) => {
- return collectionid.replace("collection_", "")
-}
-
const CollectionsPage = async (params: any) => {
const cookieStore = cookies();
@@ -71,19 +67,7 @@ const CollectionsPage = async (params: any) => {
{collections.map((collection: any) => (
-
-
-
-
{collection.name}
-
- {collection.courses.slice(0, 3).map((course: any) => (
-
-

-
- ))}
-
-
-
+
))}
diff --git a/front/app/orgs/[orgslug]/(withmenu)/courses/courses.tsx b/front/app/orgs/[orgslug]/(withmenu)/courses/courses.tsx
index f5af8a02..afabb52d 100644
--- a/front/app/orgs/[orgslug]/(withmenu)/courses/courses.tsx
+++ b/front/app/orgs/[orgslug]/(withmenu)/courses/courses.tsx
@@ -17,6 +17,7 @@ import AuthenticatedClientElement from '@components/Security/AuthenticatedClient
import { getCourseThumbnailMediaDirectory } from '@services/media/media';
import ConfirmationModal from '@components/StyledElements/ConfirmationModal/ConfirmationModal';
import { Pencil, X } from 'lucide-react';
+import CourseThumbnail from '@components/Objects/Other/CourseThumbnail';
interface CourseProps {
orgslug: string;
@@ -75,13 +76,7 @@ function Courses(props: CourseProps) {
{courses.map((course: any) => (
-
-
-
-
-
-
-
{course.name}
+
))}
@@ -107,11 +102,11 @@ const AdminEditsArea = (props: { orgSlug: string, courseId: string, course: any,
status='warning'
>
-
+
diff --git a/front/app/orgs/[orgslug]/(withmenu)/page.tsx b/front/app/orgs/[orgslug]/(withmenu)/page.tsx
index 83675fb2..ebfac310 100644
--- a/front/app/orgs/[orgslug]/(withmenu)/page.tsx
+++ b/front/app/orgs/[orgslug]/(withmenu)/page.tsx
@@ -13,6 +13,8 @@ import GeneralWrapperStyled from '@components/StyledElements/Wrappers/GeneralWra
import TypeOfContentTitle from '@components/StyledElements/Titles/TypeOfContentTitle';
import { getCourseThumbnailMediaDirectory } from '@services/media/media';
import { getAccessTokenFromRefreshTokenCookie, getNewAccessTokenUsingRefreshTokenServer } from '@services/auth/auth';
+import CourseThumbnail from '@components/Objects/Other/CourseThumbnail';
+import CollectionThumbnail from '@components/Objects/Other/CollectionThumbnail';
type MetadataProps = {
params: { orgslug: string };
@@ -74,18 +76,7 @@ const OrgHomePage = async (params: any) => {
{collections.map((collection: any) => (
-
-
-
{collection.name}
-
- {collection.courses.slice(0, 3).map((course: any) => (
-
-

-
- ))}
-
-
-
+
))}
@@ -96,11 +87,7 @@ const OrgHomePage = async (params: any) => {
{courses.map((course: any) => (
-
-
-
-
-
{course.name}
+
))}
diff --git a/front/components/Objects/Other/CollectionThumbnail.tsx b/front/components/Objects/Other/CollectionThumbnail.tsx
new file mode 100644
index 00000000..7075e595
--- /dev/null
+++ b/front/components/Objects/Other/CollectionThumbnail.tsx
@@ -0,0 +1,81 @@
+"use client";
+import AuthenticatedClientElement from '@components/Security/AuthenticatedClientElement'
+import ConfirmationModal from '@components/StyledElements/ConfirmationModal/ConfirmationModal'
+import { getUriWithOrg } from '@services/config/config'
+import { deleteCollection } from '@services/courses/collections'
+import { getCourseThumbnailMediaDirectory } from '@services/media/media'
+import { revalidateTags } from '@services/utils/ts/requests'
+import { X } from 'lucide-react'
+import Link from 'next/link'
+import { useRouter } from 'next/navigation'
+import React from 'react'
+
+type PropsType = {
+ collection: any,
+ orgslug: string,
+ org_id: string
+}
+
+const removeCollectionPrefix = (collectionid: string) => {
+ return collectionid.replace("collection_", "")
+}
+
+function CollectionThumbnail(props: PropsType) {
+ return (
+
+
+
+
+
+ {props.collection.courses.slice(0, 3).map((course: any) => (
+
+
+
+
+
+
+ ))}
+
+
{props.collection.name}
+
+
+
+ )
+}
+
+const CollectionAdminEditsArea = (props: any) => {
+ const router = useRouter();
+
+ const deleteCollectionUI = async (collectionId: number) => {
+ await deleteCollection(collectionId);
+ await revalidateTags(["collections"], props.orgslug);
+ // reload the page
+ router.refresh();
+ router.push(getUriWithOrg(props.orgslug, "/collections"));
+
+ // refresh page (FIX for Next.js BUG)
+ //window.location.reload();
+ }
+
+ return (
+
+
+
+
+
}
+ functionToExecute={() => deleteCollectionUI(props.collection_id)}
+ status='warning'
+ >
+
+
+ )
+}
+
+export default CollectionThumbnail
\ No newline at end of file
diff --git a/front/components/Objects/Other/CourseThumbnail.tsx b/front/components/Objects/Other/CourseThumbnail.tsx
new file mode 100644
index 00000000..2aa2eaa8
--- /dev/null
+++ b/front/components/Objects/Other/CourseThumbnail.tsx
@@ -0,0 +1,76 @@
+"use client";
+import AuthenticatedClientElement from '@components/Security/AuthenticatedClientElement';
+import ConfirmationModal from '@components/StyledElements/ConfirmationModal/ConfirmationModal';
+import { getUriWithOrg } from '@services/config/config';
+import { deleteCourseFromBackend } from '@services/courses/courses';
+import { getCourseThumbnailMediaDirectory } from '@services/media/media';
+import { revalidateTags } from '@services/utils/ts/requests';
+import { FileEdit, Pencil, X } from 'lucide-react';
+import Link from 'next/link';
+import { useRouter } from 'next/navigation';
+import React from 'react'
+
+type PropsType = {
+ course: any,
+ orgslug: string
+}
+
+// function to remove "course_" from the course_id
+function removeCoursePrefix(course_id: string) {
+ return course_id.replace("course_", "");
+}
+
+function CourseThumbnail(props: PropsType) {
+ const router = useRouter();
+
+ async function deleteCourses(course_id: any) {
+ await deleteCourseFromBackend(course_id);
+ await revalidateTags(['courses'], props.orgslug);
+
+ router.refresh();
+ }
+
+ return (
+
+
+
+
+
+
+
+
{props.course.name}
+
+ )
+}
+
+const AdminEditsArea = (props: { orgSlug: string, courseId: string, course: any, deleteCourses: any }) => {
+ return (
+
+ }
+ functionToExecute={() => props.deleteCourses(props.courseId)}
+ status='warning'
+ >
+
+
+
+ )
+}
+
+export default CourseThumbnail
\ No newline at end of file