Skip to content

Commit 8b76c97

Browse files
committed
replace drawer object with the name of the component
1 parent 30e5d33 commit 8b76c97

File tree

7 files changed

+31
-24
lines changed

7 files changed

+31
-24
lines changed

packages/react/src/components/CheckoutButton.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,15 @@ import { withClerk } from './withClerk';
4646
*/
4747
export const CheckoutButton = withClerk(
4848
({ clerk, children, ...props }: WithClerkProp<React.PropsWithChildren<__experimental_CheckoutButtonProps>>) => {
49-
const { planId, planPeriod, subscriberType, onSubscriptionComplete, newSubscriptionRedirectUrl, drawer, ...rest } =
50-
props;
49+
const {
50+
planId,
51+
planPeriod,
52+
subscriberType,
53+
onSubscriptionComplete,
54+
newSubscriptionRedirectUrl,
55+
checkoutProps,
56+
...rest
57+
} = props;
5158

5259
const { userId, orgId } = useAuth();
5360

@@ -73,7 +80,7 @@ export const CheckoutButton = withClerk(
7380
subscriberType,
7481
onSubscriptionComplete,
7582
newSubscriptionRedirectUrl,
76-
...drawer,
83+
...checkoutProps,
7784
});
7885
};
7986

packages/react/src/components/PlanDetailsButton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import { withClerk } from './withClerk';
3535
*/
3636
export const PlanDetailsButton = withClerk(
3737
({ clerk, children, ...props }: WithClerkProp<React.PropsWithChildren<__experimental_PlanDetailsButtonProps>>) => {
38-
const { plan, planId, initialPlanPeriod, drawer, ...rest } = props;
38+
const { plan, planId, initialPlanPeriod, planDetailsProps, ...rest } = props;
3939
children = normalizeWithDefaultValue(children, 'Plan details');
4040
const child = assertSingleChild(children)('PlanDetailsButton');
4141

@@ -48,7 +48,7 @@ export const PlanDetailsButton = withClerk(
4848
plan,
4949
planId,
5050
initialPlanPeriod,
51-
...drawer,
51+
...planDetailsProps,
5252
});
5353
};
5454

