What Do You Want?
I Want My Own _________.

Maybe We're Here To Decide What We Want
What The People Want:
Loading what the people want...
Nothing here yet.
'; return; } submissions.forEach(item => { const entry = document.createElement('div'); entry.className = 'iwmo-want'; let answer = item.answer.trim(); /* Remove "I want my own" if they already typed it */ answer = answer.replace(/^i\s+want\s+my\s+own\s*/i, ''); const prefix = document.createElement('div'); prefix.className = 'iwmo-prefix'; prefix.textContent = 'I Want My Own'; const answerText = document.createElement('div'); answerText.className = 'iwmo-answer'; answerText.textContent = answer; entry.appendChild(prefix); entry.appendChild(answerText); container.appendChild(entry); }); } catch (error) { console.error(error); container.innerHTML = ''; } })(); 
IWMO ADMIN
Sign in to continue
IWMO ADMIN
Pending Submissions
Loading submissions...
Loading submissions...
'; try { const response = await fetch( SUPABASE_URL + '/rest/v1/Submissions' + '?select=id,answer,created_at' + '&approved=eq.false' + '&reviewed=eq.false' + '&order=created_at.desc', { headers: { 'apikey': API_KEY, 'Authorization': 'Bearer ' + accessToken } } ); if (!response.ok) { throw new Error('Could not load submissions'); } const submissions = await response.json(); list.innerHTML = ''; if (submissions.length === 0) { list.innerHTML = 'All caught up.
'; return; } submissions.forEach(function(item) { const card = document.createElement('div'); card.className = 'iwmo-admin-card'; const answer = document.createElement('div'); answer.className = 'iwmo-admin-answer'; answer.textContent = item.answer; const date = document.createElement('div'); date.className = 'iwmo-admin-date'; date.textContent = new Date(item.created_at).toLocaleString(); const actions = document.createElement('div'); actions.className = 'iwmo-admin-actions'; const approve = document.createElement('button'); approve.className = 'iwmo-approve'; approve.textContent = 'APPROVE'; const deny = document.createElement('button'); deny.className = 'iwmo-deny'; deny.textContent = 'DENY'; approve.addEventListener( 'click', function() { reviewSubmission( item.id, true, card, approve, deny ); } ); deny.addEventListener( 'click', function() { reviewSubmission( item.id, false, card, approve, deny ); } ); actions.appendChild(approve); actions.appendChild(deny); card.appendChild(answer); card.appendChild(date); card.appendChild(actions); list.appendChild(card); }); } catch (error) { console.error(error); list.innerHTML = 'Could not load submissions.
'; } } /* ---------------- APPROVE / DENY ---------------- */ async function reviewSubmission( id, approved, card, approveButton, denyButton ) { approveButton.disabled = true; denyButton.disabled = true; try { const response = await fetch( SUPABASE_URL + '/rest/v1/Submissions?id=eq.' + encodeURIComponent(id), { method: 'PATCH', headers: { 'apikey': API_KEY, 'Authorization': 'Bearer ' + accessToken, 'Content-Type': 'application/json', 'Prefer': 'return=minimal' }, body: JSON.stringify({ approved: approved, reviewed: true }) } ); if (!response.ok) { throw new Error( 'Could not update submission' ); } card.remove(); if ( list.querySelectorAll( '.iwmo-admin-card' ).length === 0 ) { list.innerHTML = 'All caught up.
'; } } catch (error) { console.error(error); approveButton.disabled = false; denyButton.disabled = false; alert( 'Something went wrong. Try again.' ); } } /* ---------------- LOG OUT ---------------- */ document .getElementById('iwmo-logout') .addEventListener('click', function() { accessToken = null; sessionStorage.removeItem( 'iwmo_admin_token' ); dashboard.style.display = 'none'; loginArea.style.display = 'block'; document.getElementById( 'iwmo-password' ).value = ''; loginMessage.textContent = ''; }); /* ---------------- EXISTING SESSION ---------------- */ const savedToken = sessionStorage.getItem( 'iwmo_admin_token' ); if (savedToken) { accessToken = savedToken; loginArea.style.display = 'none'; dashboard.style.display = 'block'; await loadSubmissions(); } })();