const API_BASE = window?.ENV?.API_BASE || ""; export async function fetchSections() { const res = await fetch(`${API_BASE}/apps`); if (!res.ok) throw new Error('Failed to fetch sections'); return res.json(); } export async function addAppToSection({ section, app }) { const res = await fetch(`${API_BASE}/add_app`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ section, app }) }); if (!res.ok) throw new Error(await res.text()); return res.json(); } export async function getIconUrl(filename) { const res = await fetch(`${API_BASE}/icon/${filename}`); if (!res.ok) throw new Error(`Failed to fetch icon for ${filename}`); const data = await res.json(); return data.url; } export async function editAppInSection({ section, app }) { const res = await fetch(`${API_BASE}/edit_app`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ section, app }) }); if (!res.ok) throw new Error(await res.text()); return await res.json(); } export async function deleteAppFromSection({ section, app }) { const res = await fetch(`${API_BASE}/delete_app`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ section, app }) }); if (!res.ok) throw new Error(await res.text()); return res.json(); }