Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/weak-ways-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@clerk/clerk-js': minor
'@clerk/types': minor
---

[Billing Beta] Replace `forOrganizations: true` with `for: "organizations"` in `<PricingTable/>`.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function Card(props: CardProps) {
subscription,
plan,
planPeriod,
forOrganizations: pricingTableProps.forOrganizations,
for: pricingTableProps.for,
hasActiveOrganization: !!organization,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,25 @@ const run = (args: {
subscription?: BillingSubscriptionItemResource;
plan?: BillingPlanResource;
planPeriod?: BillingSubscriptionPlanPeriod;
forOrganizations?: boolean;
for?: 'user' | 'organization';
hasActiveOrganization?: boolean;
}) =>
getPricingFooterState({
subscription: args.subscription,
plan: args.plan ?? basePlan,
planPeriod: args.planPeriod ?? 'month',
forOrganizations: args.forOrganizations,
for: args.for,
hasActiveOrganization: args.hasActiveOrganization ?? false,
});

describe('usePricingFooterState', () => {
it('hides footer when org plans and no active org', () => {
const res = run({ subscription: undefined, forOrganizations: true, hasActiveOrganization: false });
const res = run({ subscription: undefined, for: 'organization', hasActiveOrganization: false });
expect(res).toEqual({ shouldShowFooter: false, shouldShowFooterNotice: false });
});

it('shows footer when no subscription and user plans', () => {
const res = run({ subscription: undefined, forOrganizations: false });
const res = run({ subscription: undefined, for: 'user' });
expect(res).toEqual({ shouldShowFooter: true, shouldShowFooterNotice: false });
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ type UsePricingFooterStateParams = {
subscription: BillingSubscriptionItemResource | undefined;
plan: BillingPlanResource;
planPeriod: BillingSubscriptionPlanPeriod;
forOrganizations?: boolean;
for?: 'user' | 'organization';
hasActiveOrganization: boolean;
};

Expand All @@ -13,14 +13,14 @@ type UsePricingFooterStateParams = {
* @returns [shouldShowFooter, shouldShowFooterNotice]
*/
const valueResolution = (params: UsePricingFooterStateParams): [boolean, boolean] => {
const { subscription, plan, planPeriod, forOrganizations, hasActiveOrganization } = params;
const { subscription, plan, planPeriod, for: forWhom, hasActiveOrganization } = params;
const show_with_notice: [boolean, boolean] = [true, true];
const show_without_notice: [boolean, boolean] = [true, false];
const hide: [boolean, boolean] = [false, false];

// No subscription
if (!subscription) {
if (forOrganizations && !hasActiveOrganization) {
if (forWhom === 'organization' && !hasActiveOrganization) {
return hide;
}
return show_without_notice;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export function ComponentContextProvider({
);
case 'PricingTable':
return (
<SubscriberTypeContext.Provider value={(props as PricingTableProps).forOrganizations ? 'organization' : 'user'}>
<SubscriberTypeContext.Provider value={(props as PricingTableProps).for || 'user'}>
<PricingTableContext.Provider value={{ componentName, ...(props as PricingTableProps) }}>
{children}
</PricingTableContext.Provider>
Expand Down
7 changes: 4 additions & 3 deletions packages/types/src/clerk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,7 @@
*/
windowNavigate: (to: URL | string) => void;
},
) => Promise<unknown> | unknown;

Check warning on line 1178 in packages/types/src/clerk.ts

View workflow job for this annotation

GitHub Actions / Static analysis

'unknown' overrides all other types in this union type

export type WithoutRouting<T> = Omit<T, 'path' | 'routing'>;

Expand Down Expand Up @@ -1829,10 +1829,11 @@

type PricingTableBaseProps = {
/**
* Whether to show pricing table for organizations.
* @default false
* The subscriber type to display plans for.
* If `organization`, show plans for the active organization; otherwise for the user.
* @default 'user'
*/
forOrganizations?: boolean;
for?: ForPayerType;
/**
* Customisation options to fully match the Clerk components to your own brand.
* These options serve as overrides and will be merged with the global `appearance`
Expand Down
Loading