Compare commits

..

No commits in common. "2b6449f61b44fd929b9b45773fe3ce851ca65f7b" and "d431f34e7296ce7d42a66f96f4da950ae1de0d70" have entirely different histories.

4 changed files with 4 additions and 60 deletions

View file

@ -14,6 +14,7 @@ function persistRsvp(hasRsvped = true) {
}
function rsvpButtonClicked() {
console.log("here");
persistRsvp(true);
}

View file

@ -1,19 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="/style.css">
</head>
<body>
<h1 class="title fontXL textCenter backgroundLightGreen colorWhite">Collin and Lucy's Wedding</h1>
<div class="contents fontM">
<label for="username">Username</label>
<input type="text" name="username" id="username">
<label for="password">Password</label>
<input type="password" name="password" id="password">
<button onclick="login">Login</button>
</div>
<script src="/login.js"></script>
</body>
</html>

View file

@ -1,7 +0,0 @@
function login() {
const usernameInput = document.getElementById('username');
const passwordInput = document.getElementById('password');
const token = btoa(`${usernameInput.textContent}:${passwordInput.textContent}`);
document.cookie = `token=${String(token)}; path=/`;
}

View file

@ -1,42 +1,11 @@
function createRsvpEntry(rsvp) {
const table = document.getElementById('rsvpsTable');
const tbody = table.children.item(0)
const { attending, partyMembers } = rsvp;
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);
}
}
async function getRsvps() {
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);
}
// token is test:test for now
const resp = await fetch('/api/rsvps', { headers: { 'Authorization': 'Basic dGVzdDp0ZXN0'} })
JSON.parse(resp.body)
}
window.onload = async function () {