Skip to content

Commit 0c413de

Browse files
cleanup
1 parent 0f6d1c3 commit 0c413de

File tree

5 files changed

+37
-104
lines changed

5 files changed

+37
-104
lines changed

src/pages/PlanPage/subRoutes/CurrentOrgPlan/BillingDetails/EmailAddress/EmailAddress.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type FormData = z.infer<typeof emailSchema>
2727
function EmailAddress() {
2828
const { provider, owner } = useParams<URLParams>()
2929
const { data: accountDetails } = useAccountDetails({ provider, owner })
30-
const [isEditMode, setEditMode] = useState(false)
30+
const [isFormOpen, setIsFormOpen] = useState(false)
3131
const currentCustomerEmail =
3232
accountDetails?.subscriptionDetail?.customer?.email || 'No email provided'
3333

@@ -50,7 +50,7 @@ function EmailAddress() {
5050
{ newEmail: data?.newCustomerEmail },
5151
{
5252
onSuccess: () => {
53-
setEditMode(false)
53+
setIsFormOpen(false)
5454
},
5555
}
5656
)
@@ -60,18 +60,18 @@ function EmailAddress() {
6060
<div className="flex flex-col gap-2 border-t p-4">
6161
<div className="flex justify-between">
6262
<h4 className="font-semibold">Email address</h4>{' '}
63-
{!isEditMode && (
63+
{!isFormOpen && (
6464
/* @ts-expect-error - A hasn't been typed yet */
6565
<A
6666
variant="semibold"
67-
onClick={() => setEditMode(true)}
67+
onClick={() => setIsFormOpen(true)}
6868
hook="edit-email"
6969
>
7070
Edit <Icon name="chevronRight" size="sm" variant="solid" />
7171
</A>
7272
)}
7373
</div>
74-
{isEditMode ? (
74+
{isFormOpen ? (
7575
<form onSubmit={handleSubmit(submit)} className="flex flex-col gap-2">
7676
<TextInput
7777
data-testid="billing-email-input"
@@ -99,7 +99,7 @@ function EmailAddress() {
9999
hook="cancel-email"
100100
variant="plain"
101101
disabled={isLoading}
102-
onClick={() => setEditMode(false)}
102+
onClick={() => setIsFormOpen(false)}
103103
>
104104
Cancel
105105
</Button>

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

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,40 @@
11
import { z } from 'zod'
22

3+
import amexLogo from 'assets/billing/amex.svg'
4+
import discoverLogo from 'assets/billing/discover.svg'
5+
import mastercardLogo from 'assets/billing/mastercard.svg'
6+
import visaLogo from 'assets/billing/visa.svg'
37
import { SubscriptionDetailSchema } from 'services/account'
4-
import { CardBrand, CardBrands } from 'services/account/types'
5-
import {
8+
import {
69
formatTimestampToCalendarDate,
710
lastTwoDigits,
811
} from 'shared/utils/billing'
912

13+
const cardBrands = {
14+
amex: {
15+
logo: amexLogo,
16+
name: 'American Express',
17+
},
18+
discover: {
19+
logo: discoverLogo,
20+
name: 'Discover',
21+
},
22+
mastercard: {
23+
logo: mastercardLogo,
24+
name: 'MasterCard',
25+
},
26+
visa: {
27+
logo: visaLogo,
28+
name: 'Visa',
29+
},
30+
fallback: {
31+
logo: visaLogo,
32+
name: 'Credit card',
33+
},
34+
}
35+
36+
type CardBrand = keyof typeof cardBrands
37+
1038
interface CardInformationProps {
1139
subscriptionDetail: z.infer<typeof SubscriptionDetailSchema>
1240
card: {
@@ -17,7 +45,7 @@ interface CardInformationProps {
1745
}
1846
}
1947
function CardInformation({ subscriptionDetail, card }: CardInformationProps) {
20-
const typeCard = CardBrands[card?.brand as CardBrand] ?? CardBrands.fallback
48+
const typeCard = cardBrands[card?.brand as CardBrand] ?? cardBrands.fallback
2149
let nextBilling = null
2250

2351
if (!subscriptionDetail?.cancelAtPeriodEnd) {

src/services/account/propTypes.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import PropType from 'prop-types'
22

3-
// TODO: These types were duplicated into types.ts,
4-
// delete this file once all usages are migrated to TS
5-
63
export const invoicePropType = PropType.shape({
74
created: PropType.number.isRequired,
85
dueDate: PropType.number,

src/services/account/types.ts

Lines changed: 0 additions & 71 deletions
This file was deleted.

src/services/navigation/useNavLinks/useNavLinks.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -967,26 +967,5 @@ export function useNavLinks() {
967967
isExternalLink: true,
968968
openNewTab: true,
969969
},
970-
billingEditPrimary: {
971-
path: (
972-
{ provider = p, owner = o} = {
973-
provider: p,
974-
owner: o,
975-
}
976-
) =>
977-
`/plan/${provider}/${owner}?tab=primary`,
978-
isExternalLink: false,
979-
text: 'Primary payment method',
980-
},
981-
billingEditSecondary: {
982-
path: (
983-
{ provider = p, owner = o} = {
984-
provider: p,
985-
owner: o,
986-
}
987-
) => `/plan/${provider}/${owner}?tab=secondary`,
988-
isExternalLink: false,
989-
text: 'Secondary payment method',
990-
},
991970
}
992971
}

0 commit comments

Comments
 (0)