import { useCurrentOrganisation } from '@documenso/lib/client-only/providers/organisation'; import { canExecuteOrganisationAction } from '@documenso/lib/utils/organisations'; import { Badge } from '@documenso/ui/primitives/badge'; import { Button } from '@documenso/ui/primitives/button'; import { Trans } from '@lingui/react/macro'; import { ArrowRightIcon, CheckIcon, LockIcon } from 'lucide-react'; import type { ReactNode } from 'react'; import { Link } from 'react-router'; export type SettingsUpsellCardProps = { planLabel: ReactNode; title: ReactNode; description: ReactNode; features: ReactNode[]; preview: ReactNode; /** * CTA label. Defaults to "Upgrade Plan". */ ctaLabel?: ReactNode; /** * CTA destination. Defaults to the organisation billing settings page. */ ctaTo?: string; /** * Render the CTA as an external link (new tab) instead of an internal route. */ ctaExternal?: boolean; }; /** * Shared split-card layout for claim-gated settings upsells on Documenso * Cloud. The left pane pitches the feature (plan badge, title, description, * feature list, upgrade CTA); the right pane renders a decorative scenario * preview supplied by the caller. * * Callers decide *when* to render this (cloud + missing claim flag). */ export const SettingsUpsellCard = ({ planLabel, title, description, features, preview, ctaLabel, ctaTo, ctaExternal = false, }: SettingsUpsellCardProps) => { const organisation = useCurrentOrganisation(); const canManageBilling = canExecuteOrganisationAction('MANAGE_BILLING', organisation.currentOrganisationRole); const ctaHref = ctaTo ?? `/o/${organisation.url}/settings/billing`; const ctaContent = ( <> {ctaLabel ?? Upgrade Plan} ); return (
{/* * `min-w-0` on both grid items: `fr` tracks have an `auto` content * minimum, so long preview content (e.g. a wide mono domain line) would * otherwise widen the right track beyond its 0.92fr share — and * re-balance the whole grid on every preview cycle (layout shift). */}
{planLabel}

{title}

{description}

    {features.map((feature, index) => (
  • {feature}
  • ))}
{canManageBilling ? ( ) : (

Contact your organisation owner to upgrade plans.

)}
); };