// ===== SCREENS: Weather, Forum, Coach (AI), Score, Commute ===== // ---------- Weather & Roads ---------- function WeatherScreen({ t, go }) { const w = weather_now; return (
{w.loc}
{w.temp}°
{w.cond}
Feels like {w.feels}°
{w.icon}
{[['Humidity', w.humidity + '%'], ['Wind', w.wind + ' km/h'], ['Visibility', w.visibility]].map(([l, v]) => (
{v}
{l}
))}
⚠️
Heavy rain advisory — roads are slippery. Increase following distance and reduce speed by 20%.
5-Day Forecast {weather_data.map((d, i) => (
{d.day} {d.icon}
Road: {d.road}
{d.hi}° {d.lo}°
{i < weather_data.length - 1 &&
}
))}
Road Surface Ratings
{road_surfaces.map(r => (
{r.road}
{r.cond}
{[1, 2, 3, 4, 5].map(n => ( ))}
))}
); } // ---------- Community Forum ---------- function ForumScreen({ t, go }) { const [posts, setPosts] = useState(forum_posts); const toggle = (id) => setPosts(ps => ps.map(p => p.id === id ? { ...p, liked: !p.liked, likes: p.likes + (p.liked ? -1 : 1) } : p)); return (
{}}>
🚗
Share a road update or tip…
{posts.map(p => (
{p.avatar}
{p.user}
{p.region} · {p.time}

{p.text}

))}
); } // ---------- AI Driving Coach ---------- function CoachScreen({ t, go }) { const [messages, setMessages] = useState([ { role: 'assistant', text: "Hi! I'm your NRSA AI Driving Coach 🚗 Ask me anything about safe driving, road rules, or handling tricky situations." }, ]); const [input, setInput] = useState(''); const [busy, setBusy] = useState(false); const scrollRef = useRef(null); useEffect(() => { if (scrollRef.current) scrollRef.current.scrollTop = scrollRef.current.scrollHeight; }, [messages, busy]); const send = async (text) => { const msg = (text || input).trim(); if (!msg || busy) return; setInput(''); setMessages(m => [...m, { role: 'user', text: msg }]); setBusy(true); try { const history = [...messages, { role: 'user', text: msg }] .map(m => `${m.role === 'user' ? 'Driver' : 'Coach'}: ${m.text}`).join('\n'); const prompt = `You are an expert NRSA AI Driving Coach. Give concise, practical road safety advice. Be encouraging, direct, and safety-focused. Keep responses under 120 words. Use 1-2 relevant emojis.\n\nConversation so far:\n${history}\n\nReply as the Coach:`; const reply = await window.claude.complete(prompt); setMessages(m => [...m, { role: 'assistant', text: (reply || '').trim() || "Stay safe out there! Could you rephrase that?" }]); } catch (e) { setMessages(m => [...m, { role: 'assistant', text: "I'm having trouble connecting right now. Remember: stay alert, keep your distance, and buckle up! 🚗" }]); } setBusy(false); }; return (
{messages.map((m, i) => (
{m.role === 'assistant' &&
🤖
}
{m.text}
))} {busy && (
🤖
{[0, 1, 2].map(i => )}
)}
{/* Quick prompts */}
{coach_prompts.map(q => send(q)} color={t.mid}>{q})}
{/* Composer */}
setInput(e.target.value)} onKeyDown={e => e.key === 'Enter' && send()} placeholder="Ask your coach…" style={{ flex: 1, border: `1px solid ${t.border}`, background: t.inputBg, color: t.text, borderRadius: 999, padding: '12px 16px', outline: 'none', fontWeight: 500, }} />
); } // ---------- Safety Score ---------- function ScoreScreen({ t, go }) { return (
87 SAFETY SCORE Excellent Driver · Top 5%
+3 points this week. Keep braking smoothly to reach 90!
Score Breakdown {score_breakdown.map((s, i) => (
{s.label} {s.value}
))}
Regional Leaderboard {leaderboard.map((l, i) => (
{l.rank <= 3 ? ['🥇','🥈','🥉'][l.rank-1] : l.rank} {l.avatar}
{l.name}{l.you && YOU}
{l.region}
{l.score}
{i < leaderboard.length - 1 &&
}
))}
); } // ---------- Commute Tracker ---------- function CommuteScreen({ t, go }) { const [heatmap, setHeatmap] = useState(false); return (
go('Buddy')} className="no-select" style={{ background: 'none', border: 'none', color: t.mid, fontSize: 12.5, fontWeight: 700 }}>+ Add Route}>Saved Routes
{commute_routes.map(r => (
{r.name}
{r.from} → {r.to}
{r.traffic}
Distance
{r.dist}
Est. Time
{r.eta}
Start Trip Alert
))}
); } Object.assign(window, { WeatherScreen, ForumScreen, CoachScreen, ScoreScreen, CommuteScreen });