const map = L.map('map', { zoomControl: false }).setView([-0.0258, 109.3323], 13); L.control.zoom({ position: 'bottomright' }).addTo(map); L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { maxZoom: 19 }).addTo(map); let currentMode = null; let tempLayer = null; let places = []; let houses = []; let houseFilter = 'all'; // 'all' | 'linked' | 'unlinked' // Add a simple layer control (top-right) to filter households by linked status const HouseFilterControl = L.Control.extend({ options: { position: 'bottomright' }, onAdd: function () { const container = L.DomUtil.create('div', 'leaflet-bar leaflet-control house-filter-control'); container.innerHTML = `
⚠️ Handover locked — household must be verified first.
` : ''; const popupContent = `Loading...
'; try { const res = await apiFetch('/api/analytics/sembako-demand'); if (!res.ok) throw new Error('Failed to fetch analytics'); const data = await res.json(); const totalHouseholds = data.reduce((sum, r) => sum + Number(r.households_needing_aid || 0), 0); const totalResidents = data.reduce((sum, r) => sum + Number(r.total_residents_needing_aid || 0), 0); const rows = data.map(row => `All verified households have received sembako!
❌ ${err.message}. Please log in first.
`; } } function renderPendingHandoverSection(records) { if (!records || records.length === 0) { return `No pending handovers need verification right now.
No pending household assessments.