import { forwardRef, useRef } from 'react'; import { z } from 'zod'; import { ReportSchema } from '@ballerine/common'; import { ContentTooltip, useReportSections } from '@ballerine/ui'; import { SectionObserver } from '@/common/components/organisms/SectionObserver/SectionObserver'; type BusinessReportProps = { report: z.infer; disableSectionObserver?: boolean; }; export const BusinessReport = forwardRef( ({ report, disableSectionObserver = false }, ref) => { const { sections } = useReportSections(report); const sectionRefs = useRef<{ [key: string]: HTMLDivElement | null }>({}); return (
{sections.map(section => { const titleContent = (
{section.Icon && } {section.title}
); return (
(sectionRefs.current[section.id] = el)} className="min-h-[100px]" // Minimum height helps with detection > {section.description ? ( {titleContent} ) : ( <>{titleContent} )} {section.Component}
); })}
{!disableSectionObserver && ( )}
); }, ); BusinessReport.displayName = 'BusinessReport';