Feats y Fixs Varios
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
// src/components/ParliamentLayout.tsx
|
||||
import React from 'react';
|
||||
import React, { useLayoutEffect } from 'react';
|
||||
import { handleImageFallback } from './imageFallback';
|
||||
|
||||
// Interfaces (no cambian)
|
||||
interface SeatFillData {
|
||||
@@ -14,7 +15,7 @@ interface SeatFillData {
|
||||
interface ParliamentLayoutProps {
|
||||
seatData: SeatFillData[];
|
||||
size?: number;
|
||||
presidenteBancada: { color: string | null } | null;
|
||||
presidenteBancada?: { color: string | null } | null;
|
||||
}
|
||||
|
||||
const PRESIDENTE_SEAT_INDEX = 91;
|
||||
@@ -24,9 +25,14 @@ export const ParliamentLayout: React.FC<ParliamentLayoutProps> = ({
|
||||
size = 400,
|
||||
presidenteBancada,
|
||||
}) => {
|
||||
// HOOK DE IMAGENES POR DEFECTO
|
||||
useLayoutEffect(() => {
|
||||
// Se ejecuta después de que el componente y el tooltip se hayan renderizado
|
||||
handleImageFallback('.seat-tooltip img', '/default-avatar.png');
|
||||
}, [seatData, presidenteBancada]); // Dependencias: se vuelve a ejecutar si estos datos cambian
|
||||
const uniqueColors = [...new Set(seatData.map(d => d.color))];
|
||||
|
||||
// --- NUEVO ARRAY DE ELEMENTOS ORDENADO ---
|
||||
// --- ARRAY DE ELEMENTOS ORDENADO ---
|
||||
const seatElements = [
|
||||
<circle key="seat-0" id="seat-0" r="12" cy="268.306" cx="202.26" transform="matrix(-0.632908, 0.774227, 0.774227, 0.632908, 0, 0)" />,
|
||||
<circle key="seat-1" id="seat-1" r="12" cy="214.247" cx="223.62" transform="matrix(-0.632908, 0.774227, 0.774227, 0.632908, 0, 0)" />,
|
||||
@@ -135,14 +141,12 @@ export const ParliamentLayout: React.FC<ParliamentLayoutProps> = ({
|
||||
|
||||
const renderedElements = seatElements.map((child, index) => {
|
||||
// --- CASO ESPECIAL: ASIENTO PRESIDENCIAL ---
|
||||
if (index === PRESIDENTE_SEAT_INDEX) {
|
||||
if (presidenteBancada && index === PRESIDENTE_SEAT_INDEX) {
|
||||
return React.cloneElement(child, {
|
||||
fill: presidenteBancada?.color || '#A9A9A9',
|
||||
fill: presidenteBancada.color || '#A9A9A9',
|
||||
stroke: '#000000',
|
||||
strokeWidth: 2,
|
||||
// Le damos un tooltip genérico al presidente
|
||||
'data-tooltip-id': 'seat-tooltip',
|
||||
'data-tooltip-html': `<div class="seat-tooltip"><p>Presidencia de la Cámara</p></div>`
|
||||
'data-tooltip-id': 'seat-tooltip'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user