Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.
TypeScript analyticsaudience-segmentationchartscohort-analysisgoogle-analyticsproduct-analyticsstatisticsuser-journeyweb-analytics
import { Column, Text } from '@umami/react-zen';
import { memo } from 'react';
import type { BoardComponentConfig } from '@/lib/types';
import { getComponentDefinition } from '../boardComponentRegistry';
function BoardComponentRendererComponent({
config,
websiteId,
entityType,
isPreview,
}: {
config: BoardComponentConfig;
websiteId?: string;
entityType?: string;
isPreview?: boolean;
}) {
const definition = getComponentDefinition(config.type);
if (!definition) {
return (
<Column alignItems="center" justifyContent="center" width="100%" height="100%">
<Text color="muted">Unknown component: {config.type}</Text>
</Column>
);
}
const Component =
(entityType && definition.componentByEntityType?.[entityType]) || definition.component;
if (!websiteId && definition.requiresWebsite !== false) {
return (
<Column alignItems="center" justifyContent="center" width="100%" height="100%">
<Text color="muted">Select a website</Text>
</Column>
);
}
return (
<Component
{...(websiteId ? { websiteId } : {})}
{...(isPreview ? { isPreview } : {})}
{...config.props}
/>
);
}
export const BoardComponentRenderer = memo(
BoardComponentRendererComponent,
(prevProps, nextProps) =>
prevProps.websiteId === nextProps.websiteId &&
prevProps.entityType === nextProps.entityType &&
prevProps.isPreview === nextProps.isPreview &&
prevProps.config === nextProps.config,
);
BoardComponentRenderer.displayName = 'BoardComponentRenderer';