Add files via upload

This commit is contained in:
James 2025-10-03 23:35:24 -07:00 committed by GitHub
parent 1584723c30
commit 193f56a908
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 11 deletions

View File

@ -462,10 +462,11 @@
</div> </div>
<script> <script>
const API = 'https://api.oblistudios.com';
/* ===== Login banner (whoami) ===== */ /* ===== Login banner (whoami) ===== */
async function getWhoAmI() { async function getWhoAmI() {
try { try {
const r = await fetch('/api/whoami', { credentials: 'include' }); const r = await fetch(`${API}/api/inventory`, { credentials: 'include' })
if (!r.ok) return null; if (!r.ok) return null;
return await r.json(); return await r.json();
} catch { return null; } } catch { return null; }
@ -673,10 +674,10 @@
}); });
// 1) Try to reserve on the server // 1) Try to reserve on the server
const reserve = await fetch('/api/reserve', { const reserve = await fetch(`${API}/api/reserve`, {
method: 'POST', headers: { 'Content-Type': 'application/json' }, credentials: 'include', method: 'POST', headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ items }) credentials: 'include', body: JSON.stringify({ items })
}).then(r => r.json()).catch(() => ({ ok: false })); })
if (!reserve?.ok) { if (!reserve?.ok) {
const rem = typeof reserve?.remaining === 'number' ? reserve.remaining : remaining; const rem = typeof reserve?.remaining === 'number' ? reserve.remaining : remaining;
@ -686,10 +687,10 @@
} }
// 2) Create a Stripe Checkout session // 2) Create a Stripe Checkout session
const session = await fetch('/api/create-checkout', { const session = await fetch(`${API}/api/create-checkout`, {
method: 'POST', headers: { 'Content-Type': 'application/json' }, credentials: 'include', method: 'POST', headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ items }) credentials: 'include', body: JSON.stringify({ items })
}).then(r => r.json()); })
if (!session?.url) { if (!session?.url) {
alert('Could not start checkout. Try again.'); return; alert('Could not start checkout. Try again.'); return;
@ -724,8 +725,7 @@
let remaining = 12; let remaining = 12;
async function refreshRemaining() { async function refreshRemaining() {
try { try {
const r = await fetch('http://10.1.10.195:3000/api/inventory', { credentials: 'include' }); const j = await r.json(); const r = await fetch(`${API}/api/inventory`, { credentials: 'include' })
remaining = j.remaining;
document.querySelectorAll('[data-remaining] .remN').forEach(s => s.textContent = remaining); document.querySelectorAll('[data-remaining] .remN').forEach(s => s.textContent = remaining);
// Disable all three server buttons if none left: // Disable all three server buttons if none left:
if (remaining <= 0) { if (remaining <= 0) {