UpgradeToPro.tsx 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import { ReactNode } from 'react'
  2. import { cn } from 'ui'
  3. import { Admonition } from 'ui-patterns'
  4. import { DocsButton } from './DocsButton'
  5. import { UpgradePlanButton } from './UpgradePlanButton'
  6. interface UpgradeToProProps {
  7. icon?: ReactNode
  8. primaryText: string
  9. secondaryText: string
  10. plan?: 'Pro' | 'Team' | 'Enterprise'
  11. addon?: 'pitr' | 'customDomain' | 'ipv4' | 'spendCap' | 'computeSize'
  12. /** Used in the default message template for request upgrade dialog, e.g: "Upgrade to ..." */
  13. featureProposition?: string
  14. /** As an override for the button text in both upgrade + request to upgrade scenario */
  15. buttonText?: string
  16. /** Where the upgrade interest is coming from */
  17. source?: string
  18. disabled?: boolean
  19. fullWidth?: boolean
  20. layout?: 'vertical' | 'horizontal'
  21. variant?: 'default' | 'primary'
  22. className?: string
  23. docsUrl?: string
  24. }
  25. export const UpgradeToPro = ({
  26. icon,
  27. primaryText,
  28. secondaryText,
  29. plan: planToUpgrade = 'Pro',
  30. addon,
  31. featureProposition,
  32. buttonText,
  33. source = 'upgrade',
  34. disabled = false,
  35. fullWidth = false,
  36. layout = 'horizontal',
  37. variant = 'primary',
  38. className,
  39. docsUrl,
  40. }: UpgradeToProProps) => {
  41. return (
  42. <Admonition
  43. type="default"
  44. icon={icon}
  45. layout={layout}
  46. title={primaryText}
  47. description={secondaryText}
  48. className={cn(fullWidth && 'border-0 rounded-none border-b', className)}
  49. actions={
  50. <>
  51. <UpgradePlanButton
  52. plan={planToUpgrade}
  53. addon={addon}
  54. source={source}
  55. featureProposition={featureProposition}
  56. disabled={disabled}
  57. variant={variant}
  58. >
  59. {buttonText}
  60. </UpgradePlanButton>
  61. {!!docsUrl && <DocsButton href={docsUrl} />}
  62. </>
  63. }
  64. />
  65. )
  66. }