import React, { useCallback } from 'react'; import { getSectorDisplay } from '@/constants.tsx'; import { mapBackendSectorToTranslationKey } from '@/lib/sector-mapper.ts'; import { getOrganizationSubtypeLabel } from '@/schemas/organizationSubtype.ts'; import { Organization } from '@/types.ts'; import { BadgeCheck } from 'lucide-react'; import Badge from '@/components/ui/Badge.tsx'; import HighlightedText from '@/components/ui/HighlightedText.tsx'; interface OrganizationListItemProps { org: Organization; isSelected: boolean; onSelectOrg: (org: Organization) => void; onHoverOrg: (id: string | null) => void; searchTerm: string; } const OrganizationListItem: React.FC = React.memo( ({ org, isSelected, onSelectOrg, onHoverOrg, searchTerm }) => { const sectorDisplay = getSectorDisplay(org.Sector); const baseClasses = 'group rounded-xl cursor-pointer transition-all duration-300 ease-out border border-border/50 shadow-sm hover:shadow-md'; const stateClasses = isSelected ? 'bg-primary/10 border-primary shadow-md ring-2 ring-primary/20' : 'bg-card/50 hover:bg-card hover:border-border'; const handleClick = useCallback(() => onSelectOrg(org), [onSelectOrg, org]); const handleMouseEnter = useCallback(() => onHoverOrg(org.ID), [onHoverOrg, org.ID]); const handleMouseLeave = useCallback(() => onHoverOrg(null), [onHoverOrg]); return (
(e.key === 'Enter' || e.key === ' ') && onSelectOrg(org)} >
{/* Enhanced Icon Container */}
{org.LogoURL ? ( {`${org.Name} { (e.target as HTMLImageElement).style.display = 'none'; }} /> ) : org.Sector ? (
{React.cloneElement(sectorDisplay.icon, { className: 'h-7 w-7 text-white drop-shadow-sm', })}
) : (
{org.Name.charAt(0).toUpperCase()}
)}
{/* Content */}
{/* Name and Verified Badge */}

{org.Verified && ( )}
{/* Subtype Badge */} {org.Subtype && (
{getOrganizationSubtypeLabel(org.Subtype)}
)} {/* Description */} {org.Description && (

)}
); } ); OrganizationListItem.displayName = 'OrganizationListItem'; export default OrganizationListItem;