Skip to content

Commit 84528d0

Browse files
committed
finishing touches on subscription details
1 parent 962e8d5 commit 84528d0

File tree

8 files changed

+14
-9
lines changed

8 files changed

+14
-9
lines changed

packages/clerk-js/src/ui/Components.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import type {
33
__experimental_PlanDetailsProps,
44
__experimental_SubscriptionDetailsProps,
55
__internal_CheckoutProps,
6-
__internal_PlanDetailsProps,
76
__internal_UserVerificationProps,
87
Appearance,
98
Clerk,
@@ -113,9 +112,9 @@ export type ComponentControls = {
113112
props: T extends 'checkout'
114113
? __internal_CheckoutProps
115114
: T extends 'planDetails'
116-
? __internal_PlanDetailsProps
115+
? __experimental_PlanDetailsProps
117116
: T extends 'subscriptionDetails'
118-
? __internal_PlanDetailsProps
117+
? __experimental_SubscriptionDetailsProps
119118
: never,
120119
) => void;
121120
closeDrawer: (

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { formatDate } from '@/ui/utils/formatDate';
2424

2525
const isFreePlan = (plan: CommercePlanResource) => !plan.hasBaseFee;
2626

27-
import { usePlansContext, useSubscriberTypeContext, useSubscriptions } from '../../contexts';
27+
import { SubscriberTypeContext, usePlansContext, useSubscriberTypeContext, useSubscriptions } from '../../contexts';
2828
import type { LocalizationKey } from '../../customizables';
2929
import {
3030
Badge,
@@ -59,7 +59,9 @@ export const SubscriptionDetails = (props: __experimental_SubscriptionDetailsPro
5959
return (
6060
<Drawer.Content>
6161
<SubscriptionDetailsContext.Provider value={{ componentName: 'SubscriptionDetails', ...props }}>
62-
<SubscriptionDetailsInternal {...props} />
62+
<SubscriberTypeContext.Provider value={props.for}>
63+
<SubscriptionDetailsInternal {...props} />
64+
</SubscriberTypeContext.Provider>
6365
</SubscriptionDetailsContext.Provider>
6466
</Drawer.Content>
6567
);

packages/clerk-js/src/ui/contexts/components/Plans.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ export const usePlansContext = () => {
362362

363363
if (subscription && subscription.planPeriod === planPeriod && !subscription.canceledAtDate) {
364364
clerk.__experimental_openSubscriptionDetails({
365+
for: subscriberType,
365366
onSubscriptionCancel: () => {
366367
revalidateAll();
367368
onSubscriptionChange?.();

packages/clerk-js/src/ui/contexts/components/SubscriberType.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createContext, useContext } from 'react';
22

33
const DEFAUlT = 'user';
4-
export const SubscriberTypeContext = createContext<'user' | 'org'>(DEFAUlT);
4+
export const SubscriberTypeContext = createContext<'user' | 'org' | undefined>(DEFAUlT);
55

66
export const useSubscriberTypeContext = () => useContext(SubscriberTypeContext) || DEFAUlT;
77

packages/clerk-js/src/ui/lazyModules/MountedCheckoutDrawer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function MountedCheckoutDrawer({
2727
// Without this, the drawer would not be rendered after a session switch.
2828
key={user?.id}
2929
globalAppearance={appearance}
30-
appearanceKey={'checkout' as any}
30+
appearanceKey={'checkout'}
3131
componentAppearance={checkoutDrawer.props.appearance || {}}
3232
flowName={'checkout'}
3333
open={checkoutDrawer.open}

packages/clerk-js/src/ui/lazyModules/MountedSubscriptionDetailDrawer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function MountedSubscriptionDetailDrawer({
2727
// Without this, the drawer would not be rendered after a session switch.
2828
key={user?.id}
2929
globalAppearance={appearance}
30-
appearanceKey={'planDetails' as any}
30+
appearanceKey={'subscriptionDetails' as any}
3131
componentAppearance={subscriptionDetailsDrawer.props.appearance || {}}
3232
flowName={'subscriptionDetails'}
3333
open={subscriptionDetailsDrawer.open}

packages/types/src/appearance.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,7 @@ export type WaitlistTheme = Theme;
884884
export type PricingTableTheme = Theme;
885885
export type CheckoutTheme = Theme;
886886
export type PlanDetailTheme = Theme;
887+
export type SubscriptionDetailsTheme = Theme;
887888
export type APIKeysTheme = Theme;
888889
export type OAuthConsentTheme = Theme;
889890

packages/types/src/clerk.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import type {
1212
PricingTableTheme,
1313
SignInTheme,
1414
SignUpTheme,
15+
SubscriptionDetailsTheme,
1516
UserButtonTheme,
1617
UserProfileTheme,
1718
UserVerificationTheme,
@@ -1777,7 +1778,8 @@ export type __experimental_PlanDetailsProps = {
17771778
};
17781779

17791780
export type __experimental_SubscriptionDetailsProps = {
1780-
appearance?: PlanDetailTheme;
1781+
for?: CommerceSubscriberType;
1782+
appearance?: SubscriptionDetailsTheme;
17811783
onSubscriptionCancel?: () => void;
17821784
portalId?: string;
17831785
portalRoot?: PortalRoot;

0 commit comments

Comments
 (0)