Add files via upload

This commit is contained in:
James 2025-10-06 00:48:58 -07:00 committed by GitHub
parent f594dc5159
commit b1a8bd7d6d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 255 additions and 194 deletions

View File

@ -338,7 +338,10 @@
<div class="wrap">
<div class="row">
<h1>BESTWCOAST Shop</h1>
<a class="cart-btn" href="https://discord.gg/kQrAQSSrez" id="loginDiscord">Login to our Discord</a>
<a class="cart-btn"
href="#"
id="loginDiscord"
data-client-id="1423370765578797126">Login to our Discord</a>
<span id="whoami" class="muted"></span>
<div class="spacer"></div>
<nav class="links" aria-label="Primary">
@ -372,6 +375,64 @@
<section id="grid" class="grid"></section>
</div>
</main>
<script>
const API = "https://affiliated-lets-automatic-oak.trycloudflare.com"; // unchanged
// ---- whoami banner (unchanged logic) ----
async function getWhoAmI() {
try {
const r = await fetch(`${API}/api/inventory`, { credentials: 'include' });
if (!r.ok) return null;
const j = await r.json();
const u = j?.user ?? j;
const label = u?.global_name ?? u?.username ?? (u?.id ? `User ${u.id}` : null);
return label ? { label, raw: u } : null;
} catch { return null; }
}
(async () => {
const who = await getWhoAmI();
document.getElementById('whoami').textContent =
who ? `Signed in as ${who.label}` : 'Not signed in';
})();
// ---- FIXED Discord login button ----
document.getElementById('loginDiscord').addEventListener('click', async (e) => {
e.preventDefault();
const backTo = encodeURIComponent(location.href);
const clientId = document.getElementById('loginDiscord').dataset.clientId;
const backendStart = `${API}/api/auth/discord?redirect=${backTo}`;
const callback = encodeURIComponent(`${API}/api/auth/discord/callback`);
const direct = `https://discord.com/oauth2/authorize?client_id=${clientId}&redirect_uri=${callback}&response_type=code&scope=identify`;
try {
// If backend is reachable, use the backend start route
const ping = await fetch(`${API}/healthz`, { mode: 'no-cors' }).catch(() => null);
// no-cors fetch wont throw on 200, but if DNS/route fails we hit catch above
location.href = backendStart;
} catch {
// Fallback: go straight to Discords authorize page
location.href = direct;
}
});
</script>
<script>
document.getElementById('checkoutBtn').addEventListener('click', async (e) => {
e.preventDefault();
const entries = Object.entries(state.cart || {});
if (!entries.length) return alert('Your cart is empty.');
alert("⚠️ IMPORTANT: After checkout, you must contact a team member to receive your order.\n\nPlease open a ticket in Discord once payment is complete.");
const items = entries.map(([id, qty]) => {
const p = products.find(p => p.id === id);
return { id, name: p?.name || id, qty: Number(qty || 1), price: p?.price || 0 };
});
await checkout(items);
});
</script>
<!-- Drawer (Cart) -->
<aside id="drawer" aria-hidden="true">