Skip to content

Commit f6ef841

Browse files
authored
chore(clerk-js,types,localizations): Tidy up checkout complete state (#5644)
1 parent 59284dc commit f6ef841

File tree

5 files changed

+62
-19
lines changed

5 files changed

+62
-19
lines changed

.changeset/tender-chefs-punch.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@clerk/localizations': patch
3+
'@clerk/clerk-js': patch
4+
'@clerk/types': patch
5+
---
6+
7+
Chore: tidy up checkout complete state for upcoming subscriptions

packages/clerk-js/bundlewatch.config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{ "path": "./dist/clerk.js", "maxSize": "590kB" },
44
{ "path": "./dist/clerk.browser.js", "maxSize": "73.88KB" },
55
{ "path": "./dist/clerk.headless*.js", "maxSize": "55KB" },
6-
{ "path": "./dist/ui-common*.js", "maxSize": "99KB" },
6+
{ "path": "./dist/ui-common*.js", "maxSize": "99.2KB" },
77
{ "path": "./dist/vendors*.js", "maxSize": "36KB" },
88
{ "path": "./dist/coinbase*.js", "maxSize": "35.5KB" },
99
{ "path": "./dist/createorganization*.js", "maxSize": "5KB" },
@@ -20,7 +20,7 @@
2020
{ "path": "./dist/waitlist*.js", "maxSize": "1.3KB" },
2121
{ "path": "./dist/keylessPrompt*.js", "maxSize": "5.9KB" },
2222
{ "path": "./dist/pricingTable*.js", "maxSize": "5.28KB" },
23-
{ "path": "./dist/checkout*.js", "maxSize": "3KB" },
23+
{ "path": "./dist/checkout*.js", "maxSize": "3.05KB" },
2424
{ "path": "./dist/paymentSources*.js", "maxSize": "8.2KB" },
2525
{ "path": "./dist/up-billing-page*.js", "maxSize": "1KB" },
2626
{ "path": "./dist/op-billing-page*.js", "maxSize": "1KB" },

packages/clerk-js/src/ui/components/Checkout/CheckoutComplete.tsx

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { __experimental_CommerceCheckoutResource } from '@clerk/types';
33
import { Box, Button, descriptors, Heading, Icon, localizationKeys, Span, Text } from '../../customizables';
44
import { Drawer, LineItems, useDrawerContext } from '../../elements';
55
import { Check } from '../../icons';
6+
import { formatDate } from '../../utils';
67

78
const capitalize = (name: string) => name[0].toUpperCase() + name.slice(1);
89

@@ -77,18 +78,22 @@ export const CheckoutComplete = ({ checkout }: { checkout: __experimental_Commer
7778
elementDescriptor={descriptors.checkoutSuccessTitle}
7879
as='h2'
7980
textVariant='h2'
80-
>
81-
{/* TODO(@COMMERCE): needs localization */}
82-
Payment was successful!
83-
</Heading>
81+
localizationKey={
82+
checkout.subscription?.status === 'active'
83+
? localizationKeys('__experimental_commerce.checkout.title__paymentSuccessful')
84+
: localizationKeys('__experimental_commerce.checkout.title__subscriptionSuccessful')
85+
}
86+
/>
8487
<Text
8588
elementDescriptor={descriptors.checkoutSuccessDescription}
8689
colorScheme='secondary'
8790
sx={t => ({ textAlign: 'center', paddingInline: t.space.$8, marginBlockStart: t.space.$2 })}
88-
>
89-
{/* TODO(@COMMERCE): needs localization */}
90-
Minim adipisicing enim fugiat enim est ad nisi exercitation nisi exercitation quis culpa.
91-
</Text>
91+
localizationKey={
92+
checkout.subscription?.status === 'active'
93+
? localizationKeys('__experimental_commerce.checkout.description__paymentSuccessful')
94+
: localizationKeys('__experimental_commerce.checkout.description__subscriptionSuccessful')
95+
}
96+
/>
9297
</Span>
9398
</Span>
9499
</Drawer.Body>
@@ -100,8 +105,7 @@ export const CheckoutComplete = ({ checkout }: { checkout: __experimental_Commer
100105
>
101106
<LineItems.Root>
102107
<LineItems.Group variant='secondary'>
103-
{/* TODO(@COMMERCE): needs localization */}
104-
<LineItems.Title title='Total paid' />
108+
<LineItems.Title title={localizationKeys('__experimental_commerce.checkout.lineItems.title__totalPaid')} />
105109
<LineItems.Description
106110
text={
107111
checkout.invoice
@@ -111,19 +115,27 @@ export const CheckoutComplete = ({ checkout }: { checkout: __experimental_Commer
111115
/>
112116
</LineItems.Group>
113117
<LineItems.Group variant='secondary'>
114-
{/* TODO(@COMMERCE): needs localization */}
115-
<LineItems.Title title='Payment method' />
118+
<LineItems.Title
119+
title={
120+
checkout.subscription?.status === 'active'
121+
? localizationKeys('__experimental_commerce.checkout.lineItems.title__paymentMethod')
122+
: localizationKeys('__experimental_commerce.checkout.lineItems.title__subscriptionBegins')
123+
}
124+
/>
116125
<LineItems.Description
117126
text={
118-
checkout.paymentSource
119-
? `${capitalize(checkout.paymentSource.cardType)}${checkout.paymentSource.last4}`
120-
: '–'
127+
checkout.subscription?.status === 'active'
128+
? checkout.paymentSource
129+
? `${capitalize(checkout.paymentSource.cardType)}${checkout.paymentSource.last4}`
130+
: '–'
131+
: checkout.subscription?.periodStart
132+
? formatDate(new Date(checkout.subscription.periodStart))
133+
: '–'
121134
}
122135
/>
123136
</LineItems.Group>
124137
<LineItems.Group variant='tertiary'>
125-
{/* TODO(@COMMERCE): needs localization */}
126-
<LineItems.Title title='Invoice ID' />
138+
<LineItems.Title title={localizationKeys('__experimental_commerce.checkout.lineItems.title__invoiceId')} />
127139
<LineItems.Description
128140
text={checkout.invoice ? checkout.invoice.id : '–'}
129141
truncateText

packages/localizations/src/en-US.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@ export const enUS: LocalizationResource = {
1313
reSubscribe: 'Re-subscribe',
1414
month: 'Month',
1515
switchPlan: 'Switch to this plan',
16+
checkout: {
17+
title__paymentSuccessful: 'Payment was successful!',
18+
title__subscriptionSuccessful: 'Success!',
19+
description__paymentSuccessful: 'Your new subscription is all set.',
20+
description__subscriptionSuccessful: 'Your new subscription is all set.',
21+
lineItems: {
22+
title__totalPaid: 'Total paid',
23+
title__paymentMethod: 'Payment method',
24+
title__invoiceId: 'Invoice ID',
25+
title__subscriptionBegins: 'Subscription begins',
26+
},
27+
},
1628
},
1729
backButton: 'Back',
1830
badge__currentPlan: 'Current Plan',

packages/types/src/localization.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,18 @@ type _LocalizationResource = {
114114
switchPlan: LocalizationValue;
115115
billedAnnually: LocalizationValue;
116116
accountFunds: LocalizationValue;
117+
checkout: {
118+
title__paymentSuccessful: LocalizationValue;
119+
title__subscriptionSuccessful: LocalizationValue;
120+
description__paymentSuccessful: LocalizationValue;
121+
description__subscriptionSuccessful: LocalizationValue;
122+
lineItems: {
123+
title__totalPaid: LocalizationValue;
124+
title__paymentMethod: LocalizationValue;
125+
title__invoiceId: LocalizationValue;
126+
title__subscriptionBegins: LocalizationValue;
127+
};
128+
};
117129
};
118130
signUp: {
119131
start: {

0 commit comments

Comments
 (0)