| 
									
										
										
										
											2025-08-14 15:27:45 -03:00
										 |  |  | // src/App.tsx
 | 
					
						
							| 
									
										
										
										
											2025-08-15 17:31:51 -03:00
										 |  |  | import { useState, useEffect } from 'react'; | 
					
						
							| 
									
										
										
										
											2025-08-14 15:27:45 -03:00
										 |  |  | import { MunicipioWidget } from './components/MunicipioWidget'; | 
					
						
							|  |  |  | import { MunicipioSelector } from './components/MunicipioSelector'; | 
					
						
							| 
									
										
										
										
											2025-08-15 17:31:51 -03:00
										 |  |  | import { getMunicipios, type MunicipioSimple } from './services/api'; | 
					
						
							| 
									
										
										
										
											2025-08-14 15:27:45 -03:00
										 |  |  | import './App.css'; | 
					
						
							| 
									
										
										
										
											2025-08-15 17:31:51 -03:00
										 |  |  | import { ResumenProvincialWidget } from './components/ResumenProvincialWidget'; | 
					
						
							|  |  |  | import { BancasWidget } from './components/BancasWidget'; | 
					
						
							|  |  |  | import { TelegramasView } from './components/TelegramasView'; | 
					
						
							|  |  |  | import { MapaD3Widget } from './components/MapaD3Widget'; | 
					
						
							| 
									
										
										
										
											2025-08-14 15:27:45 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | function App() { | 
					
						
							|  |  |  |   const [selectedMunicipioId, setSelectedMunicipioId] = useState<string | null>(null); | 
					
						
							| 
									
										
										
										
											2025-08-15 17:31:51 -03:00
										 |  |  |   const [listaMunicipios, setListaMunicipios] = useState<MunicipioSimple[]>([]); | 
					
						
							|  |  |  |   const [loading, setLoading] = useState(true); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   useEffect(() => { | 
					
						
							|  |  |  |     getMunicipios() | 
					
						
							|  |  |  |       .then(setListaMunicipios) | 
					
						
							|  |  |  |       .catch(err => console.error("Error al cargar la lista de municipios", err)) | 
					
						
							|  |  |  |       .finally(() => setLoading(false)); | 
					
						
							|  |  |  |   }, []); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (loading) return <h1>Cargando datos iniciales...</h1>; | 
					
						
							| 
									
										
										
										
											2025-08-14 15:27:45 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  |   return ( | 
					
						
							|  |  |  |     <> | 
					
						
							|  |  |  |       <h1>Elecciones 2025 - Resultados en Vivo</h1> | 
					
						
							| 
									
										
										
										
											2025-08-15 17:31:51 -03:00
										 |  |  |       <section> | 
					
						
							|  |  |  |         <ResumenProvincialWidget distritoId="02" /> | 
					
						
							|  |  |  |       </section> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       <hr /> | 
					
						
							|  |  |  |        | 
					
						
							|  |  |  |       <section style={{ display: 'grid', gridTemplateColumns: '2fr 1fr', gap: '20px' }}> | 
					
						
							|  |  |  |         <div> | 
					
						
							|  |  |  |           <h2>Mapa de Resultados</h2> | 
					
						
							|  |  |  |           <MapaD3Widget | 
					
						
							|  |  |  |             municipios={listaMunicipios}  | 
					
						
							|  |  |  |             onMunicipioClick={setSelectedMunicipioId}  | 
					
						
							|  |  |  |           /> | 
					
						
							|  |  |  |         </div> | 
					
						
							|  |  |  |         <div> | 
					
						
							|  |  |  |           <h2>Consulta por Municipio</h2> | 
					
						
							|  |  |  |           <MunicipioSelector  | 
					
						
							|  |  |  |             municipios={listaMunicipios}  | 
					
						
							|  |  |  |             onMunicipioChange={setSelectedMunicipioId}  | 
					
						
							|  |  |  |           /> | 
					
						
							|  |  |  |           {selectedMunicipioId && ( | 
					
						
							|  |  |  |             <div style={{ marginTop: '20px' }}> | 
					
						
							|  |  |  |               <MunicipioWidget municipioId={selectedMunicipioId} /> | 
					
						
							|  |  |  |             </div> | 
					
						
							|  |  |  |           )} | 
					
						
							|  |  |  |         </div> | 
					
						
							|  |  |  |       </section> | 
					
						
							| 
									
										
										
										
											2025-08-14 15:27:45 -03:00
										 |  |  |        | 
					
						
							| 
									
										
										
										
											2025-08-15 17:31:51 -03:00
										 |  |  |       <section> | 
					
						
							|  |  |  |         {/* Usamos el ID del distrito de Bs As ("02") */} | 
					
						
							|  |  |  |         <ResumenProvincialWidget distritoId="02" /> | 
					
						
							|  |  |  |       </section> | 
					
						
							| 
									
										
										
										
											2025-08-14 15:27:45 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  |       <hr /> | 
					
						
							|  |  |  |        | 
					
						
							| 
									
										
										
										
											2025-08-15 17:31:51 -03:00
										 |  |  |       <section> | 
					
						
							|  |  |  |         <h2>Consulta por Municipio</h2> | 
					
						
							|  |  |  |         <MunicipioSelector onMunicipioChange={setSelectedMunicipioId} municipios={[]} /> | 
					
						
							|  |  |  |         {selectedMunicipioId && ( | 
					
						
							|  |  |  |           <div style={{ marginTop: '20px' }}> | 
					
						
							|  |  |  |             <MunicipioWidget municipioId={selectedMunicipioId} /> | 
					
						
							|  |  |  |           </div> | 
					
						
							|  |  |  |         )} | 
					
						
							|  |  |  |       </section> | 
					
						
							|  |  |  |        | 
					
						
							|  |  |  |       <section> | 
					
						
							|  |  |  |         <h2>Proyección de Bancas</h2> | 
					
						
							|  |  |  |         {/* Usamos el ID de la sección de La Plata ("0001") como ejemplo */} | 
					
						
							|  |  |  |         <BancasWidget seccionId="0001" />  | 
					
						
							|  |  |  |       </section> | 
					
						
							| 
									
										
										
										
											2025-08-14 15:27:45 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-15 17:31:51 -03:00
										 |  |  |       <hr /> | 
					
						
							|  |  |  |        | 
					
						
							|  |  |  |       <section> | 
					
						
							|  |  |  |         <h2>Consulta de Resultados por Municipio</h2> | 
					
						
							|  |  |  |         <MunicipioSelector onMunicipioChange={setSelectedMunicipioId} municipios={[]} /> | 
					
						
							|  |  |  |         {selectedMunicipioId && ( | 
					
						
							|  |  |  |           <div style={{ marginTop: '20px' }}> | 
					
						
							|  |  |  |             <MunicipioWidget municipioId={selectedMunicipioId} /> | 
					
						
							|  |  |  |           </div> | 
					
						
							|  |  |  |         )} | 
					
						
							|  |  |  |       </section> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       <hr /> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       <section> | 
					
						
							|  |  |  |         <h2>Explorador de Telegramas</h2> | 
					
						
							|  |  |  |         <TelegramasView /> | 
					
						
							|  |  |  |       </section> | 
					
						
							| 
									
										
										
										
											2025-08-14 15:27:45 -03:00
										 |  |  |     </> | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export default App; |