Skip to content

Commit 22d10c1

Browse files
committed
chore(clerk-js): Drop support for forOrganizations in PricingTable
1 parent d105c54 commit 22d10c1

File tree

3 files changed

+3
-71
lines changed

3 files changed

+3
-71
lines changed

packages/clerk-js/src/core/clerk.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,14 +1158,6 @@ export class Clerk implements ClerkInterface {
11581158
}
11591159
return;
11601160
}
1161-
// Temporary backward compatibility for legacy prop: `forOrganizations`. Will be removed in the coming minor release.
1162-
const nextProps = { ...(props as any) } as PricingTableProps & { forOrganizations?: boolean };
1163-
if (typeof (props as any)?.forOrganizations !== 'undefined') {
1164-
logger.warnOnce(
1165-
'Clerk: [IMPORTANT] <PricingTable /> prop `forOrganizations` is deprecated and will be removed in the coming minors. Use `for="organization"` instead.',
1166-
);
1167-
}
1168-
11691161
this.assertComponentsReady(this.#clerkUi);
11701162
const component = 'PricingTable';
11711163
void this.#clerkUi
@@ -1175,11 +1167,11 @@ export class Clerk implements ClerkInterface {
11751167
name: component,
11761168
appearanceKey: 'pricingTable',
11771169
node,
1178-
props: nextProps,
1170+
props,
11791171
}),
11801172
);
11811173

1182-
this.telemetry?.record(eventPrebuiltComponentMounted(component, nextProps));
1174+
this.telemetry?.record(eventPrebuiltComponentMounted(component, props));
11831175
};
11841176

11851177
public unmountPricingTable = (node: HTMLDivElement): void => {

packages/ui/src/components/PricingTable/__tests__/PricingTable.test.tsx

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -513,61 +513,6 @@ describe('PricingTable - plans visibility', () => {
513513
await findByRole('heading', { name: 'Test Plan' });
514514
});
515515

516-
it('fetches organization plans and renders when using legacy forOrganizations: true', async () => {
517-
const { wrapper, fixtures, props } = await createFixtures(f => {
518-
f.withBilling();
519-
f.withOrganizations();
520-
f.withUser({ email_addresses: ['test@clerk.com'], organization_memberships: ['Org1'] });
521-
});
522-
523-
// Set legacy prop via context provider
524-
props.setProps({ forOrganizations: true } as any);
525-
526-
fixtures.clerk.billing.getStatements.mockRejectedValue();
527-
fixtures.clerk.organization.getPaymentMethods.mockRejectedValue();
528-
fixtures.clerk.billing.getPlans.mockResolvedValue({ data: [testPlan as any], total_count: 1 });
529-
fixtures.clerk.billing.getSubscription.mockResolvedValue({
530-
id: 'sub_org_active',
531-
status: 'active',
532-
activeAt: new Date('2021-01-01'),
533-
createdAt: new Date('2021-01-01'),
534-
nextPayment: null,
535-
pastDueAt: null,
536-
updatedAt: null,
537-
subscriptionItems: [
538-
{
539-
id: 'si_active_org',
540-
plan: { ...testPlan, forPayerType: 'organization' },
541-
createdAt: new Date('2021-01-01'),
542-
paymentMethodId: 'src_1',
543-
pastDueAt: null,
544-
canceledAt: null,
545-
periodStart: new Date('2021-01-01'),
546-
periodEnd: new Date('2021-01-31'),
547-
planPeriod: 'month' as const,
548-
status: 'active' as const,
549-
isFreeTrial: false,
550-
cancel: vi.fn(),
551-
pathRoot: '',
552-
reload: vi.fn(),
553-
},
554-
],
555-
pathRoot: '',
556-
reload: vi.fn(),
557-
});
558-
559-
const { getByRole } = render(<PricingTable />, { wrapper });
560-
561-
await waitFor(() => {
562-
// Ensure plans rendered
563-
expect(getByRole('heading', { name: 'Test Plan' })).toBeVisible();
564-
// Ensure API args reflect org context
565-
expect(fixtures.clerk.billing.getPlans).toHaveBeenCalledWith(expect.objectContaining({ for: 'organization' }));
566-
// Ensure subscription called with active org
567-
expect(fixtures.clerk.billing.getSubscription).toHaveBeenCalledWith(expect.objectContaining({ orgId: 'Org1' }));
568-
});
569-
});
570-
571516
it('fetches organization plans and renders when using for: organization', async () => {
572517
const { wrapper, fixtures, props } = await createFixtures(f => {
573518
f.withBilling();

packages/ui/src/contexts/ClerkUIComponentsContext.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,7 @@ export function ComponentContextProvider({
9595
);
9696
case 'PricingTable':
9797
return (
98-
<SubscriberTypeContext.Provider
99-
value={
100-
// Backward compatibility: support legacy `forOrganizations: true`
101-
(props as any).forOrganizations ? 'organization' : (props as PricingTableProps).for || 'user'
102-
}
103-
>
98+
<SubscriberTypeContext.Provider value={(props as PricingTableProps).for || 'user'}>
10499
<PricingTableContext.Provider value={{ componentName, ...(props as PricingTableProps) }}>
105100
{children}
106101
</PricingTableContext.Provider>

0 commit comments

Comments
 (0)