Add files via upload
This commit is contained in:
parent
f594dc5159
commit
b1a8bd7d6d
63
ASAshop.html
63
ASAshop.html
|
|
@ -338,7 +338,10 @@
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<h1>BESTWCOAST Shop</h1>
|
<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>
|
<span id="whoami" class="muted"></span>
|
||||||
<div class="spacer"></div>
|
<div class="spacer"></div>
|
||||||
<nav class="links" aria-label="Primary">
|
<nav class="links" aria-label="Primary">
|
||||||
|
|
@ -372,6 +375,64 @@
|
||||||
<section id="grid" class="grid"></section>
|
<section id="grid" class="grid"></section>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</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 won’t throw on 200, but if DNS/route fails we hit catch above
|
||||||
|
location.href = backendStart;
|
||||||
|
} catch {
|
||||||
|
// Fallback: go straight to Discord’s 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) -->
|
<!-- Drawer (Cart) -->
|
||||||
<aside id="drawer" aria-hidden="true">
|
<aside id="drawer" aria-hidden="true">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue