diff --git a/prisma/migrations/20230317171159_adds_possiblity_of_multiple_answers_to_one_card/migration.sql b/prisma/migrations/20230317171159_adds_possiblity_of_multiple_answers_to_one_card/migration.sql new file mode 100644 index 0000000..7189663 --- /dev/null +++ b/prisma/migrations/20230317171159_adds_possiblity_of_multiple_answers_to_one_card/migration.sql @@ -0,0 +1,9 @@ +/* + Warnings: + + - You are about to drop the column `answer` on the `Card` table. All the data in the column will be lost. + +*/ +-- AlterTable +ALTER TABLE "Card" DROP COLUMN "answer", +ADD COLUMN "validAnswers" TEXT[]; diff --git a/prisma/migrations/20230317201422_adds_answer_validation_report_model/migration.sql b/prisma/migrations/20230317201422_adds_answer_validation_report_model/migration.sql new file mode 100644 index 0000000..8496c51 --- /dev/null +++ b/prisma/migrations/20230317201422_adds_answer_validation_report_model/migration.sql @@ -0,0 +1,17 @@ +-- CreateTable +CREATE TABLE "AnswerValidationReport" ( + "id" TEXT NOT NULL, + "cardId" TEXT NOT NULL, + "userId" TEXT, + "answer" TEXT NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + + CONSTRAINT "AnswerValidationReport_pkey" PRIMARY KEY ("id") +); + +-- AddForeignKey +ALTER TABLE "AnswerValidationReport" ADD CONSTRAINT "AnswerValidationReport_cardId_fkey" FOREIGN KEY ("cardId") REFERENCES "Card"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "AnswerValidationReport" ADD CONSTRAINT "AnswerValidationReport_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE; diff --git a/prisma/migrations/20230318184925_adds_answer_validation_status_field/migration.sql b/prisma/migrations/20230318184925_adds_answer_validation_status_field/migration.sql new file mode 100644 index 0000000..4ddaceb --- /dev/null +++ b/prisma/migrations/20230318184925_adds_answer_validation_status_field/migration.sql @@ -0,0 +1,5 @@ +-- CreateEnum +CREATE TYPE "AnswerValidationReportStatus" AS ENUM ('Pending', 'Accepted', 'Rejected'); + +-- AlterTable +ALTER TABLE "AnswerValidationReport" ADD COLUMN "status" "AnswerValidationReportStatus" NOT NULL DEFAULT 'Pending'; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index da1da52..e03310a 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -34,18 +34,19 @@ model Session { } model User { - id String @id @default(cuid()) - name String? - email String? @unique - emailVerified DateTime? - image String? - accounts Account[] - sessions Session[] - decks Deck[] - studySessions StudySession[] - favorites Favorite[] - description String? - topics Topic[] + id String @id @default(cuid()) + name String? + email String? @unique + emailVerified DateTime? + image String? + accounts Account[] + sessions Session[] + decks Deck[] + studySessions StudySession[] + favorites Favorite[] + description String? + topics Topic[] + answerValidationReports AnswerValidationReport[] } model VerificationToken { @@ -62,6 +63,12 @@ enum Visibility { WithLink } +enum AnswerValidationReportStatus { + Pending + Accepted + Rejected +} + model Deck { id String @id @default(cuid()) title String @@ -88,15 +95,28 @@ model Topic { } model Card { - id String @id @default(cuid()) - question String - answer String - deckId String - deck Deck @relation(fields: [deckId], references: [id], onDelete: Cascade) - createdAt DateTime @default(now()) - updatedAt DateTime @default(now()) @updatedAt - studySessionBoxCards StudySessionBoxCard[] - isAiPowered Boolean @default(false) + id String @id @default(cuid()) + question String + validAnswers String[] + deckId String + deck Deck @relation(fields: [deckId], references: [id], onDelete: Cascade) + createdAt DateTime @default(now()) + updatedAt DateTime @default(now()) @updatedAt + studySessionBoxCards StudySessionBoxCard[] + isAiPowered Boolean @default(false) + answerValidationReports AnswerValidationReport[] +} + +model AnswerValidationReport { + id String @id @default(cuid()) + cardId String + card Card @relation(fields: [cardId], references: [id], onDelete: Cascade) + userId String? + user User? @relation(fields: [userId], references: [id], onDelete: SetNull) + answer String + createdAt DateTime @default(now()) + updatedAt DateTime @default(now()) @updatedAt + status AnswerValidationReportStatus @default(Pending) } model StudySession { diff --git a/src/components/modal/index.ts b/src/components/modal/index.ts index a71686b..8bc91ae 100644 --- a/src/components/modal/index.ts +++ b/src/components/modal/index.ts @@ -1,9 +1,11 @@ import { BaseModal } from './base/base-modal.component' import { NewCardModal } from './new-card/new-card-modal.component' import { NewTopicModal } from './new-topic/new-topic-modal.component' +import { ReportAnswerValidationModal } from './report-answer-validation/report-answer-validation.component' export const Modal = { Base: BaseModal, NewTopic: NewTopicModal, NewCard: NewCardModal, + ReportAnswerValidation: ReportAnswerValidationModal, } diff --git a/src/components/modal/new-card/new-card-modal.component.tsx b/src/components/modal/new-card/new-card-modal.component.tsx index fa0a82d..e5a137a 100644 --- a/src/components/modal/new-card/new-card-modal.component.tsx +++ b/src/components/modal/new-card/new-card-modal.component.tsx @@ -52,8 +52,9 @@ export function NewCardModal(props: NewCardModalProps) {