import { apiGet } from '../api.js'; import { syncNotifications } from '../notifications.js'; export async function renderAssigned(root) { root.innerHTML = `
Incidents assignés
`; const box = root.querySelector('#box'); const btn = root.querySelector('#btnRefresh'); async function load() { box.innerHTML = '
Chargement…
'; try { const res = await apiGet('/api/mobile/incidents/assigned'); const items = res?.incidents || []; syncNotifications({ incidents: items }); if (!items.length) { box.innerHTML = '
Aucun incident assigné.
'; return; } box.innerHTML = items.map((i) => { const id = Number(i.id || 0); const ticket = (i.ticket_id || `INC-${id}`); const title = (i.title || '').toString(); const prio = (i.priority || '').toString(); const status = (i.status_label || '').toString(); return `
${escapeHtml(ticket)}
${escapeHtml(title)}
${escapeHtml(prio)}
${escapeHtml(status)}
`; }).join(''); } catch { box.innerHTML = '
Impossible de charger la liste.
'; } } btn.addEventListener('click', load); await load(); } function escapeHtml(s) { return String(s) .replaceAll('&', '&') .replaceAll('<', '<') .replaceAll('>', '>') .replaceAll('"', '"') .replaceAll("'", '''); }