Initial commit for wedding-planner MVP
This commit is contained in:
28
components/CreateEventForm.tsx
Normal file
28
components/CreateEventForm.tsx
Normal file
@@ -0,0 +1,28 @@
|
||||
'use client'
|
||||
|
||||
import { useState } from "react"
|
||||
|
||||
export default function CreateEventForm() {
|
||||
const [name, setName] = useState('');
|
||||
|
||||
async function handleSubmit(e: React.FormEvent) {
|
||||
e.preventDefault()
|
||||
const res = await fetch('api/events', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ name }),
|
||||
});
|
||||
const event = await res.json();
|
||||
console.log('Created:', event);
|
||||
};
|
||||
|
||||
return (
|
||||
<form onSubmit={handleSubmit}>
|
||||
<input
|
||||
value={name}
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
placeholder="Event Name"
|
||||
/>
|
||||
<button type="submit">Create</button>
|
||||
</form>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user