packages/react/src/components/SubscriptionDetailsButton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const SubscriptionDetailsButton = withClerk(
4646
children,
4747
...props
4848
}: WithClerkProp<React.PropsWithChildren<__experimental_SubscriptionDetailsButtonProps>>) => {
49-
const { for: forProp, drawer, onSubscriptionCancel, ...rest } = props;
49+
const { for: forProp, subscriptionDetailsProps, onSubscriptionCancel, ...rest } = props;
5050
children = normalizeWithDefaultValue(children, 'Subscription details');
5151
const child = assertSingleChild(children)('SubscriptionDetailsButton');
5252

@@ -70,7 +70,7 @@ export const SubscriptionDetailsButton = withClerk(
7070
return clerk.__internal_openSubscriptionDetails({
7171
for: forProp,
7272
onSubscriptionCancel,
73-
...drawer,
73+
...subscriptionDetailsProps,
7474
});
7575
};
7676

packages/react/src/components/__tests__/CheckoutButton.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ describe('CheckoutButton', () => {
101101
planPeriod: 'month' as const,
102102
onSubscriptionComplete: vi.fn(),
103103
newSubscriptionRedirectUrl: '/success',
104-
drawer: {
104+
planDetailsProps: {
105105
appearance: {} as Theme,
106106
onClose: vi.fn(),
107107
},
@@ -114,7 +114,7 @@ describe('CheckoutButton', () => {
114114
await waitFor(() => {
115115
expect(mockOpenCheckout).toHaveBeenCalledWith(
116116
expect.objectContaining({
117-
...props.drawer,
117+
...props.planDetailsProps,
118118
planId: props.planId,
119119
onSubscriptionComplete: props.onSubscriptionComplete,
120120
newSubscriptionRedirectUrl: props.newSubscriptionRedirectUrl,
@@ -180,7 +180,7 @@ describe('CheckoutButton', () => {
180180
it('handles portal configuration correctly', async () => {
181181
const portalProps = {
182182
planId: 'test_plan',
183-
drawer: {
183+
planDetailsProps: {
184184
portalId: 'custom-portal',
185185
portalRoot: document.createElement('div'),
186186
},
@@ -191,7 +191,7 @@ describe('CheckoutButton', () => {
191191
await userEvent.click(screen.getByText('Checkout'));
192192
await waitFor(() => {
193193
expect(mockOpenCheckout).toHaveBeenCalledWith(
194-
expect.objectContaining({ ...portalProps.drawer, planId: portalProps.planId }),
194+
expect.objectContaining({ ...portalProps.planDetailsProps, planId: portalProps.planId }),
195195
);
196196
});
197197
});

packages/react/src/components/__tests__/PlanDetailsButton.test.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ describe('PlanDetailsButton', () => {
9494
const props = {
9595
planId: 'test_plan',
9696
initialPlanPeriod: 'month' as const,
97-
drawer: {
97+
planDetailsProps: {
9898
appearance: {} as Theme,
9999
},
100100
};
@@ -105,15 +105,15 @@ describe('PlanDetailsButton', () => {
105105

106106
await waitFor(() => {
107107
expect(mockOpenPlanDetails).toHaveBeenCalledWith(
108-
expect.objectContaining({ ...props.drawer, planId: props.planId }),
108+
expect.objectContaining({ ...props.planDetailsProps, planId: props.planId }),
109109
);
110110
});
111111
});
112112

113113
it('calls clerk.__internal_openPlanDetails with plan object when clicked', async () => {
114114
const props = {
115115
plan: mockPlanResource,
116-
drawer: {
116+
planDetailsProps: {
117117
appearance: {} as Theme,
118118
},
119119
};
@@ -124,7 +124,7 @@ describe('PlanDetailsButton', () => {
124124

125125
await waitFor(() => {
126126
expect(mockOpenPlanDetails).toHaveBeenCalledWith(
127-
expect.objectContaining({ ...props.drawer, plan: props.plan }),
127+
expect.objectContaining({ ...props.planDetailsProps, plan: props.plan }),
128128
);
129129
});
130130
});
@@ -152,7 +152,7 @@ describe('PlanDetailsButton', () => {
152152
it('handles portal configuration correctly', async () => {
153153
const portalProps = {
154154
planId: 'test_plan',
155-
drawer: {
155+
planDetailsProps: {
156156
portalId: 'custom-portal',
157157
portalRoot: document.createElement('div'),
158158
},
@@ -164,7 +164,7 @@ describe('PlanDetailsButton', () => {
164164

165165
await waitFor(() => {
166166
expect(mockOpenPlanDetails).toHaveBeenCalledWith(
167-
expect.objectContaining({ ...portalProps.drawer, planId: portalProps.planId }),
167+
expect.objectContaining({ ...portalProps.planDetailsProps, planId: portalProps.planId }),
168168
);
169169
});
170170
});

packages/react/src/components/__tests__/SubscriptionDetailsButton.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ describe('SubscriptionDetailsButton', () => {
121121
const props = {
122122
for: 'user' as const,
123123
onSubscriptionCancel,
124-
drawer: {
124+
planDetailsProps: {
125125
appearance: {} as Theme,
126126
},
127127
};
@@ -133,7 +133,7 @@ describe('SubscriptionDetailsButton', () => {
133133
await waitFor(() => {
134134
expect(mockOpenSubscriptionDetails).toHaveBeenCalledWith(
135135
expect.objectContaining({
136-
...props.drawer,
136+
...props.planDetailsProps,
137137
for: props.for,
138138
onSubscriptionCancel: props.onSubscriptionCancel,
139139
}),
@@ -183,7 +183,7 @@ describe('SubscriptionDetailsButton', () => {
183183

184184
it('handles portal configuration correctly', async () => {
185185
const portalProps = {
186-
drawer: {
186+
planDetailsProps: {
187187
portalId: 'custom-portal',
188188
portalRoot: document.createElement('div'),
189189
},
@@ -196,7 +196,7 @@ describe('SubscriptionDetailsButton', () => {
196196
await waitFor(() => {
197197
expect(mockOpenSubscriptionDetails).toHaveBeenCalledWith(
198198
expect.objectContaining({
199-
...portalProps.drawer,
199+
...portalProps.planDetailsProps,
200200
}),
201201
);
202202
});

packages/types/src/clerk.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1847,7 +1847,7 @@ export type __experimental_CheckoutButtonProps = {
18471847
planPeriod?: CommerceSubscriptionPlanPeriod;
18481848
subscriberType?: CommercePayerType;
18491849
onSubscriptionComplete?: () => void;
1850-
drawer?: {
1850+
checkoutProps?: {
18511851
appearance?: CheckoutTheme;
18521852
portalId?: string;
18531853
portalRoot?: HTMLElement | null | undefined;
@@ -1893,7 +1893,7 @@ export type __experimental_PlanDetailsButtonProps = {
18931893
plan?: CommercePlanResource;
18941894
planId?: string;
18951895
initialPlanPeriod?: CommerceSubscriptionPlanPeriod;
1896-
drawer?: {
1896+
planDetailsProps?: {
18971897
appearance?: PlanDetailTheme;
18981898
portalId?: string;
18991899
portalRoot?: PortalRoot;
@@ -1941,7 +1941,7 @@ export type __experimental_SubscriptionDetailsButtonProps = {
19411941
*/
19421942
for?: CommercePayerType;
19431943
onSubscriptionCancel?: () => void;
1944-
drawer?: {
1944+
subscriptionDetailsProps?: {
19451945
appearance?: SubscriptionDetailsTheme;
19461946
portalId?: string;
19471947
portalRoot?: PortalRoot;

0 commit comments

Comments
 (0)