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