A per-event queue board for a repair cafe. Customers sign items in on a shared tablet; volunteers drag repairs through Queue, In progress and Done on a dashboard, then export the day's records as CSV. Zero npm dependencies: node:http plus JSON files on disk, no build step. Categories and house rules are set in config.json. Events are deleted 7 days after creation. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
87 lines
2.7 KiB
HTML
87 lines
2.7 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>New event — Repair Cafe Kanban</title>
|
|
<link rel="stylesheet" href="/static/app.css">
|
|
</head>
|
|
<body>
|
|
<div class="wrap">
|
|
<h1>Create repair cafe kanban</h1>
|
|
<p class="subtitle">Set up a board for one event.</p>
|
|
|
|
<div id="error" class="notice error" hidden></div>
|
|
|
|
<form id="form" autocomplete="off">
|
|
<div class="field">
|
|
<label for="name">Name of event</label>
|
|
<input type="text" id="name" name="name" required maxlength="80" placeholder="Saturday Repair Day">
|
|
</div>
|
|
|
|
<div class="field">
|
|
<label class="check">
|
|
<input type="checkbox" id="randomize">
|
|
<span>Randomise the address<br>
|
|
<span class="hint">Adds a few random characters to the end so the address is hard to
|
|
guess or collide with. Useful if you run an event with the same name often.</span></span>
|
|
</label>
|
|
</div>
|
|
|
|
<div class="field">
|
|
<label>The board will live at</label>
|
|
<div class="url-preview" id="preview">…</div>
|
|
</div>
|
|
|
|
<button type="submit" class="primary big" id="create">Create</button>
|
|
<p style="margin-top:24px"><a href="/">Cancel</a></p>
|
|
</form>
|
|
</div>
|
|
|
|
<script>
|
|
const nameInput = document.getElementById('name');
|
|
const randomize = document.getElementById('randomize');
|
|
const preview = document.getElementById('preview');
|
|
const errorBox = document.getElementById('error');
|
|
const createBtn = document.getElementById('create');
|
|
|
|
// Must match slugify() in lib/store.js.
|
|
function slugify(name) {
|
|
return name.toLowerCase().trim().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 60);
|
|
}
|
|
|
|
function updatePreview() {
|
|
const slug = slugify(nameInput.value);
|
|
const suffix = randomize.checked ? '-xxxx' : '';
|
|
preview.textContent = slug ? `${location.origin}/${slug}${suffix}` : '…';
|
|
}
|
|
|
|
nameInput.addEventListener('input', updatePreview);
|
|
randomize.addEventListener('change', updatePreview);
|
|
updatePreview();
|
|
|
|
document.getElementById('form').addEventListener('submit', async (e) => {
|
|
e.preventDefault();
|
|
errorBox.hidden = true;
|
|
createBtn.disabled = true;
|
|
try {
|
|
const res = await fetch('/api/events', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ name: nameInput.value, randomize: randomize.checked }),
|
|
});
|
|
const data = await res.json();
|
|
if (!res.ok) throw new Error(data.error || 'Could not create the event.');
|
|
location.href = '/' + data.slug;
|
|
} catch (err) {
|
|
errorBox.textContent = err.message;
|
|
errorBox.hidden = false;
|
|
createBtn.disabled = false;
|
|
}
|
|
});
|
|
|
|
nameInput.focus();
|
|
</script>
|
|
</body>
|
|
</html>
|