import React, { useCallback, useMemo, useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { useTranslation } from '@/hooks/useI18n.tsx'; import type { HistoricalLandmark, Organization, SymbiosisMatch, WebIntelligenceResult, } from '@/types.ts'; import MatchesList from '@/components/matches/MatchesList.tsx'; import ResourceFlowList from '@/components/resource-flow/ResourceFlowList.tsx'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/Card.tsx'; import HistoricalContextCard from '@/components/organization/HistoricalContextCard.tsx'; import { NetworkGraph } from '@/components/organization/NetworkGraph.tsx'; import OrganizationDetailsGrid from '@/components/organization/OrganizationDetailsGrid.tsx'; import OrganizationHeader from '@/components/organization/OrganizationHeader.tsx'; import PartnershipHub from '@/components/organization/PartnershipHub.tsx'; interface SymbiosisState { symbiosisResult: SymbiosisMatch[] | null; isAnalyzing: boolean; analysisError: string | null; webIntelResult: WebIntelligenceResult | null; isFetchingWebIntel: boolean; webIntelError: string | null; } interface OrganizationContentProps { organization: Organization; relatedLandmark: HistoricalLandmark | null; symbiosisState: SymbiosisState; handleUpdateOrganization: (updatedOrg: Organization) => void; handleMapNavigation: () => void; handleSelectOrg: (org: Organization) => void; handleAnalyzeSymbiosis: () => void; handleFetchWebIntelligence: () => void; } const OrganizationContent: React.FC = ({ organization, relatedLandmark, symbiosisState, handleUpdateOrganization, handleMapNavigation, handleSelectOrg, handleAnalyzeSymbiosis, handleFetchWebIntelligence, }) => { const { t } = useTranslation(); const navigate = useNavigate(); const [selectedResourceId, setSelectedResourceId] = useState(null); const handleViewMatches = useCallback((resourceId: string) => { setSelectedResourceId(resourceId); }, []); const handleCloseMatches = useCallback(() => { setSelectedResourceId(null); }, []); const handleNetworkNodeClick = useCallback( (nodeId: string, nodeType: string) => { if (nodeType === 'Organization' && nodeId !== organization.ID) { // Navigate to the clicked organization navigate(`/organization/${nodeId}`); } // For Sites, ResourceFlows, etc., we could add more navigation logic }, [navigate, organization.ID] ); // Memoize the ai object to prevent PartnershipHub re-renders const aiProps = useMemo( () => ({ symbiosisResult: symbiosisState.symbiosisResult, isAnalyzing: symbiosisState.isAnalyzing, analysisError: symbiosisState.analysisError, handleAnalyzeSymbiosis, webIntelResult: symbiosisState.webIntelResult, isFetchingWebIntel: symbiosisState.isFetchingWebIntel, webIntelError: symbiosisState.webIntelError, handleFetchWebIntelligence, }), [ symbiosisState.symbiosisResult, symbiosisState.isAnalyzing, symbiosisState.analysisError, handleAnalyzeSymbiosis, symbiosisState.webIntelResult, symbiosisState.isFetchingWebIntel, symbiosisState.webIntelError, handleFetchWebIntelligence, ] ); return (
{relatedLandmark && ( )} {t('organizationPage.description')}

{organization.Description}

{/* Network Graph - Visual representation of connections */} {selectedResourceId && (

{t('matches.title')}

)}
); }; export default React.memo(OrganizationContent);