'use client' import { PricingTableRowDesktop, PricingTableRowMobile } from '~/components/Pricing/PricingTableRow' import Solutions from '~/data/MainProducts' import { Organization } from '~/data/organizations' import { useSendTelemetryEvent } from '~/lib/telemetry' import { useIsomorphicLayoutEffect } from 'common' import Link from 'next/link' import { useRef, useState } from 'react' import { plans } from 'shared-data/plans' import { pricing } from 'shared-data/pricing' import { Button, cn, Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue, } from 'ui' import UpgradePlan from './UpgradePlan' import { isCrossZoneHref } from '@/lib/cross-zone' const MobileHeader = ({ description, priceDescription, price, plan, showDollarSign = true, from = false, organizations, hasExistingOrganizations, }: { description: string priceDescription: string price: string plan: string showDollarSign?: boolean from?: boolean organizations?: Organization[] hasExistingOrganizations?: boolean }) => { const sendTelemetryEvent = useSendTelemetryEvent() const orgSlug = organizations?.[0]?.slug const selectedPlan = plans.find((p) => p.name === plan)! const isUpgradablePlan = selectedPlan.name === 'Pro' || selectedPlan.name === 'Team' const trackPlanCtaClick = () => sendTelemetryEvent({ action: 'www_pricing_plan_cta_clicked', properties: { plan, showUpgradeText: false, section: 'comparison_table', tableMode: 'mobile', }, ...(orgSlug && { groups: { organization: orgSlug } }), }) return (

{plan}

{from && From} {showDollarSign ? ( {plan !== 'Enterprise' ? '$' : ''} {price} ) : ( {price} )}

{priceDescription}

{description}

{isUpgradablePlan && hasExistingOrganizations ? ( sendTelemetryEvent({ action: 'www_pricing_plan_cta_clicked', properties: { plan, showUpgradeText: true, section: 'comparison_table', tableMode: 'mobile', }, ...(orgSlug && { groups: { organization: orgSlug } }), }) } size="medium" planId={selectedPlan.planId} /> ) : ( )}
) } interface PricingComparisonTableProps { organizations?: Organization[] hasExistingOrganizations?: boolean } const PricingComparisonTable = ({ organizations, hasExistingOrganizations, }: PricingComparisonTableProps) => { const [activeMobilePlan, setActiveMobilePlan] = useState('Free') const sendTelemetryEvent = useSendTelemetryEvent() const orgSlug = organizations?.[0]?.slug const tableRef = useRef(null) const theadRef = useRef(null) useIsomorphicLayoutEffect(() => { const table = tableRef.current const thead = theadRef.current if (!table || !thead) return const observer = new ResizeObserver(() => { const theadTop = parseFloat(getComputedStyle(thead).top) || 0 const categoryTop = Math.floor(theadTop + thead.getBoundingClientRect().height) table.style.setProperty('--pricing-category-top', `${categoryTop}px`) }) observer.observe(thead) return () => observer.disconnect() }, []) return (
{/* */}
{/* Free - Mobile */}
{activeMobilePlan === 'Free' && ( <> )} {activeMobilePlan === 'Pro' && ( <> )} {activeMobilePlan === 'Team' && ( <> )} {activeMobilePlan === 'Enterprise' && ( <> )}
{/* */}
{plans.map((plan) => { const isUpgradablePlan = plan.name === 'Pro' || plan.name === 'Team' const trackPlanCtaClick = () => sendTelemetryEvent({ action: 'www_pricing_plan_cta_clicked', properties: { plan: plan.name, showUpgradeText: false, section: 'comparison_table', tableMode: 'desktop', }, ...(orgSlug && { groups: { organization: orgSlug } }), }) return ( ) })}
Pricing plan comparison
Feature by

{plan.name}

{plan.name !== 'Enterprise' && '$'} {plan.priceMonthly} {['Free', 'Pro', 'Team'].includes(plan.name) && ( {plan.costUnit} )}

{isUpgradablePlan && hasExistingOrganizations ? ( sendTelemetryEvent({ action: 'www_pricing_plan_cta_clicked', properties: { plan: plan.name, showUpgradeText: true, section: 'comparison_table', tableMode: 'desktop', }, ...(orgSlug && { groups: { organization: orgSlug } }), }) } size="tiny" planId={plan.planId} /> ) : ( )}
) } export default PricingComparisonTable