File tree Expand file tree Collapse file tree 3 files changed +56
-2
lines changed
app/(course)/courses/[courseId] Expand file tree Collapse file tree 3 files changed +56
-2
lines changed Original file line number Diff line number Diff line change
1
+ import { auth } from "@clerk/nextjs/server" ;
2
+ import { Chapter , Course , UserProgress } from "@prisma/client"
3
+ import { redirect } from "next/navigation" ;
4
+
5
+ import { db } from "@/lib/db" ;
6
+
7
+ interface CourseSidebarProps {
8
+ course : Course & {
9
+ chapters : ( Chapter & {
10
+ userProgress : UserProgress [ ] | null ,
11
+ } ) [ ]
12
+ } ;
13
+ progressCount : number ;
14
+ }
15
+
16
+ export const CourseSidebar = async ( {
17
+ course,
18
+ progressCount,
19
+ } : CourseSidebarProps ) => {
20
+ const userId = auth ( ) ;
21
+
22
+ if ( ! userId ) {
23
+ return redirect ( "/" ) ;
24
+ }
25
+
26
+ const purchase = await db . purchase . findUnique ( {
27
+ where : {
28
+
29
+ }
30
+ } )
31
+
32
+ return (
33
+ < div >
34
+ Course sidebar
35
+ </ div >
36
+ )
37
+ }
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ import { auth } from "@clerk/nextjs/server";
2
2
import { redirect } from "next/navigation" ;
3
3
4
4
import { db } from "@/lib/db" ;
5
+ import { getProgress } from "@/actions/get-progress" ;
6
+ import { CourseSidebar } from "./_components/course-sidebar" ;
5
7
6
8
const CourseLayout = async ( {
7
9
children,
@@ -39,9 +41,23 @@ const CourseLayout = async ({
39
41
} ,
40
42
} ) ;
41
43
44
+ if ( ! course ) {
45
+ return redirect ( "/" ) ;
46
+ }
47
+
48
+ const progressCount = await getProgress ( userId , course . id ) ;
49
+
42
50
return (
43
- < div >
44
- { children }
51
+ < div className = "h-full" >
52
+ < div className = "hidden md:flex h-full w-80 flex-col fixed inset-y-0 z-50" >
53
+ < CourseSidebar
54
+ course = { course }
55
+ progressCount = { progressCount }
56
+ />
57
+ </ div >
58
+ < main className = "md:pl-80 h-full" >
59
+ { children }
60
+ </ main >
45
61
</ div >
46
62
)
47
63
}
Original file line number Diff line number Diff line change @@ -113,6 +113,7 @@ model Purchase {
113
113
updatedAt DateTime @updatedAt
114
114
115
115
@@index ([courseId ] )
116
+ @@unique ([userId , courseId ] )
116
117
}
117
118
118
119
model StripeCustomer {
You can’t perform that action at this time.
0 commit comments