Skip to content

Commit

Permalink
Removed deck query input, added window refocus logic to home screen, …
Browse files Browse the repository at this point in the history
…refactored DxDeck and DxCard to Deck and Card across the app
  • Loading branch information
SlyPuffin committed Feb 15, 2022
1 parent dcfd842 commit 589075a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
8 changes: 4 additions & 4 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ generator client {
previewFeatures = ["referentialIntegrity"]
}

model DxDeck {
model Deck {
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
type String @db.VarChar(255)
name String @db.Text
cards DxCard[]
cards Card[]
}

model DxCard {
model Card {
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
Expand All @@ -30,6 +30,6 @@ model DxCard {
source String @db.VarChar(255)
xp Float @db.Float
deckId String
deck DxDeck @relation(fields: [deckId], references: [id], onDelete: Cascade)
deck Deck @relation(fields: [deckId], references: [id], onDelete: Cascade)
@@index([deckId])
}
2 changes: 1 addition & 1 deletion prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { PrismaClient } from "@prisma/client";
const prisma = new PrismaClient();

async function main() {
const deck = await prisma.dxDeck.create({
const deck = await prisma.deck.create({
data: {
type: "concept",
name: "Seeded Deck 1",
Expand Down
9 changes: 2 additions & 7 deletions src/backend/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@ import { prisma } from "@/backend/utils/prisma";
export const appRouter = trpc
.router()
.query("get-decks", {
input: z
.object({
text: z.string().nullish(),
})
.nullish(),
async resolve({ input }) {
const decksFromDb = await prisma.dxDeck.findMany();
const decksFromDb = await prisma.deck.findMany();
return { decks: decksFromDb };
},
})
Expand All @@ -22,7 +17,7 @@ export const appRouter = trpc
}),
async resolve({ input }) {
const { id } = input;
const cardsFromDb = await prisma.dxCard.findMany({
const cardsFromDb = await prisma.card.findMany({
where: {
deckId: id,
},
Expand Down
8 changes: 5 additions & 3 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { trpc } from "@/utils/trpc";
import React from "react";
import Link from "next/link";
import { DxDeck } from "@prisma/client";
import { Deck } from "@prisma/client";

export default function Home() {
const { data, isLoading } = trpc.useQuery(["get-decks"]);
const { data, isLoading } = trpc.useQuery(["get-decks"], {
refetchOnWindowFocus: false,
});

type DeckProps = {
decks: DxDeck[];
decks: Deck[];
};
type DeckState = {};

Expand Down

0 comments on commit 589075a

Please sign in to comment.