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.

2.8 KB
Raw Blame
import { useActions, useValues } from 'kea'

import * as remoteWork from '@posthog/brand/hoggies/png/remote-work'
import { LemonButton, LemonModal } from '@posthog/lemon-ui'

import { pngHoggie } from 'lib/brand/hoggies'
import { PayGateMini } from 'lib/components/PayGateMini/PayGateMini'

import { upgradeModalLogic } from './upgradeModalLogic'

const HedgehogRemoteWork = pngHoggie(remoteWork)

export function UpgradeModal(): JSX.Element {
    const {
        upgradeModalFeatureKey,
        upgradeModalFeatureUsage,
        upgradeModalIsGrandfathered,
        projectLimit,
        shouldShowPlatformAddonMessage,
    } = useValues(upgradeModalLogic)
    const { hideUpgradeModal } = useActions(upgradeModalLogic)

    if (!upgradeModalFeatureKey) {
        return <></>
    }

    if (shouldShowPlatformAddonMessage) {
        return (
            <LemonModal onClose={hideUpgradeModal} isOpen={!!upgradeModalFeatureKey} zIndex="1169">
                <div className="max-w-2xl mt-8">
                    <div className="PayGateMini rounded flex flex-col items-center p-4 text-center bg-primary border border-primary">
                        <div className="mb-3 max-w-72">
                            <HedgehogRemoteWork />
                        </div>
                        <p className="max-w-140 mb-4">
                            You've reached your usage limit for <b>projects</b>. To create more than{' '}
                            <b>{projectLimit} projects</b>, you need to subscribe to the Boost, Scale, or Enterprise
                            plan.
                        </p>
                        <LemonButton
                            type="primary"
                            center
                            to="/organization/billing?products=platform_and_support"
                            onClick={hideUpgradeModal}
                        >
                            Upgrade now
                        </LemonButton>
                    </div>
                </div>
            </LemonModal>
        )
    }

    return (
        <LemonModal onClose={hideUpgradeModal} isOpen={!!upgradeModalFeatureKey} zIndex="1169">
            <div className="max-w-2xl">
                <PayGateMini
                    feature={upgradeModalFeatureKey}
                    featureDetail="upgrade-modal"
                    currentUsage={upgradeModalFeatureUsage ?? undefined}
                    isGrandfathered={upgradeModalIsGrandfathered ?? undefined}
                    background={false}
                    handleSubmit={hideUpgradeModal}
                >
                    <div className="pr-7">
                        You should have access to this feature already. If you are still seeing this modal, please let
                        us know 🙂
                    </div>
                </PayGateMini>
            </div>
        </LemonModal>
    )
}