@bpinternal/billing-ui 0.21.0 → 0.22.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
@@ -184,25 +184,20 @@ export declare type BillingChangeEvent = {
184
184
  */
185
185
  export declare type BillingClient = Pick<billing.Client, 'listPlans' | 'listAddons' | 'getSubscription' | 'previewSubscriptionUpdate' | 'setPlan' | 'setAddons' | 'getPaymentMethod' | 'createPaymentMethodIntent' | 'setPaymentMethod' | 'getCustomer' | 'setCustomer' | 'listInvoices' | 'getBillingReadonly' | 'getWorkspaceUsages' | 'getAutoRechargeSettings' | 'setAutoRechargeSettings' | 'payInvoice' | 'cancelPendingSubscriptionUpgrade'> &
186
186
  /**
187
- * `getWorkspaceMember` lives on the generic `@botpress/client`, not the
188
- * billing client, but is REQUIRED here: `useIsAuthorized` depends on it to
189
- * check the caller's workspace membership. Every host must pass a client
190
- * object that also exposes it. Still type-only — no runtime dep.
187
+ * `getWorkspaceMember` and `saveWorkspaceCancellationReasons` live on the
188
+ * generic `@botpress/client`, not the billing client, but are REQUIRED here:
189
+ * `useIsAuthorized` checks the caller's workspace membership, and the
190
+ * downgrade flow saves the cancellation survey answers. Every host must pass
191
+ * a client object that also exposes them. Still type-only — no runtime dep.
191
192
  */
192
- Pick<Client, 'getWorkspaceMember'> &
193
+ Pick<Client, 'getWorkspaceMember' | 'saveWorkspaceCancellationReasons'> &
193
194
  /**
194
195
  * Per-bot usage breakdown is OPTIONAL: those methods also live on the
195
196
  * generic `@botpress/client`, but only a host that wants the per-bot view
196
197
  * needs to pass a client exposing them. Omit them and the UsageDashboard
197
198
  * hides the per-bot section.
198
199
  */
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
- };
200
+ Partial<Pick<Client, 'breakDownWorkspaceUsageByBot' | 'listBots'>>;
206
201
 
207
202
  export declare type BillingColorScheme = 'default' | 'neutral';
208
203
 
@@ -1200,7 +1195,7 @@ export declare function usePlans(): UseQueryResult<Plan[], Error>;
1200
1195
 
1201
1196
  export declare const UsersIcon: ({ size, ...props }: IconProps) => JSX.Element;
1202
1197
 
1203
- /** Persists the cancellation survey answers. */
1198
+ /** Persists the cancellation survey answers; no-op without BillingProvider's `workspaceId`. */
1204
1199
  export declare function useSaveCancellationFeedback(): UseMutationResult<void, Error, CancellationFeedback>;
1205
1200
 
1206
1201
  /** Absolute add-on quantities for the current subscription (0 removes an add-on). */
package/dist/index.js CHANGED
@@ -3978,11 +3978,15 @@ function ys() {
3978
3978
  );
3979
3979
  }
3980
3980
  function Wi() {
3981
- const { client: a, queryClient: e } = X();
3981
+ const { client: a, queryClient: e, scope: t } = X();
3982
3982
  return ba(
3983
3983
  {
3984
- mutationFn: async (t) => {
3985
- await a.saveCancellationFeedback(t);
3984
+ mutationFn: async (n) => {
3985
+ t !== "default" && await a.saveWorkspaceCancellationReasons({
3986
+ id: t,
3987
+ reasons: [n.reason],
3988
+ comment: n.comment
3989
+ });
3986
3990
  }
3987
3991
  },
3988
3992
  e