import { type FeatureGroupSlug } from '@automattic/calypso-products'; import { AddOns } from '@automattic/data-stores'; import { useMemo } from '@wordpress/element'; import clsx from 'clsx'; import { useTranslate } from 'i18n-calypso'; import { usePlansGridContext } from '../../grid-context'; import { DataResponse, GridPlan, PlanActionOverrides } from '../../types'; import { StickyContainer } from '../sticky-container'; import BillingTimeframes from './billing-timeframes'; import EnterpriseFeatures from './enterprise-features'; import PlanFeaturesList from './plan-features-list'; import PlanHeaders from './plan-headers'; import PlanLogos from './plan-logos'; import PlanPrices from './plan-prices'; import PlanTagline from './plan-tagline'; import PreviousFeaturesIncludedTitle from './previous-features-included-title'; import TopButtons from './top-buttons'; type TableProps = { currentSitePlanSlug?: string | null; generatedWPComSubdomain: DataResponse< { domain_name: string } >; gridPlanForSpotlight?: GridPlan; hideUnavailableFeatures?: boolean; isCustomDomainAllowedOnFreePlan: boolean; isInSignup: boolean; onStorageAddOnClick?: ( addOnSlug: AddOns.StorageAddOnSlug ) => void; paidDomainName?: string; planActionOverrides?: PlanActionOverrides; renderedGridPlans: GridPlan[]; selectedFeature?: string; showRefundPeriod?: boolean; showUpgradeableStorage: boolean; stickyRowOffset: number; options?: { isTableCell?: boolean; }; }; const Table = ( { currentSitePlanSlug, generatedWPComSubdomain, gridPlanForSpotlight, hideUnavailableFeatures, isCustomDomainAllowedOnFreePlan, isInSignup, onStorageAddOnClick, paidDomainName, planActionOverrides, renderedGridPlans, selectedFeature, showRefundPeriod, showUpgradeableStorage, stickyRowOffset, }: TableProps ) => { const translate = useTranslate(); const { featureGroupMap, enableCategorisedFeatures, enableLogosOnlyForEnterprisePlan, enableReducedFeatureGroupSpacing, } = usePlansGridContext(); const featureGroups = useMemo( () => Object.keys( featureGroupMap ) as FeatureGroupSlug[], [ featureGroupMap ] ); // Do not render the spotlight plan if it exists const gridPlansWithoutSpotlight = useMemo( () => ! gridPlanForSpotlight ? renderedGridPlans : renderedGridPlans.filter( ( { planSlug } ) => gridPlanForSpotlight.planSlug !== planSlug ), [ renderedGridPlans, gridPlanForSpotlight ] ); // Search for a plan with a highlight label. Some margin is applied in the stylesheet to cover the badges/labels const hasHighlightedPlan = gridPlansWithoutSpotlight.some( ( { highlightLabel } ) => !! highlightLabel ); const tableClasses = clsx( 'plan-features-2023-grid__table', `has-${ gridPlansWithoutSpotlight.length }-cols`, { 'has-highlighted-plan': hasHighlightedPlan, } ); return ( { ( isStuck: boolean ) => ( ) } { ! enableCategorisedFeatures && ( ) } { featureGroups.map( ( featureGroupSlug, featureGroupIndex ) => ( ) ) }
{ translate( 'Available plans to choose from' ) }
); }; export default Table;