+ {response?.data?.length === 0 && (
+
+ No questions found
+
+ )}
{response?.data?.map((post) => (
{
+export const NewPostDialog = ({ contentId }: { contentId: number | null }) => {
const { theme } = useTheme();
const formRef = useRef>(null);
const searchParam = useSearchParams();
@@ -86,6 +86,7 @@ export const NewPostDialog = () => {
execute({
title: title?.toString() || '',
content: value,
+ contentId,
tags: (tags?.toString() || '').split(','),
});
};
diff --git a/src/components/admin/ContentRendererClient.tsx b/src/components/admin/ContentRendererClient.tsx
index 46344a3f7..8378c005c 100644
--- a/src/components/admin/ContentRendererClient.tsx
+++ b/src/components/admin/ContentRendererClient.tsx
@@ -148,6 +148,12 @@ export const ContentRendererClient = ({
Slides
+
+ Q & A
+
) : null}
{!showChapters && metadata.segments?.length > 0 && (
From d87556677e14725643f380dc7425510672b933fc Mon Sep 17 00:00:00 2001
From: iamnithishraja <153272518+iamnithishraja@users.noreply.github.com>
Date: Mon, 13 May 2024 02:53:54 +0530
Subject: [PATCH 2/3] fixed linting issue
---
prisma/schema.prisma | 105 ++++++++++++++++++++++---------------------
1 file changed, 54 insertions(+), 51 deletions(-)
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index e28a36d28..d6195424e 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -21,7 +21,7 @@ model Course {
purchasedBy UserPurchases[]
bookmarks Bookmark[]
certificate Certificate[]
- certIssued Boolean @default(false)
+ certIssued Boolean @default(false)
}
model UserPurchases {
@@ -53,6 +53,7 @@ model Content {
comments Comment[]
commentsCount Int @default(0)
bookmark Bookmark?
+ Question Question[]
}
model CourseContent {
@@ -65,11 +66,11 @@ model CourseContent {
}
model Certificate {
- id String @id @default(cuid())
- user User @relation(fields: [userId], references: [id])
- userId String
- course Course @relation(fields: [courseId], references: [id])
- courseId Int
+ id String @id @default(cuid())
+ user User @relation(fields: [userId], references: [id])
+ userId String
+ course Course @relation(fields: [courseId], references: [id])
+ courseId Int
@@unique([userId, courseId])
}
@@ -208,76 +209,78 @@ model Comment {
votes Vote[]
isPinned Boolean @default(false)
}
+
model Question {
- id Int @id @default(autoincrement())
- title String
- content String
- slug String @unique
- createdAt DateTime @default(now())
- author User @relation(fields: [authorId], references: [id])
- authorId String
- upvotes Int @default(0)
- downvotes Int @default(0)
+ id Int @id @default(autoincrement())
+ title String
+ content String
+ slug String @unique
+ createdAt DateTime @default(now())
+ author User @relation(fields: [authorId], references: [id])
+ authorId String
+ upvotes Int @default(0)
+ downvotes Int @default(0)
totalanswers Int @default(0)
- answers Answer[]
- votes Vote[]
- contentId Int?
- video Content? @relation(fields: [contentId], references: [id])
- tags String[]
- updatedAt DateTime @updatedAt
+ answers Answer[]
+ votes Vote[]
+ contentId Int?
+ video Content? @relation(fields: [contentId], references: [id])
+ tags String[]
+ updatedAt DateTime @updatedAt
@@index([authorId])
}
model Answer {
- id Int @id @default(autoincrement())
- content String
- createdAt DateTime @default(now())
- question Question @relation(fields: [questionId], references: [id])
- questionId Int
- author User @relation(fields: [authorId], references: [id])
- authorId String
- votes Vote[]
- upvotes Int @default(0)
- downvotes Int @default(0)
- totalanswers Int @default(0)
- parentId Int?
- responses Answer[] @relation("AnswerToAnswer")
- parent Answer? @relation("AnswerToAnswer", fields: [parentId], references: [id])
- updatedAt DateTime @updatedAt
+ id Int @id @default(autoincrement())
+ content String
+ createdAt DateTime @default(now())
+ question Question @relation(fields: [questionId], references: [id])
+ questionId Int
+ author User @relation(fields: [authorId], references: [id])
+ authorId String
+ votes Vote[]
+ upvotes Int @default(0)
+ downvotes Int @default(0)
+ totalanswers Int @default(0)
+ parentId Int?
+ responses Answer[] @relation("AnswerToAnswer")
+ parent Answer? @relation("AnswerToAnswer", fields: [parentId], references: [id])
+ updatedAt DateTime @updatedAt
@@index([questionId])
@@index([authorId])
@@index([parentId])
}
-
model Vote {
- id Int @id @default(autoincrement())
- questionId Int?
- question Question? @relation(fields: [questionId], references: [id])
- answerId Int?
- answer Answer? @relation(fields: [answerId], references: [id])
- commentId Int?
- comment Comment? @relation(fields: [commentId], references: [id])
- userId String
- user User @relation(fields: [userId], references: [id])
- voteType VoteType
- createdAt DateTime @default(now())
+ id Int @id @default(autoincrement())
+ questionId Int?
+ question Question? @relation(fields: [questionId], references: [id])
+ answerId Int?
+ answer Answer? @relation(fields: [answerId], references: [id])
+ commentId Int?
+ comment Comment? @relation(fields: [commentId], references: [id])
+ userId String
+ user User @relation(fields: [userId], references: [id])
+ voteType VoteType
+ createdAt DateTime @default(now())
- @@unique([questionId, userId])
- @@unique([answerId, userId])
- @@unique([commentId, userId])
+ @@unique([questionId, userId])
+ @@unique([answerId, userId])
+ @@unique([commentId, userId])
}
enum VoteType {
UPVOTE
DOWNVOTE
}
+
enum PostType {
QUESTION
ANSWER
}
+
enum CommentType {
INTRO
DEFAULT
From 78f2c79f582112462b3993f8bb8de2f0a7e24062 Mon Sep 17 00:00:00 2001
From: iamnithishraja <153272518+iamnithishraja@users.noreply.github.com>
Date: Mon, 13 May 2024 03:35:24 +0530
Subject: [PATCH 3/3] Update schema.prisma
---
prisma/schema.prisma | 98 ++++++++++++++++++++------------------------
1 file changed, 45 insertions(+), 53 deletions(-)
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index 846854f3b..125df7c42 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -20,7 +20,7 @@ model Course {
content CourseContent[]
purchasedBy UserPurchases[]
certificate Certificate[]
- certIssued Boolean @default(false)
+ certIssued Boolean @default(false)
}
model UserPurchases {
@@ -65,17 +65,13 @@ model CourseContent {
}
model Certificate {
- id String @id @default(cuid())
- user User @relation(fields: [userId], references: [id])
- userId String
- course Course @relation(fields: [courseId], references: [id])
- courseId Int
id String @id @default(cuid())
slug String @default("certId")
user User @relation(fields: [userId], references: [id])
userId String
course Course @relation(fields: [courseId], references: [id])
courseId Int
+
@@unique([userId, courseId])
}
@@ -189,8 +185,6 @@ model Bookmark {
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
content Content @relation(fields: [contentId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now())
- courseId Int
- course Course @relation(fields: [courseId], references: [id], onDelete: Cascade)
}
model Comment {
@@ -213,78 +207,76 @@ model Comment {
votes Vote[]
isPinned Boolean @default(false)
}
-
model Question {
- id Int @id @default(autoincrement())
- title String
- content String
- slug String @unique
- createdAt DateTime @default(now())
- author User @relation(fields: [authorId], references: [id])
- authorId String
- upvotes Int @default(0)
- downvotes Int @default(0)
+ id Int @id @default(autoincrement())
+ title String
+ content String
+ slug String @unique
+ createdAt DateTime @default(now())
+ author User @relation(fields: [authorId], references: [id])
+ authorId String
+ upvotes Int @default(0)
+ downvotes Int @default(0)
totalanswers Int @default(0)
- answers Answer[]
- votes Vote[]
+ answers Answer[]
+ votes Vote[]
+ tags String[]
contentId Int?
video Content? @relation(fields: [contentId], references: [id])
- tags String[]
- updatedAt DateTime @updatedAt
+ updatedAt DateTime @updatedAt
@@index([authorId])
}
model Answer {
- id Int @id @default(autoincrement())
- content String
- createdAt DateTime @default(now())
- question Question @relation(fields: [questionId], references: [id])
- questionId Int
- author User @relation(fields: [authorId], references: [id])
- authorId String
- votes Vote[]
- upvotes Int @default(0)
- downvotes Int @default(0)
- totalanswers Int @default(0)
- parentId Int?
- responses Answer[] @relation("AnswerToAnswer")
- parent Answer? @relation("AnswerToAnswer", fields: [parentId], references: [id])
- updatedAt DateTime @updatedAt
+ id Int @id @default(autoincrement())
+ content String
+ createdAt DateTime @default(now())
+ question Question @relation(fields: [questionId], references: [id])
+ questionId Int
+ author User @relation(fields: [authorId], references: [id])
+ authorId String
+ votes Vote[]
+ upvotes Int @default(0)
+ downvotes Int @default(0)
+ totalanswers Int @default(0)
+ parentId Int?
+ responses Answer[] @relation("AnswerToAnswer")
+ parent Answer? @relation("AnswerToAnswer", fields: [parentId], references: [id])
+ updatedAt DateTime @updatedAt
@@index([questionId])
@@index([authorId])
@@index([parentId])
}
+
model Vote {
- id Int @id @default(autoincrement())
- questionId Int?
- question Question? @relation(fields: [questionId], references: [id])
- answerId Int?
- answer Answer? @relation(fields: [answerId], references: [id])
- commentId Int?
- comment Comment? @relation(fields: [commentId], references: [id])
- userId String
- user User @relation(fields: [userId], references: [id])
- voteType VoteType
- createdAt DateTime @default(now())
+ id Int @id @default(autoincrement())
+ questionId Int?
+ question Question? @relation(fields: [questionId], references: [id])
+ answerId Int?
+ answer Answer? @relation(fields: [answerId], references: [id])
+ commentId Int?
+ comment Comment? @relation(fields: [commentId], references: [id])
+ userId String
+ user User @relation(fields: [userId], references: [id])
+ voteType VoteType
+ createdAt DateTime @default(now())
- @@unique([questionId, userId])
- @@unique([answerId, userId])
- @@unique([commentId, userId])
+ @@unique([questionId, userId])
+ @@unique([answerId, userId])
+ @@unique([commentId, userId])
}
enum VoteType {
UPVOTE
DOWNVOTE
}
-
enum PostType {
QUESTION
ANSWER
}
-
enum CommentType {
INTRO
DEFAULT