Add editable option approval flow

This commit is contained in:
TopherMayor
2026-04-30 22:39:51 -07:00
parent 1674930435
commit 1e36d45976
3 changed files with 82 additions and 8 deletions

View File

@@ -1638,6 +1638,7 @@
<div class="form-grid">
<input type="text" id="addName" placeholder="Name of the place (required)" maxlength="80" />
<input type="text" id="addDesc" placeholder="Short description — price, vibe, what to expect…" maxlength="200" />
<textarea id="addDetails" placeholder="Details on separate lines — price, inclusions, caveats, or notes…" maxlength="500" rows="3" style="background:transparent;border:1px solid #252a38;border-radius:10px;color:#e0e6f0;padding:10px;resize:vertical;min-height:84px;"></textarea>
<input type="url" id="addUrl" placeholder="Website URL (optional)" />
<div class="btn-row">
<select id="addCategory">
@@ -1909,13 +1910,15 @@
});
render();
if (mapInitialized) mapRefreshMarkers();
} else if (msg.type === 'option_added' || msg.type === 'option_approved') {
} else if (msg.type === 'option_added' || msg.type === 'option_approved' || msg.type === 'option_updated') {
if (!state.options.find(o => o.id === msg.option.id)) {
state.options.push(msg.option);
renderTabs();
render();
if (mapInitialized) mapRefreshMarkers();
} else {
state.options = state.options.map(o => o.id === msg.option.id ? { ...o, ...msg.option } : o);
}
renderTabs();
render();
if (mapInitialized) mapRefreshMarkers();
} else if (msg.type === 'option_deleted') {
state.options = state.options.filter(o => o.id !== msg.id);
renderTabs();
@@ -2968,6 +2971,7 @@
function submitNewOption() {
const name = document.getElementById('addName').value.trim();
const desc = document.getElementById('addDesc').value.trim();
const details = document.getElementById('addDetails').value.trim();
const url = document.getElementById('addUrl').value.trim();
const catId = document.getElementById('addCategory').value;
@@ -2980,11 +2984,12 @@
return;
}
wsSend({ type: 'add_option', categoryId: catId, name, desc, url, voterName: state.voterName, authToken: state.guestAuthToken });
wsSend({ type: 'add_option', categoryId: catId, name, desc, details, url, voterName: state.voterName, authToken: state.guestAuthToken });
// Clear form
document.getElementById('addName').value = '';
document.getElementById('addDesc').value = '';
document.getElementById('addDetails').value = '';
document.getElementById('addUrl').value = '';
showToast(`Submitted "${name}" for approval!`, 'success');
}