From 0f0ce967b678e12b08a9da3d49e346d958ef1b72 Mon Sep 17 00:00:00 2001 From: christian Date: Fri, 24 May 2024 17:54:50 +0200 Subject: [PATCH] Fixed producer id not being added to wine record --- src/app/CreateWine.tsx | 16 +++++++++++----- src/app/WineCards.tsx | 17 +++++++++++++++++ src/app/page.tsx | 19 +------------------ src/server/db/schema.ts | 6 ------ 4 files changed, 29 insertions(+), 29 deletions(-) create mode 100644 src/app/WineCards.tsx diff --git a/src/app/CreateWine.tsx b/src/app/CreateWine.tsx index ace1b09..8dbb62b 100644 --- a/src/app/CreateWine.tsx +++ b/src/app/CreateWine.tsx @@ -13,8 +13,8 @@ interface Producer { } export default function CreateWine() { - const [name, setName] = useState(""); - const [producer, setProducer] = useState(""); + const [name, setName] = useState(""); + const [producer, setProducer] = useState(""); const [allProducers, setAllProducers] = useState([]); useEffect(() => { @@ -37,15 +37,21 @@ export default function CreateWine() { }; const handleAdd = async (event: FormEvent) => { event.preventDefault(); + console.log(producer); addWine(producer, name); setName(""); }; return (
- + {allProducers.map((item, i) => ( + ))} diff --git a/src/app/WineCards.tsx b/src/app/WineCards.tsx new file mode 100644 index 0000000..b68cbaf --- /dev/null +++ b/src/app/WineCards.tsx @@ -0,0 +1,17 @@ +import { getWines } from "~/server/actions/allWines"; + +export const dynamic = "force-dynamic"; + +const allWines = await getWines(); + +export default function WineCards() { + return ( + <> + {allWines.map((wine) => ( +
+ {wine.name} - {wine.producer} +
+ ))} + + ); +} diff --git a/src/app/page.tsx b/src/app/page.tsx index 157fd6f..930c119 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,22 +1,5 @@ -import { getProducers } from "~/server/actions/allProducers"; -import { getWines } from "../server/actions/allWines"; import CreateWine from "./CreateWine"; -export const dynamic = "force-dynamic"; - -const allWines = await getWines(); -const allProducers = await getProducers(); - -function WineCards() { - return ( - <> - {allWines.map((wine) => ( -
- {wine.name} - {wine.producer} -
- ))} - - ); -} +import WineCards from "./WineCards"; export default async function HomePage() { return ( diff --git a/src/server/db/schema.ts b/src/server/db/schema.ts index 7fac292..d6843f9 100644 --- a/src/server/db/schema.ts +++ b/src/server/db/schema.ts @@ -7,12 +7,6 @@ import { } from "drizzle-orm/pg-core"; import { relations } from 'drizzle-orm'; -/** - * This is an example of how to use the multi-project schema feature of Drizzle ORM. Use the same - * database instance for multiple projects. - * - * @see https://orm.drizzle.team/docs/goodies#multi-project-schema - */ export const createTable = pgTableCreator((name) => `wine-shop_${name}`); export const producers = createTable(