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.4 KB
Raw Blame
import { ComponentType } from 'react'

import {
    IconBolt,
    IconClock,
    IconCode,
    IconCursorClick,
    IconFlag,
    IconGlobe,
    IconLaptop,
    IconPerson,
} from '@posthog/icons'
import { Link } from '@posthog/lemon-ui'

import { SurveyConditionSummary, SurveyConditionType } from 'scenes/surveys/utils'

export const SURVEY_CONDITION_ICON: Record<SurveyConditionType, ComponentType<{ className?: string }>> = {
    url: IconGlobe,
    selector: IconCode,
    device: IconLaptop,
    events: IconBolt,
    actions: IconCursorClick,
    flag: IconFlag,
    flag_variant: IconFlag,
    targeting: IconPerson,
    wait_period: IconClock,
}

export function SurveyConditionsList({ conditions }: { conditions: SurveyConditionSummary[] }): JSX.Element {
    return (
        <div className="flex flex-col gap-1.5">
            {conditions.map(({ type, label, value, href }) => {
                const Icon = SURVEY_CONDITION_ICON[type]
                return (
                    <div key={type} className="flex items-center gap-2 text-sm">
                        <Icon className="text-muted shrink-0 text-base" />
                        <span className="text-muted whitespace-nowrap">{label}</span>
                        <span className="ml-auto text-right truncate">
                            {href ? <Link to={href}>{value}</Link> : value}
                        </span>
                    </div>
                )
            })}
        </div>
    )
}