-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathCourseView.tsx
More file actions
107 lines (104 loc) · 3.41 KB
/
CourseView.tsx
File metadata and controls
107 lines (104 loc) · 3.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import { ChildCourseContent, FullCourseContent } from '@/db/course';
import { ContentRenderer } from './admin/ContentRenderer';
import { FolderView } from './FolderView';
import { NotionRenderer } from './NotionRenderer';
import { getFolderPercentCompleted } from '@/lib/utils';
import { QueryParams } from '@/actions/types';
import BreadCrumbComponent from './BreadCrumbComponent';
import Comments from './comment/Comments';
// import { Sidebar } from './Sidebar';
export const CourseView = ({
rest,
course,
fullCourseContent,
courseContent,
nextContent,
searchParams,
possiblePath,
}: {
fullCourseContent: FullCourseContent[];
rest: string[];
course: any;
courseContent:
| {
folder: true;
value: ChildCourseContent[];
}
| {
folder: false;
value: ChildCourseContent;
}
| null;
nextContent: any;
searchParams: QueryParams;
possiblePath: string;
}) => {
const contentType = courseContent?.folder
? 'folder'
: courseContent?.value.type;
return (
<div className="relative flex w-full flex-col gap-8 pb-16 pt-8 xl:pt-[9px]">
<div className="sticky top-[73px] z-20 flex flex-col gap-4 bg-background py-2 xl:pt-2">
<BreadCrumbComponent
course={course}
contentType={contentType}
courseContent={courseContent}
fullCourseContent={fullCourseContent}
rest={rest}
/>
</div>
{!courseContent?.folder && courseContent?.value.type === 'notion' ? (
<NotionRenderer
id={courseContent?.value?.id?.toString()}
courseId={courseContent.value.id}
/>
) : null}
{!courseContent?.folder && (contentType === 'video' || contentType === 'appx') ? (
<ContentRenderer
nextContent={nextContent}
content={{
thumbnail: courseContent?.value?.thumbnail || '',
id: courseContent?.value.id || 0,
title: courseContent?.value?.title || '',
type: contentType || 'video',
description: courseContent?.value?.description || '',
markAsCompleted:
courseContent?.value?.videoProgress?.markAsCompleted || false,
bookmark: courseContent?.value.bookmark || null,
courseId: course.id,
}}
/>
) : null}
{!courseContent?.folder &&
(contentType === 'video' || contentType === 'notion') && (
<Comments
content={{
id: courseContent?.value?.id || 0,
courseId: parseInt(course.id, 10) || 0,
//@ts-ignore
commentCount: courseContent?.value.commentsCount || 0,
possiblePath,
}}
searchParams={searchParams}
/>
)}
{courseContent?.folder ? (
<FolderView
rest={rest}
courseContent={courseContent?.value.map((x: any) => ({
title: x?.title || '',
image: x?.thumbnail || '',
type: x?.type || 'folder',
id: x?.id || 0,
markAsCompleted: x?.videoProgress?.markAsCompleted || false,
percentComplete: getFolderPercentCompleted(x?.children),
videoFullDuration: x?.videoProgress?.videoFullDuration || 0,
duration: x?.videoProgress?.duration || 0,
bookmark: x.bookmark || null,
}))}
courseId={parseInt(course.id, 10)}
/>
) : null}
</div>
);
};