-
Notifications
You must be signed in to change notification settings - Fork 67
feat: customize billing page for enterprise tier #346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
b28b1f3
5f58221
470867c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,12 @@ import { useDashboard } from '../context' | |
| import { useBillingItems } from './hooks' | ||
| import { TierAvatarBorder } from './tier-avatar-border' | ||
| import type { BillingTierData } from './types' | ||
| import { formatHours, formatMibToGb, formatTierDisplayName } from './utils' | ||
| import { | ||
| formatHours, | ||
| formatMibToGb, | ||
| formatTierDisplayName, | ||
| isEnterpriseTier, | ||
| } from './utils' | ||
|
|
||
| function formatCpu(vcpu: number): string { | ||
| return `${vcpu} vCPU` | ||
|
|
@@ -88,6 +93,7 @@ function PlanDetails({ | |
| isLoading, | ||
| }: PlanDetailsProps) { | ||
| const isBaseTier = !selectedTier || selectedTier.id.includes('base') | ||
| const isEnterprise = selectedTier ? isEnterpriseTier(selectedTier.id) : false | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When the billing items response does not include the current enterprise tier in Useful? React with 👍 / 👎. |
||
| const { teamSlug } = useRouteParams<'/dashboard/[teamSlug]/billing'>() | ||
| const pathname = usePathname() | ||
| const router = useRouter() | ||
|
|
@@ -116,44 +122,50 @@ function PlanDetails({ | |
| return ( | ||
| <div className="flex flex-col pt-2 pr-2 pb-1 w-full"> | ||
| <div className="flex items-start justify-between gap-4 max-lg:flex-col"> | ||
| <PlanTitle selectedTier={selectedTier} isLoading={isLoading} /> | ||
|
|
||
| <div className="flex items-center gap-1 flex-wrap"> | ||
| {isOnPlanPage ? ( | ||
| <Button variant="secondary" asChild> | ||
| <Link href={PROTECTED_URLS.BILLING_PLAN_SELECT(teamSlug)}> | ||
| Change Plan | ||
| </Link> | ||
| </Button> | ||
| ) : isLoading ? ( | ||
| <Skeleton className="h-8 w-36" /> | ||
| ) : ( | ||
| <> | ||
| {isBaseTier ? ( | ||
| <Button asChild> | ||
| <Link href={PROTECTED_URLS.BILLING_PLAN_SELECT(teamSlug)}> | ||
| <UpgradeIcon className="size-4" /> | ||
| Upgrade for higher concurrency | ||
| </Link> | ||
| </Button> | ||
| ) : ( | ||
| <Button variant="secondary" asChild> | ||
| <Link href={PROTECTED_URLS.BILLING_PLAN(teamSlug)}> | ||
| Manage plan & add-ons | ||
| </Link> | ||
| </Button> | ||
| )} | ||
| <Button | ||
| variant="secondary" | ||
| onClick={handleManagePayment} | ||
| loading={isPortalLoading ? 'Loading...' : undefined} | ||
| disabled={isPortalLoading} | ||
| > | ||
| Manage payment | ||
| <PlanTitle | ||
| selectedTier={selectedTier} | ||
| isLoading={isLoading} | ||
| isEnterprise={isEnterprise} | ||
| /> | ||
|
|
||
| {!isEnterprise && ( | ||
| <div className="flex items-center gap-1 flex-wrap"> | ||
| {isOnPlanPage ? ( | ||
| <Button variant="secondary" asChild> | ||
| <Link href={PROTECTED_URLS.BILLING_PLAN_SELECT(teamSlug)}> | ||
| Change Plan | ||
| </Link> | ||
| </Button> | ||
| </> | ||
| )} | ||
| </div> | ||
| ) : isLoading ? ( | ||
| <Skeleton className="h-8 w-36" /> | ||
| ) : ( | ||
| <> | ||
| {isBaseTier ? ( | ||
| <Button asChild> | ||
| <Link href={PROTECTED_URLS.BILLING_PLAN_SELECT(teamSlug)}> | ||
| <UpgradeIcon className="size-4" /> | ||
| Upgrade for higher concurrency | ||
| </Link> | ||
| </Button> | ||
| ) : ( | ||
| <Button variant="secondary" asChild> | ||
| <Link href={PROTECTED_URLS.BILLING_PLAN(teamSlug)}> | ||
| Manage plan & add-ons | ||
| </Link> | ||
| </Button> | ||
| )} | ||
| <Button | ||
| variant="secondary" | ||
| onClick={handleManagePayment} | ||
| loading={isPortalLoading ? 'Loading...' : undefined} | ||
| disabled={isPortalLoading} | ||
| > | ||
| Manage payment | ||
| </Button> | ||
| </> | ||
| )} | ||
| </div> | ||
| )} | ||
| </div> | ||
|
|
||
| <Separator className="my-4" /> | ||
|
|
@@ -166,9 +178,10 @@ function PlanDetails({ | |
| interface PlanTitleProps { | ||
| selectedTier: BillingTierData['selected'] | ||
| isLoading: boolean | ||
| isEnterprise?: boolean | ||
| } | ||
|
|
||
| function PlanTitle({ selectedTier, isLoading }: PlanTitleProps) { | ||
| function PlanTitle({ selectedTier, isLoading, isEnterprise }: PlanTitleProps) { | ||
| return ( | ||
| <div className="flex flex-col gap-2"> | ||
| <Label className="text-fg-tertiary prose-label">Plan</Label> | ||
|
|
@@ -179,11 +192,13 @@ function PlanTitle({ selectedTier, isLoading }: PlanTitleProps) { | |
| <span className="prose-value-big uppercase text-fg"> | ||
| {selectedTier ? formatTierDisplayName(selectedTier.name) : null} | ||
| </span> | ||
| <Badge className="uppercase translate-y-1"> | ||
| {selectedTier?.price_cents | ||
| ? `${formatCurrency(selectedTier.price_cents / 100)}/mo` | ||
| : 'FREE'} | ||
| </Badge> | ||
| {!isEnterprise && ( | ||
| <Badge className="uppercase translate-y-1"> | ||
| {selectedTier?.price_cents | ||
| ? `${formatCurrency(selectedTier.price_cents / 100)}/mo` | ||
| : 'FREE'} | ||
| </Badge> | ||
| )} | ||
| </div> | ||
| )} | ||
| </div> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,9 +3,15 @@ import { l } from '@/core/shared/clients/logger/logger' | |
| import { ADDON_500_SANDBOXES_ID, TIER_BASE_ID, TIER_PRO_ID } from './constants' | ||
| import type { BillingAddonData, BillingTierData } from './types' | ||
|
|
||
| export function isEnterpriseTier(tierIdOrName: string): boolean { | ||
| const lower = tierIdOrName.toLowerCase() | ||
| return lower.startsWith('ent') || lower.includes('enterprise') | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove the lower.startsWith('ent') here
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed, now only checks for |
||
| } | ||
|
|
||
| export function formatTierDisplayName(name: string): string { | ||
| if (name.toLowerCase().includes('base')) return 'Hobby' | ||
| if (name.toLowerCase().includes('pro')) return 'Professional' | ||
| if (isEnterpriseTier(name)) return 'Enterprise' | ||
| return name | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the invoices are sent to any email that has been discussed per team. let's restate it as "...directly to your company via email address" or similar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to "Invoices are sent directly to your company via email." in 470867c.