Skip to content

Commit

Permalink
chore: πŸ”– releases new app version
Browse files Browse the repository at this point in the history
  • Loading branch information
emiliosheinz authored Jan 22, 2023
2 parents 1543184 + c7e9a4e commit 0a0e7c4
Show file tree
Hide file tree
Showing 31 changed files with 999 additions and 228 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- CreateTable
CREATE TABLE "StudySession" (
"userId" TEXT NOT NULL,
"deckId" TEXT NOT NULL,

CONSTRAINT "StudySession_pkey" PRIMARY KEY ("userId","deckId")
);

-- CreateIndex
CREATE UNIQUE INDEX "StudySession_userId_deckId_key" ON "StudySession"("userId", "deckId");

-- AddForeignKey
ALTER TABLE "StudySession" ADD CONSTRAINT "StudySession_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "StudySession" ADD CONSTRAINT "StudySession_deckId_fkey" FOREIGN KEY ("deckId") REFERENCES "Deck"("id") ON DELETE CASCADE ON UPDATE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
Warnings:
- The primary key for the `StudySession` table will be changed. If it partially fails, the table could be left without primary key constraint.
- The required column `id` was added to the `StudySession` table with a prisma-level default value. This is not possible if the table is not empty. Please add this column as optional, then populate it before making it required.
*/
-- AlterTable
ALTER TABLE "StudySession" DROP CONSTRAINT "StudySession_pkey",
ADD COLUMN "id" TEXT NOT NULL,
ADD CONSTRAINT "StudySession_pkey" PRIMARY KEY ("id");

-- CreateTable
CREATE TABLE "StudySessionBox" (
"id" TEXT NOT NULL,
"studySessionId" TEXT NOT NULL,
"lastReview" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"reviewGapInHours" INTEGER NOT NULL,

CONSTRAINT "StudySessionBox_pkey" PRIMARY KEY ("id")
);

-- AddForeignKey
ALTER TABLE "StudySessionBox" ADD CONSTRAINT "StudySessionBox_studySessionId_fkey" FOREIGN KEY ("studySessionId") REFERENCES "StudySession"("id") ON DELETE CASCADE ON UPDATE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
-- AlterTable
ALTER TABLE "Card" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;

-- AlterTable
ALTER TABLE "StudySession" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;

-- AlterTable
ALTER TABLE "StudySessionBox" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;

-- AlterTable
ALTER TABLE "Topic" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;

-- CreateTable
CREATE TABLE "StudySessionAttempt" (
"id" TEXT NOT NULL,
"answer" TEXT NOT NULL,
"isRight" BOOLEAN NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"studySessionBoxId" TEXT NOT NULL,
"cardId" TEXT NOT NULL,

CONSTRAINT "StudySessionAttempt_pkey" PRIMARY KEY ("id")
);

-- AddForeignKey
ALTER TABLE "StudySessionAttempt" ADD CONSTRAINT "StudySessionAttempt_studySessionBoxId_fkey" FOREIGN KEY ("studySessionBoxId") REFERENCES "StudySessionBox"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "StudySessionAttempt" ADD CONSTRAINT "StudySessionAttempt_cardId_fkey" FOREIGN KEY ("cardId") REFERENCES "Card"("id") ON DELETE CASCADE ON UPDATE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
Warnings:
- You are about to drop the column `cardId` on the `StudySessionAttempt` table. All the data in the column will be lost.
- You are about to drop the column `studySessionBoxId` on the `StudySessionAttempt` table. All the data in the column will be lost.
- Added the required column `studySessionBoxCardId` to the `StudySessionAttempt` table without a default value. This is not possible if the table is not empty.
*/
-- DropForeignKey
ALTER TABLE "StudySessionAttempt" DROP CONSTRAINT "StudySessionAttempt_cardId_fkey";

-- DropForeignKey
ALTER TABLE "StudySessionAttempt" DROP CONSTRAINT "StudySessionAttempt_studySessionBoxId_fkey";

-- AlterTable
ALTER TABLE "StudySessionAttempt" DROP COLUMN "cardId",
DROP COLUMN "studySessionBoxId",
ADD COLUMN "studySessionBoxCardId" TEXT NOT NULL;

