@sudobility/building_blocks 0.0.60 → 0.0.64

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;
@@ -46,16 +43,8 @@ export interface PricingPageFormatters {
46
43
  getProductFeatures: (productId: string) => string[];
47
44
  }
48
45
  export interface AppPricingPageProps {
49
- /** Available subscription products */
50
- products: PricingProduct[];
51
46
  /** Whether user is authenticated */
52
47
  isAuthenticated: boolean;
53
- /** Whether user has an active subscription */
54
- hasActiveSubscription: boolean;
55
- /** Current subscription product identifier (if any) */
56
- currentProductIdentifier?: string;
57
- /** User ID used for subscription (the selected entity's ID when logged in) */
58
- subscriptionUserId?: string;
59
48
  /** All localized labels */
60
49
  labels: PricingPageLabels;
61
50
  /** Formatter functions */
@@ -70,16 +59,15 @@ export interface AppPricingPageProps {
70
59
  className?: string;
71
60
  /** Optional analytics tracking callback */
72
61
  onTrack?: (params: AnalyticsTrackingParams) => void;
73
- /**
74
- * Offer ID for subscription_lib hooks (e.g., "api", "default").
75
- * Uses useSubscribable hook to determine which packages are enabled.
76
- */
62
+ /** Offer ID for subscription_lib hooks */
77
63
  offerId: string;
78
64
  }
79
65
  /**
80
66
  * Public pricing page for displaying subscription options.
67
+ * Uses subscription_lib hooks directly for all subscription data.
68
+ *
81
69
  * - Non-authenticated: Free tile shows "Try it for Free", paid tiles show "Log in to Continue"
82
70
  * - Authenticated on free: Free tile shows "Current Plan" badge (no CTA), paid tiles show "Upgrade"
83
71
  * - Authenticated with subscription: Current plan shows badge (no CTA), higher tiers show "Upgrade"
84
72
  */
85
- export declare function AppPricingPage({ products, isAuthenticated, hasActiveSubscription, currentProductIdentifier, labels, formatters, onPlanClick, onFreePlanClick, faqItems, className, onTrack, offerId, }: AppPricingPageProps): import("react/jsx-runtime").JSX.Element;
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,20 +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 (required - same as pricing page) */
68
+ /** Get features for a product by its identifier */
92
69
  getProductFeatures: (productId: string) => string[];
93
70
  }
94
71
  export interface AppSubscriptionsPageProps {
95
- /** Subscription context value */
96
- subscription: SubscriptionContextValue;
97
- /** Rate limit configuration (for displaying current usage, not for features) */
72
+ /** Offer ID for subscription_lib hooks (e.g., "api", "default") */
73
+ offerId: string;
74
+ /** Rate limit configuration (for displaying current usage) */
98
75
  rateLimitsConfig?: RateLimitsConfigData | null;
99
- /** User ID used for subscription (the selected entity's ID when logged in) */
100
- subscriptionUserId?: string;
101
76
  /** All localized labels */
102
77
  labels: SubscriptionPageLabels;
103
78
  /** Formatter functions for dynamic strings */
104
79
  formatters: SubscriptionPageFormatters;
80
+ /** Purchase handler - called with packageId */
81
+ onPurchase: (packageId: string) => Promise<boolean>;
82
+ /** Restore purchases handler */
83
+ onRestore: () => Promise<boolean>;
105
84
  /** Called when purchase succeeds */
106
85
  onPurchaseSuccess?: () => void;
107
86
  /** Called when restore succeeds */
@@ -112,14 +91,9 @@ export interface AppSubscriptionsPageProps {
112
91
  onWarning?: (title: string, message: string) => void;
113
92
  /** Optional analytics tracking callback */
114
93
  onTrack?: (params: AnalyticsTrackingParams) => void;
115
- /**
116
- * Offer ID for subscription_lib hooks (e.g., "api", "default").
117
- * Uses useSubscribable hook to determine which packages are enabled.
118
- */
119
- offerId: string;
120
94
  }
121
95
  /**
122
96
  * Page for managing app subscriptions.
123
- * Uses useSubscribable hook to determine which packages are enabled.
97
+ * Uses subscription_lib hooks directly for all subscription data.
124
98
  */
125
- export declare function AppSubscriptionsPage({ subscription, rateLimitsConfig, subscriptionUserId, labels, formatters, onPurchaseSuccess, onRestoreSuccess, onError, onWarning, onTrack, offerId, }: AppSubscriptionsPageProps): import("react/jsx-runtime").JSX.Element;
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, SubscriptionProduct, CurrentSubscription, SubscriptionContextValue, SubscriptionPageLabels, SubscriptionPageFormatters, } from './AppSubscriptionsPage';
2
+ export type { AppSubscriptionsPageProps, SubscriptionPageLabels, SubscriptionPageFormatters, } from './AppSubscriptionsPage';
3
3
  export { AppPricingPage } from './AppPricingPage';
4
- export type { AppPricingPageProps, PricingProduct, FAQItem, PricingPageLabels, PricingPageFormatters, } from './AppPricingPage';
4
+ export type { AppPricingPageProps, FAQItem, PricingPageLabels, PricingPageFormatters, } from './AppPricingPage';