From e4c45afcb79c26a8b69ec578913f78ac068b8dad Mon Sep 17 00:00:00 2001 From: yntymakdev Date: Wed, 26 Feb 2025 11:32:49 +0600 Subject: [PATCH 1/5] customize and fixed bug on layout tsx to course ,CourseId --- prisma/schema.prisma | 182 +++++++++--------- .../(course)/courses/[courseId]/layout.tsx | 3 +- 2 files changed, 92 insertions(+), 93 deletions(-) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 93b19fc..e1cba93 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -1,104 +1,104 @@ - generator client { - provider = "prisma-client-js" - previewFeatures = ["fullTextSearchPostgres", "fullTextIndex"] - } + generator client { + provider = "prisma-client-js" + previewFeatures = ["fullTextSearchPostgres", "fullTextIndex"] + } - datasource db { - provider = "postgresql" - url = env("DATABASE_URL") - } + datasource db { + provider = "postgresql" + url = env("DATABASE_URL") + } - model Course { - id String @id @default(cuid()) - userId String - title String? @db.Text - description String? @db.Text - imageUrl String? @db.Text - price Float? - isPublished Boolean @default(false) - categoryId String? - attachments Attachment[] - createdAt DateTime @default(now()) - updateAt DateTime @updatedAt - category Category? @relation(fields: [categoryId], references: [id]) - chapters Chapter[] - purchase Purchase[] - @@index([categoryId]) - } + model Course { + id String @id @default(cuid()) + userId String + title String? @db.Text + description String? @db.Text + imageUrl String? @db.Text + price Float? + isPublished Boolean @default(false) + categoryId String? + attachments Attachment[] + createdAt DateTime @default(now()) + updateAt DateTime @updatedAt + category Category? @relation(fields: [categoryId], references: [id]) + chapters Chapter[] + purchase Purchase[] + @@index([categoryId]) + } - model Category { - id String @id @default(cuid()) - name String @unique - course Course[] - } + model Category { + id String @id @default(cuid()) + name String @unique + course Course[] + } - model Attachment { - id String @id @default(cuid()) - name String - url String @db.Text - Course Course? @relation(fields: [courseId], references: [id]) - courseId String? - createdAt DateTime @default(now()) - updateAt DateTime @updatedAt + model Attachment { + id String @id @default(cuid()) + name String + url String @db.Text + Course Course? @relation(fields: [courseId], references: [id]) + courseId String? + createdAt DateTime @default(now()) + updateAt DateTime @updatedAt - @@index([courseId]) - @@map("attachments") - } + @@index([courseId]) + @@map("attachments") + } - model Chapter { - id String @id @default(cuid()) - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - title String - position Int - description String? @db.Text - videoUrl String? @db.Text - isPublished Boolean? - isFree Boolean @default(false) - muxData MuxData? - courseId String - course Course @relation(fields: [courseId], references: [id], onDelete: Cascade) - userPostgress UserProgress[] + model Chapter { + id String @id @default(cuid()) + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + title String + position Int + description String? @db.Text + videoUrl String? @db.Text + isPublished Boolean? + isFree Boolean @default(false) + muxData MuxData? + courseId String + course Course @relation(fields: [courseId], references: [id], onDelete: Cascade) + userProgress UserProgress[] - @@index([courseId]) - } + @@index([courseId]) + } - model MuxData { - id String @id @default(cuid()) - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - assetId String - playbackId String? - chapterId String @unique - chapter Chapter @relation(fields: [chapterId], references: [id], onDelete: Cascade) - } + model MuxData { + id String @id @default(cuid()) + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + assetId String + playbackId String? + chapterId String @unique + chapter Chapter @relation(fields: [chapterId], references: [id], onDelete: Cascade) + } - model UserProgress { - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - id String @id @default(cuid()) - isCompleted Boolean @default(false) - chapter Chapter @relation(fields: [chapterId], references: [id], onDelete: Cascade) - chapterId String - userId String + model UserProgress { + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + id String @id @default(cuid()) + isCompleted Boolean @default(false) + chapter Chapter @relation(fields: [chapterId], references: [id], onDelete: Cascade) + chapterId String + userId String - @@unique([userId, chapterId]) - @@index([chapterId]) - } + @@unique([userId, chapterId]) + @@index([chapterId]) + } - model Purchase { - id String @id @default(cuid()) - userId String - courseId String - Course Course @relation(fields: [courseId], references: [id]) + model Purchase { + id String @id @default(cuid()) + userId String + courseId String + Course Course @relation(fields: [courseId], references: [id]) - @@index([courseId]) - } + @@index([courseId]) + } - model StripeCustomer { - id String @id @default(cuid()) - userId String @unique - stripeCustomer String @unique - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - } + model StripeCustomer { + id String @id @default(cuid()) + userId String @unique + stripeCustomer String @unique + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + } diff --git a/src/app/(course)/courses/[courseId]/layout.tsx b/src/app/(course)/courses/[courseId]/layout.tsx index 9cdfc1e..4877159 100644 --- a/src/app/(course)/courses/[courseId]/layout.tsx +++ b/src/app/(course)/courses/[courseId]/layout.tsx @@ -3,13 +3,12 @@ import { auth } from "@clerk/nextjs/server"; import { redirect } from "next/navigation"; import React from "react"; import { getProgress } from "../../../../../actions/getProgress"; -import CourseSideBar from "@/components/CourseSideBar"; const CourseLayout = async ({ children, params }: { children: React.ReactNode; params: { courseId: string } }) => { const { userId } = await auth(); if (!userId) { redirect("/"); - return null; // Чтобы избежать ошибки, так как redirect не возвращает JSX + return null; } const course = await db.course.findUnique({ From 5de0e13bc2acc902fe5f42a65c14ef126094b718 Mon Sep 17 00:00:00 2001 From: yntymakdev Date: Wed, 26 Feb 2025 11:50:52 +0600 Subject: [PATCH 2/5] customize and fixed bug on layout tsx to course ,CourseId --- src/app/(course)/courses/[courseId]/layout.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/(course)/courses/[courseId]/layout.tsx b/src/app/(course)/courses/[courseId]/layout.tsx index 4877159..451c439 100644 --- a/src/app/(course)/courses/[courseId]/layout.tsx +++ b/src/app/(course)/courses/[courseId]/layout.tsx @@ -3,6 +3,7 @@ import { auth } from "@clerk/nextjs/server"; import { redirect } from "next/navigation"; import React from "react"; import { getProgress } from "../../../../../actions/getProgress"; +import CourseSideBar from "./components/CourseSideBar"; const CourseLayout = async ({ children, params }: { children: React.ReactNode; params: { courseId: string } }) => { const { userId } = await auth(); @@ -28,7 +29,6 @@ const CourseLayout = async ({ children, params }: { children: React.ReactNode; p if (!course) { redirect("/"); - return null; } const progressCount = await getProgress(userId, course.id); @@ -36,7 +36,7 @@ const CourseLayout = async ({ children, params }: { children: React.ReactNode; p return (
- +
{children}
From d0c404fb789c53905f912465b306f2976a2e6780 Mon Sep 17 00:00:00 2001 From: yntymakdev Date: Wed, 26 Feb 2025 11:55:14 +0600 Subject: [PATCH 3/5] customize and fixed bug on layout tsx to course ,CourseId --- src/app/(course)/courses/[courseId]/layout.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/(course)/courses/[courseId]/layout.tsx b/src/app/(course)/courses/[courseId]/layout.tsx index 451c439..ea2f038 100644 --- a/src/app/(course)/courses/[courseId]/layout.tsx +++ b/src/app/(course)/courses/[courseId]/layout.tsx @@ -9,7 +9,6 @@ const CourseLayout = async ({ children, params }: { children: React.ReactNode; p const { userId } = await auth(); if (!userId) { redirect("/"); - return null; } const course = await db.course.findUnique({ From 6cbead5534ca84e73603563506f0bef9d443a3a8 Mon Sep 17 00:00:00 2001 From: YNTY <144984605+yntymakdev@users.noreply.github.com> Date: Mon, 5 May 2025 01:38:16 +0600 Subject: [PATCH 4/5] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=20=D0=94=D0=B8=D0=B0=D0=B3=D1=80=D0=B0=D0=BC=D0=BC?= =?UTF-8?q?=D0=B0=20=D0=B1=D0=B5=D0=B7=20=D0=BD=D0=B0=D0=B7=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F.drawio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...62\320\260\320\275\320\270\321\217.drawio" | 196 ++++++++++++++++++ 1 file changed, 196 insertions(+) create mode 100644 "actions/\320\224\320\270\320\260\320\263\321\200\320\260\320\274\320\274\320\260 \320\261\320\265\320\267 \320\275\320\260\320\267\320\262\320\260\320\275\320\270\321\217.drawio" diff --git "a/actions/\320\224\320\270\320\260\320\263\321\200\320\260\320\274\320\274\320\260 \320\261\320\265\320\267 \320\275\320\260\320\267\320\262\320\260\320\275\320\270\321\217.drawio" "b/actions/\320\224\320\270\320\260\320\263\321\200\320\260\320\274\320\274\320\260 \320\261\320\265\320\267 \320\275\320\260\320\267\320\262\320\260\320\275\320\270\321\217.drawio" new file mode 100644 index 0000000..b1872d0 --- /dev/null +++ "b/actions/\320\224\320\270\320\260\320\263\321\200\320\260\320\274\320\274\320\260 \320\261\320\265\320\267 \320\275\320\260\320\267\320\262\320\260\320\275\320\270\321\217.drawio" @@ -0,0 +1,196 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 4fc5856945e2daf604668673142ab8b5ed1c5c7b Mon Sep 17 00:00:00 2001 From: YNTY <144984605+yntymakdev@users.noreply.github.com> Date: Mon, 5 May 2025 01:39:12 +0600 Subject: [PATCH 5/5] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=94=D0=B8=D0=B0=D0=B3=D1=80=D0=B0=D0=BC?= =?UTF-8?q?=D0=BC=D0=B0=20=D0=B1=D0=B5=D0=B7=20=D0=BD=D0=B0=D0=B7=D0=B2?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D1=8F.drawio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\320\262\320\260\320\275\320\270\321\217.drawio" | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git "a/actions/\320\224\320\270\320\260\320\263\321\200\320\260\320\274\320\274\320\260 \320\261\320\265\320\267 \320\275\320\260\320\267\320\262\320\260\320\275\320\270\321\217.drawio" "b/actions/\320\224\320\270\320\260\320\263\321\200\320\260\320\274\320\274\320\260 \320\261\320\265\320\267 \320\275\320\260\320\267\320\262\320\260\320\275\320\270\321\217.drawio" index b1872d0..8e5970a 100644 --- "a/actions/\320\224\320\270\320\260\320\263\321\200\320\260\320\274\320\274\320\260 \320\261\320\265\320\267 \320\275\320\260\320\267\320\262\320\260\320\275\320\270\321\217.drawio" +++ "b/actions/\320\224\320\270\320\260\320\263\321\200\320\260\320\274\320\274\320\260 \320\261\320\265\320\267 \320\275\320\260\320\267\320\262\320\260\320\275\320\270\321\217.drawio" @@ -1,6 +1,6 @@ - + @@ -104,11 +104,20 @@ - + + + + + + + + + +