2025-06-30 12:37:33 +02:00
|
|
|
function createRsvpEntry(rsvp) {
|
2025-06-30 15:58:30 +02:00
|
|
|
const table = document.getElementById('rsvpsTable');
|
|
|
|
|
const tbody = table.children.item(0)
|
|
|
|
|
|
|
|
|
|
const { attending, partyMembers } = rsvp;
|
2025-06-30 12:37:33 +02:00
|
|
|
|
2025-06-30 15:58:30 +02:00
|
|
|
for (const member of partyMembers) {
|
|
|
|
|
const newRow = document.createElement('tr');
|
|
|
|
|
|
|
|
|
|
const attendingColumn = document.createElement('td');
|
|
|
|
|
attendingColumn.innerText = attending ? '✅' : '❌';
|
|
|
|
|
|
|
|
|
|
const nameColumn = document.createElement('td');
|
|
|
|
|
nameColumn.innerText = member.name;
|
|
|
|
|
|
|
|
|
|
const childColumn = document.createElement('td');
|
|
|
|
|
childColumn.innerText = member.child ? '👶' : '🧓';
|
|
|
|
|
|
|
|
|
|
const dietaryPreferencesColumn = document.createElement('td');
|
|
|
|
|
dietaryPreferencesColumn.innerText = member.dietaryPreferences.length > 0 ? member.dietaryPreferences : 'n/a';
|
|
|
|
|
|
|
|
|
|
newRow.appendChild(attendingColumn);
|
|
|
|
|
newRow.appendChild(nameColumn);
|
|
|
|
|
newRow.appendChild(childColumn);
|
|
|
|
|
newRow.appendChild(dietaryPreferencesColumn);
|
|
|
|
|
|
|
|
|
|
tbody.appendChild(newRow);
|
|
|
|
|
}
|
2025-06-30 12:37:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function getRsvps() {
|
2025-06-30 15:58:30 +02:00
|
|
|
const token = Object.fromEntries(
|
|
|
|
|
document.cookie.split(";").map((x) => x.trim().split("="))
|
|
|
|
|
)['token']
|
|
|
|
|
const resp = await fetch('/api/rsvps', { headers: { 'Authorization': `Basic ${token}`} });
|
|
|
|
|
const rsvps = await resp.json()
|
|
|
|
|
for (const rsvp of rsvps) {
|
|
|
|
|
createRsvpEntry(rsvp);
|
|
|
|
|
}
|
2025-06-30 12:37:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
window.onload = async function () {
|
|
|
|
|
await getRsvps();
|
|
|
|
|
};
|