import type { VFC } from 'react'; import { styled, Typography } from '@mui/material'; import { TextCell } from 'component/common/Table/cells/TextCell/TextCell'; import { Highlighter } from 'component/common/Highlighter/Highlighter'; import { useSearchHighlightContext } from 'component/common/Table/SearchHighlightContext/SearchHighlightContext'; import { TooltipLink } from 'component/common/TooltipLink/TooltipLink'; const StyledTag = styled(Typography)(({ theme }) => ({ fontSize: theme.fontSizes.smallerBody, })); interface IArrayFieldCellProps { row: T; field: keyof T; singularLabel: string; pluralLabel?: string; } export const StringArrayCell: VFC> = ({ row, field, singularLabel, pluralLabel, }) => { const { searchQuery } = useSearchHighlightContext(); const fieldValue = row[field]; if (!Array.isArray(fieldValue) || fieldValue.length === 0) return ; const labelForMultiple = pluralLabel || `${singularLabel}s`; return ( 0 && fieldValue.some((item: string | null) => item?.toLowerCase().includes(searchQuery.toLowerCase()), ) } tooltip={ <> {fieldValue.map((item: string) => ( {item} ))} } > {fieldValue.length === 1 ? `1 ${singularLabel}` : `${fieldValue.length} ${labelForMultiple}`} ); };