diff --git a/src/server/public/assets/js/dashboard_items.js b/src/server/public/assets/js/dashboard_items.js index 095e617..e93a4d4 100644 --- a/src/server/public/assets/js/dashboard_items.js +++ b/src/server/public/assets/js/dashboard_items.js @@ -27,12 +27,20 @@ const list = $('itemsList'); async function fetchItems(){ - if(!guildId) return; + if(!guildId){ showPageAlert('warning','No hay servidor seleccionado. Selecciona un servidor o inicia sesión.'); return; } if(list) list.textContent = 'Cargando items...'; try{ const res = await fetch('/api/dashboard/' + encodeURIComponent(guildId) + '/items', { headers:{ 'Accept':'application/json' } }); - if(!res.ok) throw new Error('fetch-failed'); - const j = await res.json(); if(!j || !j.ok) throw new Error('bad'); + if(!res.ok){ + // Show helpful message depending on status + if(res.status === 401) { showPageAlert('danger','No autenticado. Inicia sesión y vuelve a intentarlo.'); } + else if(res.status === 403) { showPageAlert('danger','No tienes permisos para ver items en este servidor.'); } + else { showPageAlert('danger','Error al cargar items (HTTP ' + res.status + ')'); } + if(list) list.innerHTML = '