| 16 | hasBillingAccess: boolean; |
| 17 | }; |
| 18 | export function getUpsellMessage({ |
| 19 | shouldShowUpsell, |
| 20 | isMax20x, |
| 21 | isExtraUsageCommandEnabled, |
| 22 | shouldAutoOpenRateLimitOptionsMenu, |
| 23 | isTeamOrEnterprise, |
| 24 | hasBillingAccess |
| 25 | }: UpsellParams): string | null { |
| 26 | if (!shouldShowUpsell) return null; |
| 27 | if (isMax20x) { |
| 28 | if (isExtraUsageCommandEnabled) { |
| 29 | return '/extra-usage to finish what you\u2019re working on.'; |
| 30 | } |
| 31 | return '/login to switch to an API usage-billed account.'; |
| 32 | } |
| 33 | if (shouldAutoOpenRateLimitOptionsMenu) { |
| 34 | return 'Opening your options\u2026'; |
| 35 | } |
| 36 | if (!isTeamOrEnterprise && !isExtraUsageCommandEnabled) { |
| 37 | return '/upgrade to increase your usage limit.'; |
| 38 | } |
| 39 | if (isTeamOrEnterprise) { |
| 40 | if (!isExtraUsageCommandEnabled) return null; |
| 41 | if (hasBillingAccess) { |
| 42 | return '/extra-usage to finish what you\u2019re working on.'; |
| 43 | } |
| 44 | return '/extra-usage to request more usage from your admin.'; |
| 45 | } |
| 46 | return '/upgrade or /extra-usage to finish what you\u2019re working on.'; |
| 47 | } |
| 48 | type RateLimitMessageProps = { |
| 49 | text: string; |
| 50 | onOpenRateLimitOptions?: () => void; |