managing rsvps

This commit is contained in:
briannelson95
2025-06-28 20:23:22 -04:00
parent dee9066c91
commit 28efa115ad
19 changed files with 568 additions and 197 deletions

26
lib/helper/addGuest.ts Normal file
View File

@@ -0,0 +1,26 @@
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)
}
}

23
lib/helper/createEvent.ts Normal file
View File

@@ -0,0 +1,23 @@
export async function handleCreateEvent(data: {
name: string
date?: string
location?: string
}) {
try {
const res = await fetch('/api/events/create', {
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 create event')
}
// Optionally return or mutate data
return await res.json()
} catch (err) {
console.error('Error creating event:', err)
}
}

View File

@@ -12,7 +12,7 @@ export const queries = {
}
}
})
console.log(allEvents)
return allEvents;
},
@@ -65,7 +65,12 @@ export const queries = {
creator: {
select: { id: true, email: true, name: true, role: true },
},
guests: true
guests: true,
eventGuests: {
include: {
guestBookEntry: true,
}
},
}
})
return event