import { Fragment } from 'react'; import { Panel } from '@/components/ui/panel'; import { formatScaledNumber } from '@/lib/format'; import type { CompanyAnalysis } from '@/lib/types'; type CompanyProfileFactsTableProps = { analysis: CompanyAnalysis; }; function factValue(value: string | null | undefined) { return value && value.trim().length > 0 ? value : 'n/a'; } function employeeCountLabel(value: number | null) { return value === null ? 'n/a' : formatScaledNumber(value, { maximumFractionDigits: 1 }); } export function CompanyProfileFactsTable(props: CompanyProfileFactsTableProps) { const items = [ { label: 'Exchange', value: factValue(props.analysis.companyProfile.exchange) }, { label: 'Industry', value: factValue(props.analysis.companyProfile.industry ?? props.analysis.company.sector) }, { label: 'Country / state', value: factValue(props.analysis.companyProfile.country) }, { label: 'Fiscal year end', value: factValue(props.analysis.companyProfile.fiscalYearEnd) }, { label: 'Employees', value: employeeCountLabel(props.analysis.companyProfile.employeeCount) }, { label: 'Website', value: factValue(props.analysis.companyProfile.website) }, { label: 'Category', value: factValue(props.analysis.company.category) }, { label: 'CIK', value: factValue(props.analysis.company.cik) } ]; const rows = Array.from({ length: Math.ceil(items.length / 2) }, (_, index) => items.slice(index * 2, index * 2 + 2)); return (
{rows.map((row) => ( item.label).join('-')} className="border-t border-[color:var(--line-weak)]"> {row.map((item) => ( ))} {row.length === 1 ? ( <> ))}
{item.label} {item.label === 'Website' && item.value !== 'n/a' ? ( {item.value} ) : ( item.value )} ) : null}
); }