-
Notifications
You must be signed in to change notification settings - Fork 34
feat: Add messaging for free seats and clarify paid #3925
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
Changes from 2 commits
6c755aa
2db2598
1a708d8
42c80f6
d7146ac
106c005
d214947
d464fc1
28c312c
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 |
|---|---|---|
|
|
@@ -2,26 +2,56 @@ import PropTypes from 'prop-types' | |
| import { useState } from 'react' | ||
|
|
||
| import { accountDetailsPropType } from 'services/account/propTypes' | ||
| import { formatTimestampToCalendarDate } from 'shared/utils/billing' | ||
| import { usePlanData } from 'services/account/usePlanData' | ||
| import { | ||
| BillingRate, | ||
| formatNumberToUSD, | ||
| formatTimestampToCalendarDate, | ||
| } from 'shared/utils/billing' | ||
| import { | ||
| calculatePriceProPlan, | ||
| calculatePriceTeamPlan, | ||
| } from 'shared/utils/upgradeForm' | ||
| import A from 'ui/A' | ||
| import Button from 'ui/Button' | ||
| import Icon from 'ui/Icon' | ||
|
|
||
| import BankInformation from './BankInformation' | ||
| import CardInformation from './CardInformation' | ||
| import PaymentMethodForm from './PaymentMethodForm' | ||
|
|
||
| function PaymentCard({ accountDetails, provider, owner }) { | ||
| const [isFormOpen, setIsFormOpen] = useState(false) | ||
| const { data: planData } = usePlanData({ | ||
| provider, | ||
| owner, | ||
| }) | ||
| const subscriptionDetail = accountDetails?.subscriptionDetail | ||
| const card = subscriptionDetail?.defaultPaymentMethod?.card | ||
| const usBankAccount = subscriptionDetail?.defaultPaymentMethod?.usBankAccount | ||
| const isPerYear = planData?.plan?.billingRate === BillingRate.ANNUALLY | ||
|
||
| let seats = | ||
|
||
| (planData?.plan?.planUserCount ?? 0) - (planData?.plan?.freeSeatCount ?? 0) | ||
| seats = seats > 0 ? seats : 0 | ||
| const billPrice = planData?.plan?.isProPlan | ||
| ? calculatePriceProPlan({ | ||
| seats, | ||
| baseUnitPrice: planData?.plan?.baseUnitPrice ?? 0, | ||
| }) | ||
| : calculatePriceTeamPlan({ | ||
| seats, | ||
| baseUnitPrice: planData?.plan?.baseUnitPrice ?? 0, | ||
| }) | ||
seer-by-sentry[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
seer-by-sentry[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| let nextBillingDisplayDate = null | ||
| if (!subscriptionDetail?.cancelAtPeriodEnd) { | ||
| nextBillingDisplayDate = formatTimestampToCalendarDate( | ||
| subscriptionDetail?.currentPeriodEnd | ||
| ) | ||
| } | ||
| const nextBillPrice = formatNumberToUSD( | ||
| isPerYear ? billPrice * 12 : billPrice | ||
|
||
| ) | ||
|
|
||
| return ( | ||
| <div className="flex flex-col gap-3 border-t p-4"> | ||
|
|
@@ -45,7 +75,11 @@ function PaymentCard({ accountDetails, provider, owner }) { | |
| accountDetails={accountDetails} | ||
| /> | ||
| ) : card ? ( | ||
| <CardInformation card={card} subscriptionDetail={subscriptionDetail} /> | ||
| <CardInformation | ||
| card={card} | ||
| subscriptionDetail={subscriptionDetail} | ||
| nextBillPrice={nextBillPrice} | ||
| /> | ||
| ) : usBankAccount ? ( | ||
| <BankInformation | ||
| usBankAccount={usBankAccount} | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.