/* Sector selection — Screen 1 */ import { useState, useEffect } from 'react'; import { useNavigate } from 'react-router-dom'; import { api } from '../api/client'; export default function SectorSelect({ onSelect }) { const navigate = useNavigate(); const [sectors, setSectors] = useState([]); const [selected, setSelected] = useState(new Set(['pharma', 'rare_earth'])); const [loading, setLoading] = useState(true); useEffect(() => { api.getSectors() .then(s => setSectors(s)) .catch(() => { // Fallback static list setSectors([ { id: 'pharma', name: 'Pharma', icon: '💊', status: 'active', input_count: 20, description: 'API & essential medicines', active_shocks: 0, criticality_avg: 0.78 }, { id: 'rare_earth', name: 'Rare Earths', icon: '⛏️', status: 'active', input_count: 8, description: 'Critical minerals for EV & defence', active_shocks: 0, criticality_avg: 0.83 }, { id: 'semiconductor', name: 'Semiconductor', icon: '💻', status: 'phase2', input_count: 0, description: 'Chip substrates, fab chemicals', active_shocks: 0, criticality_avg: 0 }, { id: 'solar', name: 'Solar Energy', icon: '☀️', status: 'phase2', input_count: 0, description: 'Polysilicon, solar wafers', active_shocks: 0, criticality_avg: 0 }, { id: 'ev_battery', name: 'EV Battery', icon: '🔋', status: 'phase2', input_count: 0, description: 'Lithium, cobalt, cathode materials', active_shocks: 0, criticality_avg: 0 }, { id: 'defence', name: 'Defence Inputs', icon: '🛡️', status: 'phase2', input_count: 0, description: 'Titanium, tungsten, specialty alloys', active_shocks: 0, criticality_avg: 0 }, ]); }) .finally(() => setLoading(false)); }, []); function toggle(id, isActive) { if (!isActive) return; setSelected(prev => { const next = new Set(prev); next.has(id) ? next.delete(id) : next.add(id); return next; }); } function handleContinue() { const arr = Array.from(selected); onSelect(arr); navigate('/dashboard'); } return (
{/* Back */}

Select Sectors to Monitor

You can switch anytime from the dashboard. MVP has Pharma + Rare Earths live.

{loading ? (
{[1,2,3,4,5,6].map(i =>
)}
) : (
{sectors.map(s => { const isActive = s.status === 'active'; const isSel = selected.has(s.id); return (
toggle(s.id, isActive)} style={{ background: isSel ? 'rgba(79,156,249,0.08)' : 'var(--surface)', border: `1px solid ${isSel ? 'rgba(79,156,249,0.4)' : 'var(--border)'}`, borderRadius: 14, padding: '22px 20px', cursor: isActive ? 'pointer' : 'default', opacity: isActive ? 1 : 0.45, transition: 'all 0.2s', position: 'relative', transform: isSel ? 'translateY(-2px)' : 'none', boxShadow: isSel ? '0 0 20px rgba(79,156,249,0.15)' : 'none', }} > {isSel && (
✓
)} {!isActive && (
Phase 2
)}
{s.icon}
{s.name}
{s.description}
{isActive && (
{s.input_count} inputs {s.active_shocks > 0 && ( {s.active_shocks} shocks )}
)}
); })}
)}
); }