import clsx from 'clsx'; import { Lightbulb, X } from 'lucide-react'; import { ReactNode, useMemo } from 'react'; import sanitize from 'sanitize-html'; import { useStore } from 'zustand'; import { Button } from '@@/buttons'; import { insightStore } from './insights-store'; export type Props = { header: string; content: ReactNode; setHtmlContent?: boolean; insightCloseId?: string; // set if you want to be able to close the box and not show it again }; export function InsightsBox({ header, content, setHtmlContent, insightCloseId, }: Props) { // allow to close the box and not show it again in local storage with zustand const { addInsightIDClosed, isClosed } = useStore(insightStore); const isInsightClosed = isClosed(insightCloseId); // allow angular views to set html messages for the insights box const htmlContent = useMemo(() => { if (setHtmlContent && typeof content === 'string') { // eslint-disable-next-line react/no-danger return
; } return null; }, [setHtmlContent, content]); if (isInsightClosed) { return null; } return (

{header}

{htmlContent || content}
{insightCloseId && (
); }