/* 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 (
You can switch anytime from the dashboard. MVP has Pharma + Rare Earths live.