diff --git a/front/app/_orgs/[orgslug]/(withmenu)/courses/courses.tsx b/front/app/_orgs/[orgslug]/(withmenu)/courses/courses.tsx
new file mode 100644
index 00000000..c9080c7f
--- /dev/null
+++ b/front/app/_orgs/[orgslug]/(withmenu)/courses/courses.tsx
@@ -0,0 +1,102 @@
+'use client';
+import CreateCourseModal from '@components/Modals/Course/Create/CreateCourse';
+import Modal from '@components/UI/Modal/Modal';
+import { Edit2, Trash } from "lucide-react";
+import { getAPIUrl, getBackendUrl, getUriWithOrg } from '@services/config/config';
+import CoursesLogo from "public/svg/courses.svg";
+import CollectionsLogo from "public/svg/collections.svg";
+import { deleteCourseFromBackend } from '@services/courses/courses';
+import Link from 'next/link';
+import React from 'react'
+import Image from 'next/image';
+
+interface CourseProps {
+ orgslug: string;
+ courses: any;
+}
+
+function Courses(props: CourseProps) {
+ const orgslug = props.orgslug;
+ const courses = props.courses;
+ const [newCourseModal, setNewCourseModal] = React.useState(false);
+
+ async function deleteCourses(course_id: any) {
+ await deleteCourseFromBackend(course_id);
+ }
+
+ async function closeNewCourseModal() {
+ setNewCourseModal(false);
+ }
+
+ // function to remove "course_" from the course_id
+ function removeCoursePrefix(course_id: string) {
+ return course_id.replace("course_", "");
+ }
+
+
+ return (
+
+
+
+
+ }
+ dialogTitle="Create Course"
+ dialogDescription="Create a new course"
+ dialogTrigger={
+
+ }
+ />
+
+
+
+
+
+
+ {courses.map((course: any) => (
+
+
+
+
+
+
+
+
+
+
+
+
+
{course.name}
+
+ ))}
+
+
+
+
+
+
+ )
+}
+
+export const Title = (props: any) => {
+ return (
+
+ )
+}
+
+export default Courses
\ No newline at end of file
diff --git a/front/app/_orgs/[orgslug]/(withmenu)/courses/page.tsx b/front/app/_orgs/[orgslug]/(withmenu)/courses/page.tsx
index 5876a9df..831dc15e 100644
--- a/front/app/_orgs/[orgslug]/(withmenu)/courses/page.tsx
+++ b/front/app/_orgs/[orgslug]/(withmenu)/courses/page.tsx
@@ -1,113 +1,24 @@
-"use client";
-import Link from "next/link";
-import { useRouter } from "next/navigation";
+
import React from "react";
-import styled from "styled-components";
-import { Title } from "@components/UI/Elements/Styles/Title";
-import { getAPIUrl, getBackendUrl, getSelfHostedOption, getUriWithOrg } from "@services/config/config";
-import { deleteCourseFromBackend } from "@services/courses/courses";
-import useSWR, { mutate } from "swr";
-import { swrFetcher } from "@services/utils/ts/requests";
-import { Edit2, Trash } from "lucide-react";
-import Modal from "@components/UI/Modal/Modal";
-import CreateCourseModal from "@components/Modals/Course/Create/CreateCourse";
+import Courses from "./courses";
+import { getOrgCourses } from "@services/courses/courses";
+import { Metadata } from "next";
-const CoursesIndexPage = (params: any) => {
- const router = useRouter();
+export const metadata: Metadata = {
+ title: 'LearnHouse - Courses',
+ description: 'courses',
+};
+
+const CoursesPage = async (params: any) => {
const orgslug = params.params.orgslug;
- const [newCourseModal, setNewCourseModal] = React.useState(false);
-
- const { data: courses, error: error } = useSWR(`${getAPIUrl()}courses/org_slug/${orgslug}/page/1/limit/10`, swrFetcher);
-
- async function deleteCourses(course_id: any) {
- await deleteCourseFromBackend(course_id);
- mutate(`${getAPIUrl()}courses/org_slug/${orgslug}/page/1/limit/10`);
- }
-
- async function closeNewCourseModal() {
- setNewCourseModal(false);
- }
-
- // function to remove "course_" from the course_id
- function removeCoursePrefix(course_id: string) {
- return course_id.replace("course_", "");
- }
+ const courses = await getOrgCourses(orgslug);
return (
- <>
-
- Courses {" "}
- }
- dialogTitle="Create Course"
- dialogDescription="Create a new course"
- dialogTrigger={
-
- }
- />
-
- {error && Failed to load
}
- {!courses ? (
- Loading...
- ) : (
-
- {courses.map((course: any) => (
-
-
-
-
-
-
-
-
-
-
-
-
-
{course.name}
-
- ))}
-
- )}
- >
+
+
+
);
};
-export default CoursesIndexPage;
+export default CoursesPage;
-const CourseThumbnail = styled.div`
- display: flex;
-
- img {
- width: 249px;
- height: 131px;
-
- }
-`;
-
-const CourseWrapper = styled.div`
- margin: 0 auto;
- max-width: 1500px;
- div {
- h2 {
- margin: 0;
- padding: 0;
- margin-top: 10px;
- font-size: 18px;
- font-weight: 600;
- width: 250px;
- height: 50px;
- color: #424242;
- }
- }
-`;
diff --git a/front/app/_orgs/[orgslug]/page.tsx b/front/app/_orgs/[orgslug]/(withmenu)/page.tsx
similarity index 96%
rename from front/app/_orgs/[orgslug]/page.tsx
rename to front/app/_orgs/[orgslug]/(withmenu)/page.tsx
index 2c1a6c0a..9250bdd7 100644
--- a/front/app/_orgs/[orgslug]/page.tsx
+++ b/front/app/_orgs/[orgslug]/(withmenu)/page.tsx
@@ -23,9 +23,7 @@ const OrgHomePage = async (params: any) => {
return (
-
-
-
+
{/* Collections */}
@@ -68,7 +66,7 @@ const OrgHomePage = async (params: any) => {
};
-const Title = (props: any) => {
+export const Title = (props: any) => {
return (