-- CreateTable
CREATE TABLE "StudySessionBoxCard" (
"id" TEXT NOT NULL,
"studySessionBoxId" TEXT NOT NULL,
"cardId" TEXT NOT NULL,

CONSTRAINT "StudySessionBoxCard_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "StudySessionBoxCard_studySessionBoxId_cardId_key" ON "StudySessionBoxCard"("studySessionBoxId", "cardId");

-- AddForeignKey
ALTER TABLE "StudySessionBoxCard" ADD CONSTRAINT "StudySessionBoxCard_studySessionBoxId_fkey" FOREIGN KEY ("studySessionBoxId") REFERENCES "StudySessionBox"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "StudySessionBoxCard" ADD CONSTRAINT "StudySessionBoxCard_cardId_fkey" FOREIGN KEY ("cardId") REFERENCES "Card"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "StudySessionAttempt" ADD CONSTRAINT "StudySessionAttempt_studySessionBoxCardId_fkey" FOREIGN KEY ("studySessionBoxCardId") REFERENCES "StudySessionBoxCard"("id") ON DELETE CASCADE ON UPDATE CASCADE;
94 changes: 73 additions & 21 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ model Session {
}

model User {
id String @id @default(cuid())
id String @id @default(cuid())
name String?
email String? @unique
email String? @unique
emailVerified DateTime?
image String?
accounts Account[]
sessions Session[]
decks Deck[]
studySessions StudySession[]
}

model VerificationToken {
Expand All @@ -59,29 +60,80 @@ enum Visibility {
}

model Deck {
id String @id @default(cuid())
title String
description String
visibility Visibility @default(Public)
ownerId String
image String @unique
updatedAt DateTime @default(now()) @updatedAt
createdAt DateTime @default(now())
user User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
topics Topic[]
cards Card[]
id String @id @default(cuid())
title String
description String
visibility Visibility @default(Public)
ownerId String
image String @unique
updatedAt DateTime @default(now()) @updatedAt
createdAt DateTime @default(now())
user User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
topics Topic[]
cards Card[]
studySessions StudySession[]
}

model Topic {
id String @id @default(cuid())
title String @unique
decks Deck[]
id String @id @default(cuid())
title String @unique
decks Deck[]
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
}

model Card {
id String @id @default(cuid())
question String
answer String
deckId String
deck Deck @relation(fields: [deckId], references: [id], onDelete: Cascade)
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[]
}

model StudySession {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
deckId String
deck Deck @relation(fields: [deckId], references: [id], onDelete: Cascade)
studySessionBoxes StudySessionBox[]
@@unique([userId, deckId])
}

model StudySessionBox {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
studySessionId String
studySession StudySession @relation(fields: [studySessionId], references: [id], onDelete: Cascade)
lastReview DateTime @default(now())
reviewGapInHours Int
studySessionBoxCards StudySessionBoxCard[]
}

model StudySessionBoxCard {
id String @id @default(cuid())
studySessionBoxId String
studySessionBox StudySessionBox @relation(fields: [studySessionBoxId], references: [id], onDelete: Cascade)
cardId String
card Card @relation(fields: [cardId], references: [id], onDelete: Cascade)
studySessionAttempts StudySessionAttempt[]
@@unique([studySessionBoxId, cardId])
}

model StudySessionAttempt {
id String @id @default(cuid())
answer String
isRight Boolean
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
studySessionBoxCardId String
studySessionBoxCard StudySessionBoxCard @relation(fields: [studySessionBoxCardId], references: [id], onDelete: Cascade)
}
1 change: 1 addition & 0 deletions public/images/lost-in-space.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/images/not-found-illustration.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions src/components/card/card.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { classNames } from '~/utils/css'
import type { CardProps } from './card.types'

export function _Card(props: CardProps) {
const { children, isEditable, onDeletePress, onEditPress, onClick } = props
const { children, isEditable, onDeletePress, onEditPress, onClick, as } =
props

const renderEditButtons = () => {
if (!isEditable) return null
Expand All @@ -24,8 +25,10 @@ export function _Card(props: CardProps) {
)
}

const Container = as || 'div'

return (
<div
<Container
className={classNames(
'relative flex aspect-video w-96 items-center justify-center rounded-md bg-primary-50 p-5 text-center text-lg text-primary-900 shadow-lg shadow-primary-200 ring-1 ring-primary-900 enabled:hover:bg-primary-100',
onClick ? 'cursor-pointer' : '',
Expand All @@ -34,7 +37,7 @@ export function _Card(props: CardProps) {
>
{children}
{renderEditButtons()}
</div>
</Container>
)
}

Expand Down
3 changes: 3 additions & 0 deletions src/components/card/card.types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import type { ReactTag } from '@headlessui/react/dist/types'

export type CardProps = {
children: React.ReactNode
isEditable?: boolean
onDeletePress?: () => void
onEditPress?: () => void
onClick?: () => void
as?: ReactTag
}
Loading

1 comment on commit 0a0e7c4

@vercel
Copy link

@vercel vercel bot commented on 0a0e7c4 Jan 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

briskly – ./

briskly-emiliosheinz.vercel.app
brisklyapp.vercel.app
briskly-git-main-emiliosheinz.vercel.app

Please sign in to comment.