/* Parent → Wristband pairing: pair & manage the child's RFID band. */ function WristbandScreen({ onNav, onBack }) { const child = jlChild(); const [paired, setPaired] = React.useState(() => { try { return localStorage.getItem('jl_band_'+child.id)==='1'; } catch(e){ return false; } }); const [pairing, setPairing] = React.useState(false); const [code, setCode] = React.useState(''); const [alerts, setAlerts] = React.useState(true); const [tap, setTap] = React.useState(null); React.useEffect(() => { const read = () => { try { setTap((JSON.parse(localStorage.getItem('jl_roster')||'{}'))[child.id] || null); } catch(e){} }; read(); const iv = setInterval(read, 1500); window.addEventListener('storage', read); return () => { clearInterval(iv); window.removeEventListener('storage', read); }; }, [child.id]); const startPair = () => { if (code.trim().length < 4) { jlToast('Enter the 6-digit code on the band', { icon:'triangle-alert', color:'#E5484D' }); return; } setPairing(true); setTimeout(() => { setPairing(false); setPaired(true); try { localStorage.setItem('jl_band_'+child.id,'1'); } catch(e){} jlToast(child.first + "'s wristband paired", { icon:'check-check', color:'#1F9D57' }); }, 1400); }; return (
{paired && tap && (
{child.first}'s band just tapped {tap.bus||'Bus #12'}
{(tap.stop?tap.stop+' · ':'')}{tap.time||''} · synced to your phone
)} {/* band hero */}
{child.initials}
{child.first}'s Wristband
{paired ? 'Paired · tap-to-board active' : 'Not paired yet'}
{!paired ? ( Pair a Wristband
Enter the 6-digit code printed on the back of the band, then hold it near your phone.
setCode(e.target.value.replace(/[^0-9]/g,'').slice(0,6))} placeholder="123456" inputMode="numeric" style={{ width:'100%', boxSizing:'border-box', textAlign:'center', letterSpacing:'.4em', fontSize:22, fontWeight:800, fontFamily:'var(--font-mono)', border:'1.5px solid var(--gray-200)', borderRadius:12, padding:'14px', outline:'none', color:'var(--ink)', marginBottom:14 }} />
Once paired, {child.first}'s band taps the bus and gate readers to auto-update your "Where's {child.first}?" timeline — no action needed from you.
) : ( Band Status
Battery
82% · ~4 months left
Good
Last tap
{tap ? ((tap.status==='boarded'?'Boarded ':'Tapped ') + (tap.bus||'Bus #12') + (tap.time?' · '+tap.time:'')) : 'No taps yet today'}
{tap && }
Tap alerts
Notify me on each board/exit
)}
); } Object.assign(window, { WristbandScreen });