Skip to content

Commit 30b8561

Browse files
cleanup
1 parent 0f3d8bb commit 30b8561

File tree

4 files changed

+39
-12
lines changed

4 files changed

+39
-12
lines changed

src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/PaymentCard/BankInformation.tsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@ import { USBankAccountSchema } from 'services/account'
55

66
interface BankInformationProps {
77
usBankAccount: z.infer<typeof USBankAccountSchema>
8+
nextBillingDisplayDate: string | null
89
}
910

10-
function BankInformation({ usBankAccount }: BankInformationProps) {
11+
function BankInformation({
12+
usBankAccount,
13+
nextBillingDisplayDate,
14+
}: BankInformationProps) {
1115
return (
12-
<div className="flex flex-col gap-2">
13-
<div className="flex gap-1">
16+
<div className="flex flex-col gap-3">
17+
<div className="flex gap-2">
1418
<img src={bankLogo} alt="bank logo" />
1519
<div className="ml-1 flex flex-col self-center">
1620
<b>
@@ -20,6 +24,15 @@ function BankInformation({ usBankAccount }: BankInformationProps) {
2024
</b>
2125
</div>
2226
</div>
27+
{nextBillingDisplayDate && (
28+
<p className="text-sm text-ds-gray-quinary">
29+
Your next billing date is{' '}
30+
<span className="text-ds-gray-octonary">
31+
{nextBillingDisplayDate}
32+
</span>
33+
.
34+
</p>
35+
)}
2336
</div>
2437
)
2538
}

src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/PaymentCard/CardInformation.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ CardInformation.propTypes = {
7676
expMonth: PropTypes.number.isRequired,
7777
expYear: PropTypes.number.isRequired,
7878
}).isRequired,
79-
openForm: PropTypes.func.isRequired,
8079
}
8180

8281
export default CardInformation

src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/PaymentCard/PaymentCard.jsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import PropTypes from 'prop-types'
22
import { useState } from 'react'
33

44
import { subscriptionDetailType } from 'services/account'
5+
import { formatTimestampToCalendarDate } from 'shared/utils/billing'
56
import A from 'ui/A'
67
import Button from 'ui/Button'
78
import Icon from 'ui/Icon'
@@ -14,8 +15,15 @@ function PaymentCard({ subscriptionDetail, provider, owner }) {
1415
const card = subscriptionDetail?.defaultPaymentMethod?.card
1516
const usBankAccount = subscriptionDetail?.defaultPaymentMethod?.usBankAccount
1617

18+
let nextBillingDisplayDate = null
19+
if (!subscriptionDetail?.cancelAtPeriodEnd) {
20+
nextBillingDisplayDate = formatTimestampToCalendarDate(
21+
subscriptionDetail?.currentPeriodEnd
22+
)
23+
}
24+
1725
return (
18-
<div className="flex flex-col gap-2 border-t p-4">
26+
<div className="flex flex-col gap-3 border-t p-4">
1927
<div className="flex justify-between">
2028
<h4 className="font-semibold">Payment method</h4>
2129
{!isFormOpen && (
@@ -38,7 +46,10 @@ function PaymentCard({ subscriptionDetail, provider, owner }) {
3846
) : card ? (
3947
<CardInformation card={card} subscriptionDetail={subscriptionDetail} />
4048
) : usBankAccount ? (
41-
<BankInformation usBankAccount={usBankAccount} />
49+
<BankInformation
50+
usBankAccount={usBankAccount}
51+
nextBillingDisplayDate={nextBillingDisplayDate}
52+
/>
4253
) : (
4354
<div className="flex flex-col gap-4 text-ds-gray-quinary">
4455
<p className="mt-4">
@@ -61,7 +72,7 @@ function PaymentCard({ subscriptionDetail, provider, owner }) {
6172
}
6273

6374
PaymentCard.propTypes = {
64-
subscriptionDetail: PropTypes.oneOf([subscriptionDetailType, null]),
75+
subscriptionDetail: subscriptionDetailType,
6576
provider: PropTypes.string.isRequired,
6677
owner: PropTypes.string.isRequired,
6778
}

src/services/account/propTypes.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,15 @@ export const subscriptionDetailType = PropType.shape({
2020
latestInvoice: invoicePropType,
2121
defaultPaymentMethod: PropType.shape({
2222
card: PropType.shape({
23-
brand: PropType.string.isRequired,
24-
expMonth: PropType.number.isRequired,
25-
expYear: PropType.number.isRequired,
26-
last4: PropType.string.isRequired,
27-
}).isRequired,
23+
brand: PropType.string,
24+
expMonth: PropType.number,
25+
expYear: PropType.number,
26+
last4: PropType.string,
27+
}),
28+
usBankAccount: PropType.shape({
29+
bankName: PropType.string,
30+
last4: PropType.string,
31+
}),
2832
}),
2933
trialEnd: PropType.number,
3034
})

0 commit comments

Comments
 (0)