@bpinternal/billing-ui 0.19.1 → 0.21.0

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.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Appearance } from '@stripe/stripe-js';
2
2
  import { billing } from '@botpress/client';
3
3
  import { ButtonHTMLAttributes } from 'react';
4
+ import { CancellationReason } from '@bpinternal/const';
4
5
  import { ClassValue } from 'clsx';
5
6
  import { Client } from '@botpress/client';
6
7
  import { ComponentType } from 'react';
@@ -118,6 +119,9 @@ export declare const BILLING_EVENTS: {
118
119
  readonly PLAN_UPGRADE_INITIATED: "billing_plan_upgrade_initiated";
119
120
  readonly PLAN_DOWNGRADED: "billing_plan_downgraded";
120
121
  readonly PLAN_DOWNGRADE_CANCELLED: "billing_plan_downgrade_cancelled";
122
+ readonly DOWNGRADE_CONFIRM_VIEWED: "billing_downgrade_confirm_viewed";
123
+ readonly DOWNGRADE_SURVEY_VIEWED: "billing_downgrade_survey_viewed";
124
+ readonly DOWNGRADE_SURVEY_SUBMITTED: "billing_downgrade_survey_submitted";
121
125
  readonly CHECKOUT_STEP_VIEWED: "billing_checkout_step_viewed";
122
126
  readonly CHECKOUT_INTERVAL_CHANGED: "billing_checkout_interval_changed";
123
127
  readonly PAYMENT_METHOD_SELECTED: "billing_payment_method_selected";
@@ -192,7 +196,13 @@ Pick<Client, 'getWorkspaceMember'> &
192
196
  * needs to pass a client exposing them. Omit them and the UsageDashboard
193
197
  * hides the per-bot section.
194
198
  */
195
- Partial<Pick<Client, 'breakDownWorkspaceUsageByBot' | 'listBots'>>;
199
+ Partial<Pick<Client, 'breakDownWorkspaceUsageByBot' | 'listBots'>> & {
200
+ /**
201
+ * Persists the cancellation survey answers. Not part of the billing engine,
202
+ * so every host implements it over its own backend
203
+ */
204
+ saveCancellationFeedback: (feedback: CancellationFeedback) => Promise<void>;
205
+ };
196
206
 
197
207
  export declare type BillingColorScheme = 'default' | 'neutral';
198
208
 
@@ -327,6 +337,29 @@ export declare type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {
327
337
 
328
338
  export declare const CalendarIcon: ({ size, ...props }: IconProps) => JSX.Element;
329
339
 
340
+ /** Answers from the cancellation survey shown before a downgrade. */
341
+ export declare type CancellationFeedback = {
342
+ reason: CancellationReason;
343
+ comment?: string;
344
+ /** Plan being left. */
345
+ previousPlanId: string;
346
+ /** Plan being downgraded to. */
347
+ planId: string;
348
+ };
349
+
350
+ /** Two-step downgrade flow: what the user loses, then why they're leaving. */
351
+ export declare const CancellationSurveyDialog: ({ open, onOpenChange, planId, onConfirm, loading, planFeatures, }: CancellationSurveyDialogProps) => JSX.Element;
352
+
353
+ export declare type CancellationSurveyDialogProps = {
354
+ open: boolean;
355
+ onOpenChange: (open: boolean) => void;
356
+ /** Plan the user is downgrading to. */
357
+ planId: string;
358
+ onConfirm: (feedback: CancellationFeedback) => void;
359
+ loading?: boolean;
360
+ planFeatures?: Partial<Record<PlanKind, PlanFeatureId[]>>;
361
+ };
362
+
330
363
  /** Minimal card-brand badge (saved-card row). Stripe's own UI shows real brand art. */
331
364
  export declare const CardBrandBadge: ({ brand }: {
332
365
  brand: string;
@@ -1167,6 +1200,9 @@ export declare function usePlans(): UseQueryResult<Plan[], Error>;
1167
1200
 
1168
1201
  export declare const UsersIcon: ({ size, ...props }: IconProps) => JSX.Element;
1169
1202
 
1203
+ /** Persists the cancellation survey answers. */
1204
+ export declare function useSaveCancellationFeedback(): UseMutationResult<void, Error, CancellationFeedback>;
1205
+
1170
1206
  /** Absolute add-on quantities for the current subscription (0 removes an add-on). */
1171
1207
  export declare function useSetAddons(): UseMutationResult<Subscription, Error, {
1172
1208
  addons: Record<string, number>;