diff --git a/buscar.html b/buscar.html
index ad06d77..c4d9a6f 100644
--- a/buscar.html
+++ b/buscar.html
@@ -49,7 +49,7 @@
-
+
@@ -135,6 +135,7 @@
let systemStatuses = [];
let systemGuilds = [];
let currentTab = 'mine'; // 'mine' o 'unassigned'
+ let isRestricted = false; // Control de bolsa
const colorDict = {
'gray': { bg: 'bg-slate-100', text: 'text-slate-600', dot: 'bg-slate-500', border: 'border-slate-200' },
@@ -166,9 +167,18 @@
}
document.addEventListener("DOMContentLoaded", async () => {
- if (!localStorage.getItem("token") || localStorage.getItem("role") !== 'operario') {
+ const currentRole = localStorage.getItem("role");
+ if (!localStorage.getItem("token") || (currentRole !== 'operario' && currentRole !== 'operario_cerrado')) {
window.location.href = "index.html"; return;
}
+
+ // Ocultamos la pestaña de bolsa si el perfil es cerrado
+ if (currentRole === 'operario_cerrado') {
+ isRestricted = true;
+ const unassignedTab = document.getElementById('tab-unassigned');
+ if(unassignedTab) unassignedTab.style.display = 'none';
+ }
+
await applyTheme();
lucide.createIcons();
await loadStatuses();
@@ -219,20 +229,25 @@
const resMine = await fetch(`${API_URL}/services/active`, { headers });
const dataMine = await resMine.json();
- // 2. Cargar todos los servicios para sacar la bolsa
- const resAll = await fetch(`${API_URL}/providers/scraped`, { headers });
- const dataAll = await resAll.json();
-
- if (dataMine.ok && dataAll.ok) {
- const myItems = dataMine.services.map(s => ({...s, _scope: 'mine'}));
-
- const unassignedItems = dataAll.services.filter(s => {
- return !s.assigned_to && s.status !== 'archived';
- }).map(s => ({...s, _scope: 'unassigned'}));
-
- allServices = [...myItems, ...unassignedItems].filter(s => s.provider !== 'SYSTEM_BLOCK');
- renderServices();
+ let myItems = [];
+ if (dataMine.ok) {
+ myItems = dataMine.services.map(s => ({...s, _scope: 'mine'}));
}
+
+ // 2. Cargar todos los servicios para sacar la bolsa (SOLO SI NO ESTÁ RESTRINGIDO)
+ let unassignedItems = [];
+ if (!isRestricted) {
+ const resAll = await fetch(`${API_URL}/providers/scraped`, { headers });
+ const dataAll = await resAll.json();
+ if (dataAll.ok) {
+ unassignedItems = dataAll.services.filter(s => {
+ return !s.assigned_to && s.status !== 'archived';
+ }).map(s => ({...s, _scope: 'unassigned'}));
+ }
+ }
+
+ allServices = [...myItems, ...unassignedItems].filter(s => s.provider !== 'SYSTEM_BLOCK');
+ renderServices();
} catch (e) {
alert("Error cargando los datos");
} finally {
@@ -483,7 +498,6 @@
t.classList.remove('translate-y-0');
}, 2500);
}
-