Skip to content

Commit 22c35ef

Browse files
authored
chore(types,clerk-js): Update prefix for checkout status (#6438)
1 parent aa9f185 commit 22c35ef

File tree

5 files changed

+25
-18
lines changed

5 files changed

+25
-18
lines changed

.changeset/fluffy-beers-bet.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@clerk/clerk-js': minor
3+
'@clerk/types': minor
4+
---
5+
6+
[Billing Beta]: Update prefix for checkout status
7+
Replaces `awaiting_` with `needs_`.

packages/clerk-js/src/core/modules/checkout/__tests__/manager.spec.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ describe('createCheckoutManager', () => {
7272
error: null,
7373
checkout: null,
7474
fetchStatus: 'idle',
75-
status: 'awaiting_initialization',
75+
status: 'needs_initialization',
7676
});
7777
});
7878

@@ -138,7 +138,7 @@ describe('createCheckoutManager', () => {
138138
isStarting: false,
139139
error: null,
140140
fetchStatus: 'idle',
141-
status: 'awaiting_confirmation',
141+
status: 'needs_confirmation',
142142
});
143143

144144
expect(listener1).toHaveBeenCalledWith(expectedState);
@@ -186,7 +186,7 @@ describe('createCheckoutManager', () => {
186186
checkout: mockCheckout,
187187
error: null,
188188
fetchStatus: 'idle',
189-
status: 'awaiting_confirmation',
189+
status: 'needs_confirmation',
190190
}),
191191
);
192192
});
@@ -230,7 +230,7 @@ describe('createCheckoutManager', () => {
230230
isStarting: false,
231231
error: mockError,
232232
fetchStatus: 'error',
233-
status: 'awaiting_initialization',
233+
status: 'needs_initialization',
234234
}),
235235
);
236236
});
@@ -473,7 +473,7 @@ describe('createCheckoutManager', () => {
473473
error: null,
474474
checkout: null,
475475
fetchStatus: 'idle',
476-
status: 'awaiting_initialization',
476+
status: 'needs_initialization',
477477
});
478478

479479
// Should notify listeners
@@ -515,7 +515,7 @@ describe('createCheckoutManager', () => {
515515
manager.clearCheckout();
516516
state = manager.getCacheState();
517517
expect(state.checkout).toBeNull();
518-
expect(state.status).toBe('awaiting_initialization');
518+
expect(state.status).toBe('needs_initialization');
519519
});
520520
});
521521

@@ -554,17 +554,17 @@ describe('createCheckoutManager', () => {
554554
});
555555

556556
it('should derive status based on checkout state', async () => {
557-
// Initially awaiting initialization
558-
expect(manager.getCacheState().status).toBe('awaiting_initialization');
557+
// Initially needs initialization
558+
expect(manager.getCacheState().status).toBe('needs_initialization');
559559

560-
// After starting checkout - awaiting confirmation
560+
// After starting checkout - needs confirmation
561561
const pendingCheckout = createMockCheckoutResource({ status: 'pending' });
562562
const startOperation: MockedFunction<() => Promise<CommerceCheckoutResource>> = vi
563563
.fn()
564564
.mockResolvedValue(pendingCheckout);
565565

566566
await manager.executeOperation('start', startOperation);
567-
expect(manager.getCacheState().status).toBe('awaiting_confirmation');
567+
expect(manager.getCacheState().status).toBe('needs_confirmation');
568568

569569
// After completing checkout - completed
570570
const completedCheckout = createMockCheckoutResource({ status: 'completed' });
@@ -631,7 +631,7 @@ describe('createCheckoutManager', () => {
631631
const state2 = manager2.getCacheState();
632632

633633
expect(state1.checkout?.id).toBe('checkout1');
634-
expect(state1.status).toBe('awaiting_confirmation');
634+
expect(state1.status).toBe('needs_confirmation');
635635

636636
expect(state2.checkout?.id).toBe('checkout2');
637637
expect(state2.isStarting).toBe(false);

packages/clerk-js/src/core/modules/checkout/manager.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ const createManagerCache = <CacheKey, CacheState>() => {
3636
const managerCache = createManagerCache<CheckoutKey, __experimental_CheckoutCacheState>();
3737

3838
const CHECKOUT_STATUS = {
39-
AWAITING_INITIALIZATION: 'awaiting_initialization',
40-
AWAITING_CONFIRMATION: 'awaiting_confirmation',
39+
NEEDS_INITIALIZATION: 'needs_initialization',
40+
NEEDS_CONFIRMATION: 'needs_confirmation',
4141
COMPLETED: 'completed',
4242
} as const;
4343

@@ -61,8 +61,8 @@ function deriveCheckoutState(
6161

6262
const status = (() => {
6363
if (baseState.checkout?.status === CHECKOUT_STATUS.COMPLETED) return CHECKOUT_STATUS.COMPLETED;
64-
if (baseState.checkout) return CHECKOUT_STATUS.AWAITING_CONFIRMATION;
65-
return CHECKOUT_STATUS.AWAITING_INITIALIZATION;
64+
if (baseState.checkout) return CHECKOUT_STATUS.NEEDS_CONFIRMATION;
65+
return CHECKOUT_STATUS.NEEDS_INITIALIZATION;
6666
})();
6767

6868
return {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const Checkout = (props: __internal_CheckoutProps) => {
2323
<Drawer.Content>
2424
<Drawer.Header title={localizationKeys('commerce.checkout.title')} />
2525
<CheckoutPage.Root>
26-
<CheckoutPage.Stage name='awaiting_initialization'>
26+
<CheckoutPage.Stage name='needs_initialization'>
2727
<CheckoutPage.FetchStatus status='fetching'>
2828
<Spinner
2929
sx={{
@@ -49,7 +49,7 @@ export const Checkout = (props: __internal_CheckoutProps) => {
4949
<CheckoutComplete />
5050
</CheckoutPage.Stage>
5151

52-
<CheckoutPage.Stage name='awaiting_confirmation'>
52+
<CheckoutPage.Stage name='needs_confirmation'>
5353
<CheckoutForm />
5454
</CheckoutPage.Stage>
5555
</CheckoutPage.Root>

packages/types/src/clerk.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ import type { UserResource } from './user';
6060
import type { Autocomplete, DeepPartial, DeepSnakeToCamel } from './utils';
6161
import type { WaitlistResource } from './waitlist';
6262

63-
type __experimental_CheckoutStatus = 'awaiting_initialization' | 'awaiting_confirmation' | 'completed';
63+
type __experimental_CheckoutStatus = 'needs_initialization' | 'needs_confirmation' | 'completed';
6464

6565
export type __experimental_CheckoutCacheState = Readonly<{
6666
isStarting: boolean;

0 commit comments

Comments
 (0)