Its working and i am officially the greatest (for the next 2 minutes)
All checks were successful
Vercel Preview Deployment / Deploy-Preview (push) Successful in 1m57s
All checks were successful
Vercel Preview Deployment / Deploy-Preview (push) Successful in 1m57s
This commit is contained in:
parent
3977e406c6
commit
fda212f8da
@ -1,13 +1,21 @@
|
|||||||
import { useActionState } from "react";
|
"use client";
|
||||||
import { InsertResult, addWine } from "~/server/actions/addWine";
|
import { useActionState, useEffect, useState } from "react";
|
||||||
|
import { addWine } from "~/server/actions/addWine";
|
||||||
import { getProducers } from "~/server/actions/allProducers";
|
import { getProducers } from "~/server/actions/allProducers";
|
||||||
|
|
||||||
type Wine = {
|
async function fetchProducers() {
|
||||||
name: string;
|
const producers = await getProducers();
|
||||||
producer: string;
|
return producers;
|
||||||
};
|
}
|
||||||
|
|
||||||
const producers = await getProducers();
|
type ProducersData = {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
createdAt: Date;
|
||||||
|
country: string;
|
||||||
|
region: string;
|
||||||
|
email: string;
|
||||||
|
}[];
|
||||||
|
|
||||||
export default function CreateWine() {
|
export default function CreateWine() {
|
||||||
const [formState, formAction] = useActionState(addWine, {
|
const [formState, formAction] = useActionState(addWine, {
|
||||||
@ -18,7 +26,14 @@ export default function CreateWine() {
|
|||||||
producer: "",
|
producer: "",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
const [producers, setProducers] = useState<ProducersData>([]);
|
||||||
|
useEffect(() => {
|
||||||
|
async function loadProducers() {
|
||||||
|
const producersData = await fetchProducers();
|
||||||
|
setProducers(producersData);
|
||||||
|
}
|
||||||
|
loadProducers();
|
||||||
|
}, []);
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<form action={formAction}>
|
<form action={formAction}>
|
||||||
|
Loading…
Reference in New Issue
Block a user