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.2 KB
Raw Blame
import { IconCheckCircle, IconCircleDashed } from '@posthog/icons'
import { Badge, Spinner } from '@posthog/quill'

import { ProductTour, ProgressStatus } from '~/types'

import { getProductTourStatus } from '../productToursLogic'

const STATUS_CONFIG: Record<ProgressStatus, { label: string; variant: 'success' | 'default' | 'completed' }> = {
    [ProgressStatus.Draft]: { label: 'Draft', variant: 'default' },
    [ProgressStatus.Running]: { label: 'Running', variant: 'success' },
    [ProgressStatus.Complete]: { label: 'Complete', variant: 'completed' },
}

export function QuillProductTourStatusBadge({
    tour,
    isEditing,
    draftSaveStatus,
}: {
    tour: ProductTour
    isEditing?: boolean
    draftSaveStatus?: 'unsaved' | 'saving' | 'saved' | null
}): JSX.Element {
    const config = STATUS_CONFIG[getProductTourStatus(tour)]
    return (
        <Badge variant={config.variant}>
            {isEditing && (
                <>
                    {draftSaveStatus === 'unsaved' && <IconCircleDashed />}
                    {draftSaveStatus === 'saving' && <Spinner />}
                    {draftSaveStatus === 'saved' && <IconCheckCircle className="text-success" />}
                </>
            )}
            {config.label}
        </Badge>
    )
}