Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

1.3 KB
Raw Blame
import { useValues } from 'kea'

import { IconCheckCircle } from '@posthog/icons'
import { LemonTag } from '@posthog/lemon-ui'

import type { MessagingSetupTabKey } from '../messagingTabs'
import { workflowsSetupGuideLogic } from './workflowsSetupGuideLogic'

/** The setup state of one Messaging menu item: done, or what is still open. */
export function MessagingSetupMenuStatus({ tab }: { tab: MessagingSetupTabKey }): JSX.Element | null {
    const { steps } = useValues(workflowsSetupGuideLogic)

    if (!steps) {
        return null
    }
    const isDone = (key: string): boolean => steps.some((step) => step.key === key && step.done)

    if (tab === 'channels') {
        const channelsDone = steps.some((step) => step.key === 'domain') ? isDone('domain') : isDone('channel')
        if (channelsDone) {
            return <IconCheckCircle className="text-success" />
        }
        return (
            <LemonTag size="small" type="warning">
                {isDone('channel') ? 'Verify' : 'Set up'}
            </LemonTag>
        )
    }
    if (tab === 'opt-outs') {
        return isDone('opt-outs') ? (
            <IconCheckCircle className="text-success" />
        ) : (
            <LemonTag size="small" type="warning">
                Set up
            </LemonTag>
        )
    }
    return null
}