From be7b1ee5b5c539f77a7607557999ead67b2beaae Mon Sep 17 00:00:00 2001 From: swve Date: Thu, 12 Oct 2023 20:03:06 +0200 Subject: [PATCH 1/4] feat: redesign some parts of course page --- .../(withmenu)/course/[courseid]/course.tsx | 99 +++++++++++++++---- 1 file changed, 78 insertions(+), 21 deletions(-) diff --git a/front/app/orgs/[orgslug]/(withmenu)/course/[courseid]/course.tsx b/front/app/orgs/[orgslug]/(withmenu)/course/[courseid]/course.tsx index a39c6865..dcd32aac 100644 --- a/front/app/orgs/[orgslug]/(withmenu)/course/[courseid]/course.tsx +++ b/front/app/orgs/[orgslug]/(withmenu)/course/[courseid]/course.tsx @@ -1,18 +1,15 @@ "use client"; -import { EyeOpenIcon, Pencil2Icon } from "@radix-ui/react-icons"; import { removeCourse, startCourse } from "@services/courses/activity"; import Link from "next/link"; import React, { use } from "react"; -import styled from "styled-components"; -import { getAPIUrl, getBackendUrl, getUriWithOrg } from "@services/config/config"; -import useSWR, { mutate } from "swr"; -import ToolTip from "@components/StyledElements/Tooltip/Tooltip"; +import { getUriWithOrg } from "@services/config/config"; import PageLoading from "@components/Objects/Loaders/PageLoading"; import { revalidateTags } from "@services/utils/ts/requests"; import ActivityIndicators from "@components/Pages/Courses/ActivityIndicators"; import { useRouter } from "next/navigation"; import GeneralWrapperStyled from "@components/StyledElements/Wrappers/GeneralWrapper"; import { getCourseThumbnailMediaDirectory } from "@services/media/media"; +import { ArrowRight, File, Sparkles, Star, Video } from "lucide-react"; const CourseClient = (props: any) => { const courseid = props.courseid; @@ -36,9 +33,6 @@ const CourseClient = (props: any) => { // Mutate course await revalidateTags(['courses'], orgslug); router.refresh(); - - // refresh page (FIX for Next.js BUG) - //window.location.reload(); } @@ -57,7 +51,6 @@ const CourseClient = (props: any) => {
-
@@ -70,38 +63,102 @@ const CourseClient = (props: any) => {

What you will learn

- - -

{course.learnings == ![] ? "no data" : course.learnings}

-
+
+ {course.course.learnings.map((learning: any) => { + return ( +
+
+ +
+

{learning}

+
+ ); + } + )} +

Course Lessons

- +
{course.chapters.map((chapter: any) => { return (
-

{chapter.name}

+
+

{chapter.name}

+

+ {chapter.activities.length} Activities +

+
{chapter.activities.map((activity: any) => { return ( <>

- {activity.name} - - - {" "} +

+
+
+ {activity.type === "dynamic" && +
+ +
+ } + {activity.type === "video" && +
+
+ } + {activity.type === "documentpdf" && +
+ +
+ } + +
+ +

{activity.name}

+ +
+ {activity.type === "dynamic" && + <> + +
+

Page

+
+ + + } + {activity.type === "video" && + <> + +
+

Video

+
+ + + } + {activity.type === "documentpdf" && + <> + +
+

Document

+
+ + + } +
+
); })}
); })} - +
From ee9dbbc22e81c6188359b51dd0cb5e62744b6626 Mon Sep 17 00:00:00 2001 From: swve Date: Thu, 12 Oct 2023 20:28:53 +0200 Subject: [PATCH 2/4] feat: little headerprofile changes --- front/components/Security/HeaderProfileBox.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/front/components/Security/HeaderProfileBox.tsx b/front/components/Security/HeaderProfileBox.tsx index 441f72ca..7dd781bb 100644 --- a/front/components/Security/HeaderProfileBox.tsx +++ b/front/components/Security/HeaderProfileBox.tsx @@ -28,13 +28,13 @@ export const HeaderProfileBox = () => { )} {auth.isAuthenticated && ( - -
{auth.userInfo.user_object.full_name}
+ +
{auth.userInfo.user_object.full_name}
- +
)} From 3cfa49cccd8fdebe571a308219d69110a45f86ef Mon Sep 17 00:00:00 2001 From: swve Date: Fri, 13 Oct 2023 17:57:17 +0200 Subject: [PATCH 3/4] feat: minor css change --- .../orgs/[orgslug]/(withmenu)/course/[courseid]/course.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/front/app/orgs/[orgslug]/(withmenu)/course/[courseid]/course.tsx b/front/app/orgs/[orgslug]/(withmenu)/course/[courseid]/course.tsx index dcd32aac..3aa08cec 100644 --- a/front/app/orgs/[orgslug]/(withmenu)/course/[courseid]/course.tsx +++ b/front/app/orgs/[orgslug]/(withmenu)/course/[courseid]/course.tsx @@ -9,7 +9,7 @@ import ActivityIndicators from "@components/Pages/Courses/ActivityIndicators"; import { useRouter } from "next/navigation"; import GeneralWrapperStyled from "@components/StyledElements/Wrappers/GeneralWrapper"; import { getCourseThumbnailMediaDirectory } from "@services/media/media"; -import { ArrowRight, File, Sparkles, Star, Video } from "lucide-react"; +import { ArrowRight, Check, File, Sparkles, Star, Video } from "lucide-react"; const CourseClient = (props: any) => { const courseid = props.courseid; @@ -68,8 +68,8 @@ const CourseClient = (props: any) => { return (
-
- +
+

{learning}

From 18f54ce7b1e67617f993fe558f96b2638401569f Mon Sep 17 00:00:00 2001 From: swve Date: Fri, 13 Oct 2023 18:37:37 +0200 Subject: [PATCH 4/4] feat: add course author to course page --- .../(withmenu)/course/[courseid]/course.tsx | 46 +++++++++++++++---- front/services/users/users.ts | 8 ++++ 2 files changed, 45 insertions(+), 9 deletions(-) create mode 100644 front/services/users/users.ts diff --git a/front/app/orgs/[orgslug]/(withmenu)/course/[courseid]/course.tsx b/front/app/orgs/[orgslug]/(withmenu)/course/[courseid]/course.tsx index 3aa08cec..f4ceb215 100644 --- a/front/app/orgs/[orgslug]/(withmenu)/course/[courseid]/course.tsx +++ b/front/app/orgs/[orgslug]/(withmenu)/course/[courseid]/course.tsx @@ -1,7 +1,7 @@ "use client"; import { removeCourse, startCourse } from "@services/courses/activity"; import Link from "next/link"; -import React, { use } from "react"; +import React, { use, useEffect, useState } from "react"; import { getUriWithOrg } from "@services/config/config"; import PageLoading from "@components/Objects/Loaders/PageLoading"; import { revalidateTags } from "@services/utils/ts/requests"; @@ -10,13 +10,25 @@ import { useRouter } from "next/navigation"; import GeneralWrapperStyled from "@components/StyledElements/Wrappers/GeneralWrapper"; import { getCourseThumbnailMediaDirectory } from "@services/media/media"; import { ArrowRight, Check, File, Sparkles, Star, Video } from "lucide-react"; +import Avvvatars from "avvvatars-react"; +import { getUser } from "@services/users/users"; const CourseClient = (props: any) => { + const [user, setUser] = useState({}); const courseid = props.courseid; const orgslug = props.orgslug; const course = props.course; const router = useRouter(); + + + async function getUserUI() { + let user_id = course.course.authors[0]; + const user = await getUser(user_id); + setUser(user); + console.log(user); + } + async function startCourseUI() { // Create activity await startCourse("course_" + courseid, orgslug); @@ -35,6 +47,10 @@ const CourseClient = (props: any) => { router.refresh(); } + useEffect(() => { + getUserUI(); + } + , []); return ( <> @@ -58,9 +74,9 @@ const CourseClient = (props: any) => {

Description

- -

{course.course.description}

-
+
+

{course.course.description}

+

What you will learn

@@ -101,7 +117,7 @@ const CourseClient = (props: any) => {

-
+
{activity.type === "dynamic" &&
@@ -119,7 +135,7 @@ const CourseClient = (props: any) => { }
- +

{activity.name}

@@ -161,13 +177,25 @@ const CourseClient = (props: any) => {
-
+
+ { user && +
+
+ +
+
+
Author
+
{user.full_name}
+
+
+ } + {course.trail.status == "ongoing" ? ( - ) : ( - + )}
diff --git a/front/services/users/users.ts b/front/services/users/users.ts new file mode 100644 index 00000000..798079ab --- /dev/null +++ b/front/services/users/users.ts @@ -0,0 +1,8 @@ +import { getAPIUrl } from "@services/config/config"; +import { RequestBody, errorHandling } from "@services/utils/ts/requests"; + +export async function getUser(user_id: string) { + const result = await fetch(`${getAPIUrl()}users/user_id/${user_id}`, RequestBody("GET", null, null)); + const res = await errorHandling(result); + return res; +} \ No newline at end of file