Compare commits

...

2 commits

Author SHA1 Message Date
2b6449f61b
Finishing rsvps_list js and adding page to "login" 2025-06-30 15:58:30 +02:00
7e3b7d3f21
removing log 2025-06-30 15:58:10 +02:00
4 changed files with 60 additions and 4 deletions

View file

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

19
client/login.html Normal file
View file

@ -0,0 +1,19 @@
<!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>

7
client/login.js Normal file
View file

@ -0,0 +1,7 @@
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,11 +1,42 @@
function createRsvpEntry(rsvp) { 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() { async function getRsvps() {
// token is test:test for now const token = Object.fromEntries(
const resp = await fetch('/api/rsvps', { headers: { 'Authorization': 'Basic dGVzdDp0ZXN0'} }) document.cookie.split(";").map((x) => x.trim().split("="))
JSON.parse(resp.body) )['token']
const resp = await fetch('/api/rsvps', { headers: { 'Authorization': `Basic ${token}`} });
const rsvps = await resp.json()
for (const rsvp of rsvps) {
createRsvpEntry(rsvp);
}
} }
window.onload = async function () { window.onload = async function () {