[feat] loading inventory

This commit is contained in:
2026-04-03 22:10:41 -04:00
parent 86da8a91ad
commit 03394d81e8
3 changed files with 19 additions and 17 deletions

View File

@@ -48,6 +48,21 @@ import BackToTop from "./BackToTop.astro"
(function () {
function initInventoryForms(root = document) {
// Fetch inventory entries for this card
const invList = root.querySelector('#inventoryEntryList') || document.getElementById('inventoryEntryList');
if (invList && !invList.dataset.inventoryFetched) {
invList.dataset.inventoryFetched = 'true';
const cardId = invList.dataset.cardId;
if (cardId) {
const body = new FormData();
body.append('cardId', cardId);
fetch('/api/inventory', { method: 'POST', body })
.then(r => r.text())
.then(html => { invList.innerHTML = html || ''; })
.catch(() => { invList.innerHTML = '<span class="text-danger">Failed to load inventory</span>'; });
}
}
const forms = root.querySelectorAll('[data-inventory-form]');
forms.forEach((form) => {