import React from 'react'; import { Organization } from '@/types.ts'; import { useTranslation } from '@/hooks/useI18n.tsx'; import { useDirectSymbiosis } from '@/hooks/useDirectSymbiosis.ts'; import MatchCard from '@/components/organization/MatchCard.tsx'; import { Grid, Stack } from '@/components/ui/layout'; interface DirectMatchesDisplayProps { organization: Organization; onSelectOrg: (org: Organization) => void; } const DirectMatchesDisplay = ({ organization, onSelectOrg }: DirectMatchesDisplayProps) => { const { t } = useTranslation(); const { providers, consumers } = useDirectSymbiosis(organization); // Ensure arrays and check lengths safely const safeProviders = Array.isArray(providers) ? providers : []; const safeConsumers = Array.isArray(consumers) ? consumers : []; const hasMatches = safeProviders.length > 0 || safeConsumers.length > 0; if (!hasMatches) { return (

{t('organizationPage.directSymbiosis.noMatches')}

); } return (

{t('organizationPage.directSymbiosis.fulfillsNeeds')}

{safeProviders.length > 0 ? ( safeProviders.map((match, index) => ( )) ) : (

{t('organizationPage.directSymbiosis.noMatches')}

)}

{t('organizationPage.directSymbiosis.consumesOffers')}

{safeConsumers.length > 0 ? ( safeConsumers.map((match, index) => ( )) ) : (

{t('organizationPage.directSymbiosis.noMatches')}

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