Fixed producer id not being added to wine record
All checks were successful
Vercel Production Deployment / Deploy-Production (push) Successful in 1m46s
All checks were successful
Vercel Production Deployment / Deploy-Production (push) Successful in 1m46s
This commit is contained in:
parent
b2d31d96ab
commit
0f0ce967b6
@ -13,8 +13,8 @@ interface Producer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function CreateWine() {
|
export default function CreateWine() {
|
||||||
const [name, setName] = useState("");
|
const [name, setName] = useState<string>("");
|
||||||
const [producer, setProducer] = useState("");
|
const [producer, setProducer] = useState<string>("");
|
||||||
const [allProducers, setAllProducers] = useState<Producer[]>([]);
|
const [allProducers, setAllProducers] = useState<Producer[]>([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -37,15 +37,21 @@ export default function CreateWine() {
|
|||||||
};
|
};
|
||||||
const handleAdd = async (event: FormEvent) => {
|
const handleAdd = async (event: FormEvent) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
console.log(producer);
|
||||||
addWine(producer, name);
|
addWine(producer, name);
|
||||||
setName("");
|
setName("");
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<input type="text" onChange={handleName} value={name} />
|
<input type="text" onChange={handleName} value={name} />
|
||||||
<select name="producer" onSelect={handleProducer}>
|
<select
|
||||||
{allProducers.map((item) => (
|
name="producer"
|
||||||
<option key={item.id} value={item.id}>
|
id="producer"
|
||||||
|
value={producer}
|
||||||
|
onChange={handleProducer}
|
||||||
|
>
|
||||||
|
{allProducers.map((item, i) => (
|
||||||
|
<option key={i} value={item.id}>
|
||||||
{item.name}
|
{item.name}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
|
17
src/app/WineCards.tsx
Normal file
17
src/app/WineCards.tsx
Normal file
@ -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) => (
|
||||||
|
<div key={wine.id}>
|
||||||
|
{wine.name} - {wine.producer}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
@ -1,22 +1,5 @@
|
|||||||
import { getProducers } from "~/server/actions/allProducers";
|
|
||||||
import { getWines } from "../server/actions/allWines";
|
|
||||||
import CreateWine from "./CreateWine";
|
import CreateWine from "./CreateWine";
|
||||||
export const dynamic = "force-dynamic";
|
import WineCards from "./WineCards";
|
||||||
|
|
||||||
const allWines = await getWines();
|
|
||||||
const allProducers = await getProducers();
|
|
||||||
|
|
||||||
function WineCards() {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
{allWines.map((wine) => (
|
|
||||||
<div key={wine.id}>
|
|
||||||
{wine.name} - {wine.producer}
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default async function HomePage() {
|
export default async function HomePage() {
|
||||||
return (
|
return (
|
||||||
|
@ -7,12 +7,6 @@ import {
|
|||||||
} from "drizzle-orm/pg-core";
|
} from "drizzle-orm/pg-core";
|
||||||
import { relations } from 'drizzle-orm';
|
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 createTable = pgTableCreator((name) => `wine-shop_${name}`);
|
||||||
|
|
||||||
export const producers = createTable(
|
export const producers = createTable(
|
||||||
|
Loading…
Reference in New Issue
Block a user