diff --git a/front/app/orgs/[orgslug]/(withmenu)/course/[courseid]/activity/[activityid]/activity.tsx b/front/app/orgs/[orgslug]/(withmenu)/course/[courseid]/activity/[activityid]/activity.tsx index 068cd078..1501d19f 100644 --- a/front/app/orgs/[orgslug]/(withmenu)/course/[courseid]/activity/[activityid]/activity.tsx +++ b/front/app/orgs/[orgslug]/(withmenu)/course/[courseid]/activity/[activityid]/activity.tsx @@ -1,16 +1,15 @@ "use client"; import Link from "next/link"; -import React, { useMemo } from "react"; +import React from "react"; import { getAPIUrl, getBackendUrl, getUriWithOrg } from "@services/config/config"; import Canva from "@components/Pages/Activities/DynamicCanva/DynamicCanva"; -import styled from "styled-components"; import VideoActivity from "@components/Pages/Activities/Video/Video"; -import useSWR, { mutate } from "swr"; import { Check } from "lucide-react"; import { markActivityAsComplete } from "@services/courses/activity"; -import ToolTip from "@components/StyledElements/Tooltip/Tooltip"; import DocumentPdfActivity from "@components/Pages/Activities/DocumentPdf/DocumentPdf"; import ActivityIndicators from "@components/Pages/Courses/ActivityIndicators"; +import GeneralWrapperStyled from "@components/StyledElements/Wrappers/GeneralWrapper"; +import { useRouter } from "next/navigation"; interface ActivityClientProps { activityid: string; @@ -20,6 +19,8 @@ interface ActivityClientProps { course: any; } + + function ActivityClient(props: ActivityClientProps) { const activityid = props.activityid; const courseid = props.courseid; @@ -27,149 +28,104 @@ function ActivityClient(props: ActivityClientProps) { const activity = props.activity; const course = props.course; - - async function markActivityAsCompleteFront() { - const trail = await markActivityAsComplete(orgslug, courseid, activityid); - mutate(`${getAPIUrl()}activities/activity_${activityid}`); - mutate(`${getAPIUrl()}courses/meta/course_${courseid}`); + function getChapterName(chapterId: string) { + let chapterName = ""; + course.chapters.forEach((chapter: any) => { + if (chapter.chapter_id === chapterId) { + chapterName = chapter.name; + } + }); + return chapterName; } + + + + return ( <> -
-
{JSON.stringify(activity, null, 2)}
- - - - - - - -

Course

-

{course.course.name}

-
-
- - - {activity ? ( -
- - {activity.type == "dynamic" && } - {/* todo : use apis & streams instead of this */} - {activity.type == "video" && } - - {activity.type == "documentpdf" && } - - - - {course.trail.activities_marked_complete && - course.trail.activities_marked_complete.includes("activity_" + activityid) && - course.trail.status == "ongoing" ? ( - - ) : ( - - )} - - + +
+
+
+ + + +
+
+

Course

+

{course.course.name}

+
- ) : (
)} - {
} -
+ + +
+
+

Chapter : {getChapterName(activity.chapter_id)}

+

{activity.name}

+
+
+ + +
+
+ + {activity ? ( +
+
+ {activity.type == "dynamic" && } + {/* todo : use apis & streams instead of this */} + {activity.type == "video" && } + + {activity.type == "documentpdf" && } + +
+ + +
+
+
+ ) : (
)} + {
} +
+ ); } -const ActivityThumbnail = styled.div` - padding-right: 30px; - justify-self: center; - img { - box-shadow: 0px 13px 33px -13px rgba(0, 0, 0, 0.42); - border-radius: 7px; - width: 100px; - height: 57px; - } -`; -const ActivityInfo = styled.div` - h1 { - margin-top: 0px; + +export function MarkStatus(props: { activityid: string, course: any, orgslug: string, courseid: string }) { + const router = useRouter(); + + + async function markActivityAsCompleteFront() { + const trail = await markActivityAsComplete(props.orgslug, props.courseid, props.activityid); + router.refresh(); } - p { - margin-top: 0; - margin-bottom: 0; - font-weight: 700; - } -`; + return ( + <>{props.course.trail.activities_marked_complete && + props.course.trail.activities_marked_complete.includes("activity_" + props.activityid) && + props.course.trail.status == "ongoing" ? ( +
+ + + {" "} + Already completed +
+ ) : ( +
+ {" "} + + + {" "} + Mark as complete +
+ )} + ) +} - -const ActivityTopWrapper = styled.div` - width: 1300px; - padding-top: 50px; - margin: 0 auto; - display: flex; -`; - -const CourseContent = styled.div` - display: flex; - flex-direction: column; - background-color: white; -`; - -const ActivityMarkerWrapper = styled.div` - display: block; - width: 1300px; - justify-content: flex-end; - margin: 0 auto; - align-items: center; - - button { - background-color: #151515; - border: none; - padding: 18px; - border-radius: 15px; - margin: 15px; - margin-left: 20px; - margin-top: 20px; - cursor: pointer; - transition: all 0.2s ease; - display: flex; - align-items: center; - justify-content: center; - margin: auto; - color: white; - font-weight: 700; - font-family: "DM Sans"; - font-size: 16px; - letter-spacing: -0.05em; - box-shadow: 0px 13px 33px -13px rgba(0, 0, 0, 0.42); - - i { - margin-right: 5px; - - // center the icon - display: flex; - align-items: center; - justify-content: center; - } - - &:hover { - background-color: #000000; - } - } -`; - export default ActivityClient; diff --git a/front/app/orgs/[orgslug]/(withmenu)/course/[courseid]/course.tsx b/front/app/orgs/[orgslug]/(withmenu)/course/[courseid]/course.tsx index 2e2580a4..fc323f5c 100644 --- a/front/app/orgs/[orgslug]/(withmenu)/course/[courseid]/course.tsx +++ b/front/app/orgs/[orgslug]/(withmenu)/course/[courseid]/course.tsx @@ -56,7 +56,7 @@ const CourseClient = (props: any) => { -
+

Description

diff --git a/front/components/Pages/Activities/DocumentPdf/DocumentPdf.tsx b/front/components/Pages/Activities/DocumentPdf/DocumentPdf.tsx index 4c907a5e..bdd1c56d 100644 --- a/front/components/Pages/Activities/DocumentPdf/DocumentPdf.tsx +++ b/front/components/Pages/Activities/DocumentPdf/DocumentPdf.tsx @@ -1,75 +1,18 @@ import { getBackendUrl } from "@services/config/config"; import React from "react"; -import styled from "styled-components"; function DocumentPdfActivity({ activity, course }: { activity: any; course: any }) { - function getChapterName() { - let chapterName = ""; - let chapterId = activity.chapter_id; - course.chapters.forEach((chapter: any) => { - if (chapter.chapter_id === chapterId) { - chapterName = chapter.name; - } - }); - return chapterName; - } - + return ( - - -

Chapter : {getChapterName()}

- {activity.name} -
- -