/* Admin → Alerts: emergency-alert composer + sent history. Posts the red banner parents see at the top of the parent-app Home. */ function AlertsScreen() { const TYPES = [ { id:'closure', label:'Closure', icon:'snowflake', tint:'var(--info-100)', ic:'var(--info-500)' }, { id:'dismissal', label:'Early Dismissal',icon:'clock', tint:'var(--gold-100)', ic:'var(--gold-600)' }, { id:'safety', label:'Safety', icon:'shield-alert', tint:'var(--danger-100)', ic:'var(--danger-500)' }, { id:'weather', label:'Weather', icon:'cloud-lightning',tint:'var(--warning-100)',ic:'var(--warning-600)' }, ]; const AUD = ['All families', 'Grade 6', 'Grade 7', 'Bus riders', 'Staff only']; const CHAN = [ ['push','Push',true], ['sms','SMS',true], ['email','Email',false] ]; const [type, setType] = React.useState('dismissal'); const [title, setTitle] = React.useState('Early dismissal today at 1:00 PM'); const [body, setBody] = React.useState('Due to a forecasted storm, all students will be dismissed at 1:00 PM. Buses will run on the early schedule. Please confirm your pickup plan.'); const [aud, setAud] = React.useState('All families'); const [chan, setChan] = React.useState({ push:true, sms:true, email:false }); const [sent, setSent] = React.useState([ { t:'Water main repair — normal hours resume', type:'safety', when:'May 24 · 7:10 AM', reach:'1,248 families' }, { t:'Late start Wednesday due to fog', type:'weather', when:'May 18 · 6:02 AM', reach:'1,248 families' }, ]); const send = () => { if (!title.trim()) { jlToast('Add a headline first', { icon:'triangle-alert', color:'#E5484D' }); return; } setSent(s => [{ t:title, type, when:'Just now', reach: aud }, ...s]); jlToast('Emergency alert sent to ' + aud, { icon:'siren', color:'#E5484D' }); }; const tObj = TYPES.find(t=>t.id===type); return (