Add files via upload
This commit is contained in:
parent
1584723c30
commit
193f56a908
22
ASAshop.html
22
ASAshop.html
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue