Skip to content

Commit 0449d1f

Browse files
committed
Updated prisma schema.
1 parent 41982de commit 0449d1f

File tree

3 files changed

+56
-2
lines changed

3 files changed

+56
-2
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
}

app/(course)/courses/[courseId]/layout.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { auth } from "@clerk/nextjs/server";
22
import { redirect } from "next/navigation";
33

44
import { db } from "@/lib/db";
5+
import { getProgress } from "@/actions/get-progress";
6+
import { CourseSidebar } from "./_components/course-sidebar";
57

68
const CourseLayout = async ({
79
children,
@@ -39,9 +41,23 @@ const CourseLayout = async ({
3941
},
4042
});
4143

44+
if (!course) {
45+
return redirect("/");
46+
}
47+
48+
const progressCount = await getProgress(userId, course.id);
49+
4250
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>
4561
</div>
4662
)
4763
}

prisma/schema.prisma

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ model Purchase {
113113
updatedAt DateTime @updatedAt
114114
115115
@@index([courseId])
116+
@@unique([userId, courseId])
116117
}
117118

118119
model StripeCustomer {

0 commit comments

Comments
 (0)