@sudobility/building_blocks 0.0.54 → 0.0.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -4,16 +4,13 @@
|
|
|
4
4
|
*
|
|
5
5
|
* This component uses Section internally for proper page layout.
|
|
6
6
|
* Do NOT wrap this component in a Section when consuming it.
|
|
7
|
+
*
|
|
8
|
+
* Uses subscription_lib hooks directly for all subscription data:
|
|
9
|
+
* - useSubscriptionPeriods: Get available billing periods
|
|
10
|
+
* - useSubscriptionForPeriod: Get packages for selected period
|
|
11
|
+
* - useSubscribable: Determine which packages are enabled
|
|
7
12
|
*/
|
|
8
13
|
import type { AnalyticsTrackingParams } from '../../types';
|
|
9
|
-
/** Product from subscription provider */
|
|
10
|
-
export interface PricingProduct {
|
|
11
|
-
identifier: string;
|
|
12
|
-
title: string;
|
|
13
|
-
price: string;
|
|
14
|
-
priceString: string;
|
|
15
|
-
period?: string;
|
|
16
|
-
}
|
|
17
14
|
/** FAQ item */
|
|
18
15
|
export interface FAQItem {
|
|
19
16
|
question: string;
|
|
@@ -45,33 +42,13 @@ export interface PricingPageFormatters {
|
|
|
45
42
|
/** Get features for a product by its identifier */
|
|
46
43
|
getProductFeatures: (productId: string) => string[];
|
|
47
44
|
}
|
|
48
|
-
/** Package ID to entitlement mapping */
|
|
49
|
-
export interface EntitlementMap {
|
|
50
|
-
[packageId: string]: string;
|
|
51
|
-
}
|
|
52
|
-
/** Entitlement to level mapping for comparing plan tiers */
|
|
53
|
-
export interface EntitlementLevels {
|
|
54
|
-
[entitlement: string]: number;
|
|
55
|
-
}
|
|
56
45
|
export interface AppPricingPageProps {
|
|
57
|
-
/** Available subscription products */
|
|
58
|
-
products: PricingProduct[];
|
|
59
46
|
/** Whether user is authenticated */
|
|
60
47
|
isAuthenticated: boolean;
|
|
61
|
-
/** Whether user has an active subscription */
|
|
62
|
-
hasActiveSubscription: boolean;
|
|
63
|
-
/** Current subscription product identifier (if any) */
|
|
64
|
-
currentProductIdentifier?: string;
|
|
65
|
-
/** User ID used for subscription (the selected entity's ID when logged in) */
|
|
66
|
-
subscriptionUserId?: string;
|
|
67
48
|
/** All localized labels */
|
|
68
49
|
labels: PricingPageLabels;
|
|
69
50
|
/** Formatter functions */
|
|
70
51
|
formatters: PricingPageFormatters;
|
|
71
|
-
/** Package ID to entitlement mapping for calculating savings */
|
|
72
|
-
entitlementMap: EntitlementMap;
|
|
73
|
-
/** Entitlement to level mapping for comparing tiers (higher = better) */
|
|
74
|
-
entitlementLevels: EntitlementLevels;
|
|
75
52
|
/** Called when user clicks on a plan */
|
|
76
53
|
onPlanClick: (planIdentifier: string) => void;
|
|
77
54
|
/** Called when user clicks on free plan */
|
|
@@ -82,11 +59,15 @@ export interface AppPricingPageProps {
|
|
|
82
59
|
className?: string;
|
|
83
60
|
/** Optional analytics tracking callback */
|
|
84
61
|
onTrack?: (params: AnalyticsTrackingParams) => void;
|
|
62
|
+
/** Offer ID for subscription_lib hooks */
|
|
63
|
+
offerId: string;
|
|
85
64
|
}
|
|
86
65
|
/**
|
|
87
66
|
* Public pricing page for displaying subscription options.
|
|
67
|
+
* Uses subscription_lib hooks directly for all subscription data.
|
|
68
|
+
*
|
|
88
69
|
* - Non-authenticated: Free tile shows "Try it for Free", paid tiles show "Log in to Continue"
|
|
89
70
|
* - Authenticated on free: Free tile shows "Current Plan" badge (no CTA), paid tiles show "Upgrade"
|
|
90
71
|
* - Authenticated with subscription: Current plan shows badge (no CTA), higher tiers show "Upgrade"
|
|
91
72
|
*/
|
|
92
|
-
export declare function AppPricingPage({
|
|
73
|
+
export declare function AppPricingPage({ isAuthenticated, labels, formatters, onPlanClick, onFreePlanClick, faqItems, className, onTrack, offerId, }: AppPricingPageProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,38 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview App Subscriptions Page
|
|
3
3
|
* @description Page for managing app subscriptions and viewing rate limits.
|
|
4
|
+
*
|
|
5
|
+
* Uses subscription_lib hooks directly for all subscription data:
|
|
6
|
+
* - useSubscriptionPeriods: Get available billing periods
|
|
7
|
+
* - useSubscriptionForPeriod: Get packages for selected period
|
|
8
|
+
* - useSubscribable: Determine which packages are enabled
|
|
9
|
+
* - useUserSubscription: Get current user's subscription
|
|
4
10
|
*/
|
|
5
11
|
import type { RateLimitsConfigData } from '@sudobility/types';
|
|
6
12
|
import type { AnalyticsTrackingParams } from '../../types';
|
|
7
|
-
/** Product from subscription provider */
|
|
8
|
-
export interface SubscriptionProduct {
|
|
9
|
-
identifier: string;
|
|
10
|
-
title: string;
|
|
11
|
-
price: string;
|
|
12
|
-
priceString: string;
|
|
13
|
-
period?: string;
|
|
14
|
-
freeTrialPeriod?: string;
|
|
15
|
-
introPrice?: string;
|
|
16
|
-
}
|
|
17
|
-
/** Current subscription state */
|
|
18
|
-
export interface CurrentSubscription {
|
|
19
|
-
isActive: boolean;
|
|
20
|
-
productIdentifier?: string;
|
|
21
|
-
expirationDate?: Date;
|
|
22
|
-
willRenew?: boolean;
|
|
23
|
-
}
|
|
24
|
-
/** Subscription context value passed from consumer */
|
|
25
|
-
export interface SubscriptionContextValue {
|
|
26
|
-
products: SubscriptionProduct[];
|
|
27
|
-
currentSubscription: CurrentSubscription | null;
|
|
28
|
-
isLoading: boolean;
|
|
29
|
-
error: string | null;
|
|
30
|
-
/** Purchase a subscription product. subscriptionUserId identifies which user/entity the subscription is for. */
|
|
31
|
-
purchase: (productId: string, subscriptionUserId?: string) => Promise<boolean>;
|
|
32
|
-
/** Restore purchases. subscriptionUserId identifies which user/entity to restore for. */
|
|
33
|
-
restore: (subscriptionUserId?: string) => Promise<boolean>;
|
|
34
|
-
clearError: () => void;
|
|
35
|
-
}
|
|
36
13
|
/** All localized labels for the subscription page */
|
|
37
14
|
export interface SubscriptionPageLabels {
|
|
38
15
|
title: string;
|
|
@@ -88,32 +65,22 @@ export interface SubscriptionPageFormatters {
|
|
|
88
65
|
formatSavePercent: (percent: number) => string;
|
|
89
66
|
/** Format intro price note */
|
|
90
67
|
formatIntroNote: (price: string) => string;
|
|
91
|
-
/** Get features for a product by its identifier
|
|
68
|
+
/** Get features for a product by its identifier */
|
|
92
69
|
getProductFeatures: (productId: string) => string[];
|
|
93
70
|
}
|
|
94
|
-
/** Package ID to entitlement mapping (same as PricingPage) */
|
|
95
|
-
export interface EntitlementMap {
|
|
96
|
-
[packageId: string]: string;
|
|
97
|
-
}
|
|
98
|
-
/** Entitlement to level mapping for comparing plan tiers (same as PricingPage) */
|
|
99
|
-
export interface EntitlementLevels {
|
|
100
|
-
[entitlement: string]: number;
|
|
101
|
-
}
|
|
102
71
|
export interface AppSubscriptionsPageProps {
|
|
103
|
-
/**
|
|
104
|
-
|
|
105
|
-
/** Rate limit configuration (for displaying current usage
|
|
72
|
+
/** Offer ID for subscription_lib hooks (e.g., "api", "default") */
|
|
73
|
+
offerId: string;
|
|
74
|
+
/** Rate limit configuration (for displaying current usage) */
|
|
106
75
|
rateLimitsConfig?: RateLimitsConfigData | null;
|
|
107
|
-
/** User ID used for subscription (the selected entity's ID when logged in) */
|
|
108
|
-
subscriptionUserId?: string;
|
|
109
76
|
/** All localized labels */
|
|
110
77
|
labels: SubscriptionPageLabels;
|
|
111
78
|
/** Formatter functions for dynamic strings */
|
|
112
79
|
formatters: SubscriptionPageFormatters;
|
|
113
|
-
/**
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
|
|
80
|
+
/** Purchase handler - called with packageId */
|
|
81
|
+
onPurchase: (packageId: string) => Promise<boolean>;
|
|
82
|
+
/** Restore purchases handler */
|
|
83
|
+
onRestore: () => Promise<boolean>;
|
|
117
84
|
/** Called when purchase succeeds */
|
|
118
85
|
onPurchaseSuccess?: () => void;
|
|
119
86
|
/** Called when restore succeeds */
|
|
@@ -127,6 +94,6 @@ export interface AppSubscriptionsPageProps {
|
|
|
127
94
|
}
|
|
128
95
|
/**
|
|
129
96
|
* Page for managing app subscriptions.
|
|
130
|
-
* Uses
|
|
97
|
+
* Uses subscription_lib hooks directly for all subscription data.
|
|
131
98
|
*/
|
|
132
|
-
export declare function AppSubscriptionsPage({
|
|
99
|
+
export declare function AppSubscriptionsPage({ offerId, rateLimitsConfig, labels, formatters, onPurchase, onRestore, onPurchaseSuccess, onRestoreSuccess, onError, onWarning, onTrack, }: AppSubscriptionsPageProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { AppSubscriptionsPage } from './AppSubscriptionsPage';
|
|
2
|
-
export type { AppSubscriptionsPageProps,
|
|
2
|
+
export type { AppSubscriptionsPageProps, SubscriptionPageLabels, SubscriptionPageFormatters, } from './AppSubscriptionsPage';
|
|
3
3
|
export { AppPricingPage } from './AppPricingPage';
|
|
4
|
-
export type { AppPricingPageProps,
|
|
4
|
+
export type { AppPricingPageProps, FAQItem, PricingPageLabels, PricingPageFormatters, } from './AppPricingPage';
|