Files
wedding-planner/lib/helper/addGuest.ts
briannelson95 28efa115ad managing rsvps
2025-06-28 20:23:22 -04:00

26 lines
671 B
TypeScript

export async function handleAddGuest(data: {
fName: string
lName: string
email?: string
phone?: string
address?: string
side: string
notes?: string
}) {
try {
const res = await fetch('/api/guestbook/add', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data),
})
if (!res.ok) {
const { message } = await res.json()
throw new Error(message || 'Failed to add guest')
}
// Optionally: re-fetch entries or mutate state here
} catch (err) {
console.error('Error adding guest:', err)
}
}