@iblai/iblai-js 2.72.0 → 2.73.1
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/data-layer/playwright/billing-tab-helpers.d.ts +61 -48
- package/dist/data-layer/playwright/credit-balance-helpers.d.ts +40 -18
- package/dist/data-layer/playwright/index.d.ts +3 -2
- package/dist/data-layer/playwright/plan-picker-helpers.d.ts +26 -0
- package/dist/data-layer/playwright/spend-limits-helpers.d.ts +5 -4
- package/dist/playwright/index.cjs +306 -193
- package/dist/playwright/index.cjs.map +1 -1
- package/dist/playwright/index.d.ts +133 -71
- package/dist/playwright/index.esm.js +293 -194
- package/dist/playwright/index.esm.js.map +1 -1
- package/dist/playwright/playwright/billing-tab-helpers.d.ts +61 -48
- package/dist/playwright/playwright/credit-balance-helpers.d.ts +40 -18
- package/dist/playwright/playwright/index.d.ts +3 -2
- package/dist/playwright/playwright/plan-picker-helpers.d.ts +26 -0
- package/dist/playwright/playwright/spend-limits-helpers.d.ts +5 -4
- package/dist/security/playwright/billing-tab-helpers.d.ts +61 -48
- package/dist/security/playwright/credit-balance-helpers.d.ts +40 -18
- package/dist/security/playwright/index.d.ts +3 -2
- package/dist/security/playwright/plan-picker-helpers.d.ts +26 -0
- package/dist/security/playwright/spend-limits-helpers.d.ts +5 -4
- package/dist/web-containers/playwright/billing-tab-helpers.d.ts +61 -48
- package/dist/web-containers/playwright/credit-balance-helpers.d.ts +40 -18
- package/dist/web-containers/playwright/index.d.ts +3 -2
- package/dist/web-containers/playwright/plan-picker-helpers.d.ts +26 -0
- package/dist/web-containers/playwright/spend-limits-helpers.d.ts +5 -4
- package/dist/web-containers/source/add-credits-modal.js +170 -24
- package/dist/web-containers/source/add-credits-modal.js.map +1 -1
- package/dist/web-containers/source/auto-recharge-modal.js +1 -1
- package/dist/web-containers/source/auto-recharge-modal.js.map +1 -1
- package/dist/web-containers/source/billing-credits.js +4 -4
- package/dist/web-containers/source/billing-credits.js.map +1 -1
- package/dist/web-containers/source/billing.js +60 -101
- package/dist/web-containers/source/billing.js.map +1 -1
- package/dist/web-containers/source/components/credit-balance.js +44 -72
- package/dist/web-containers/source/components/credit-balance.js.map +1 -1
- package/dist/web-containers/source/components/modals/contact-admin-modal.js +32 -0
- package/dist/web-containers/source/components/modals/contact-admin-modal.js.map +1 -0
- package/dist/web-containers/source/components/modals/upgrade-package-modal.js +281 -20
- package/dist/web-containers/source/components/modals/upgrade-package-modal.js.map +1 -1
- package/dist/web-containers/source/components/profile/add-credits-modal.js +170 -24
- package/dist/web-containers/source/components/profile/add-credits-modal.js.map +1 -1
- package/dist/web-containers/source/components/profile/auto-recharge-modal.js +1 -1
- package/dist/web-containers/source/components/profile/auto-recharge-modal.js.map +1 -1
- package/dist/web-containers/source/components/profile/billing-credits.js +4 -4
- package/dist/web-containers/source/components/profile/billing-credits.js.map +1 -1
- package/dist/web-containers/source/components/profile/billing.js +60 -101
- package/dist/web-containers/source/components/profile/billing.js.map +1 -1
- package/dist/web-containers/source/components/profile/pending-credit-top-up.js +202 -0
- package/dist/web-containers/source/components/profile/pending-credit-top-up.js.map +1 -0
- package/dist/web-containers/source/components/profile/use-complete-pending-credit-top-up.js +68 -0
- package/dist/web-containers/source/components/profile/use-complete-pending-credit-top-up.js.map +1 -0
- package/dist/web-containers/source/components/subscription-top-banner.js +119 -0
- package/dist/web-containers/source/components/subscription-top-banner.js.map +1 -0
- package/dist/web-containers/source/components/workflows/workflow-editor.js +28 -8
- package/dist/web-containers/source/components/workflows/workflow-editor.js.map +1 -1
- package/dist/web-containers/source/contact-admin-modal.js +32 -0
- package/dist/web-containers/source/contact-admin-modal.js.map +1 -0
- package/dist/web-containers/source/credit-balance.js +44 -72
- package/dist/web-containers/source/credit-balance.js.map +1 -1
- package/dist/web-containers/source/en.json.js +121 -21
- package/dist/web-containers/source/en.json.js.map +1 -1
- package/dist/web-containers/source/es.json.js +123 -23
- package/dist/web-containers/source/es.json.js.map +1 -1
- package/dist/web-containers/source/fr.json.js +121 -21
- package/dist/web-containers/source/fr.json.js.map +1 -1
- package/dist/web-containers/source/i18n/messages/en.json.js +121 -21
- package/dist/web-containers/source/i18n/messages/en.json.js.map +1 -1
- package/dist/web-containers/source/i18n/messages/es.json.js +123 -23
- package/dist/web-containers/source/i18n/messages/es.json.js.map +1 -1
- package/dist/web-containers/source/i18n/messages/fr.json.js +121 -21
- package/dist/web-containers/source/i18n/messages/fr.json.js.map +1 -1
- package/dist/web-containers/source/i18n/messages/zh.json.js +122 -22
- package/dist/web-containers/source/i18n/messages/zh.json.js.map +1 -1
- package/dist/web-containers/source/messages/en.json.js +121 -21
- package/dist/web-containers/source/messages/en.json.js.map +1 -1
- package/dist/web-containers/source/messages/es.json.js +123 -23
- package/dist/web-containers/source/messages/es.json.js.map +1 -1
- package/dist/web-containers/source/messages/fr.json.js +121 -21
- package/dist/web-containers/source/messages/fr.json.js.map +1 -1
- package/dist/web-containers/source/messages/zh.json.js +122 -22
- package/dist/web-containers/source/messages/zh.json.js.map +1 -1
- package/dist/web-containers/source/modals/contact-admin-modal.js +32 -0
- package/dist/web-containers/source/modals/contact-admin-modal.js.map +1 -0
- package/dist/web-containers/source/modals/upgrade-package-modal.js +281 -20
- package/dist/web-containers/source/modals/upgrade-package-modal.js.map +1 -1
- package/dist/web-containers/source/pending-credit-top-up.js +202 -0
- package/dist/web-containers/source/pending-credit-top-up.js.map +1 -0
- package/dist/web-containers/source/profile/add-credits-modal.js +170 -24
- package/dist/web-containers/source/profile/add-credits-modal.js.map +1 -1
- package/dist/web-containers/source/profile/auto-recharge-modal.js +1 -1
- package/dist/web-containers/source/profile/auto-recharge-modal.js.map +1 -1
- package/dist/web-containers/source/profile/billing-credits.js +4 -4
- package/dist/web-containers/source/profile/billing-credits.js.map +1 -1
- package/dist/web-containers/source/profile/billing.js +60 -101
- package/dist/web-containers/source/profile/billing.js.map +1 -1
- package/dist/web-containers/source/profile/pending-credit-top-up.js +202 -0
- package/dist/web-containers/source/profile/pending-credit-top-up.js.map +1 -0
- package/dist/web-containers/source/profile/use-complete-pending-credit-top-up.js +68 -0
- package/dist/web-containers/source/profile/use-complete-pending-credit-top-up.js.map +1 -0
- package/dist/web-containers/source/subscription-top-banner.js +119 -0
- package/dist/web-containers/source/subscription-top-banner.js.map +1 -0
- package/dist/web-containers/source/tsconfig.build.tsbuildinfo +1 -1
- package/dist/web-containers/source/upgrade-package-modal.js +281 -20
- package/dist/web-containers/source/upgrade-package-modal.js.map +1 -1
- package/dist/web-containers/source/use-complete-pending-credit-top-up.js +68 -0
- package/dist/web-containers/source/use-complete-pending-credit-top-up.js.map +1 -0
- package/dist/web-containers/source/web-containers/tsconfig.build.tsbuildinfo +1 -1
- package/dist/web-containers/source/workflow-editor.js +28 -8
- package/dist/web-containers/source/workflow-editor.js.map +1 -1
- package/dist/web-containers/source/workflows/workflow-editor.js +28 -8
- package/dist/web-containers/source/workflows/workflow-editor.js.map +1 -1
- package/dist/web-containers/source/zh.json.js +122 -22
- package/dist/web-containers/source/zh.json.js.map +1 -1
- package/dist/web-utils/playwright/billing-tab-helpers.d.ts +61 -48
- package/dist/web-utils/playwright/credit-balance-helpers.d.ts +40 -18
- package/dist/web-utils/playwright/index.d.ts +3 -2
- package/dist/web-utils/playwright/plan-picker-helpers.d.ts +26 -0
- package/dist/web-utils/playwright/spend-limits-helpers.d.ts +5 -4
- package/package.json +5 -5
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A credit top-up that has to wait for a payment method.
|
|
3
|
+
*
|
|
4
|
+
* Someone without a card on file still just presses "Add Credits" and types an
|
|
5
|
+
* amount. We then send them to the Stripe customer portal to save a card, and
|
|
6
|
+
* when Stripe brings them back we charge that amount and add the credits —
|
|
7
|
+
* one trip instead of "add a card, come back, open Add Credits again".
|
|
8
|
+
*
|
|
9
|
+
* The amount travels on the portal's after-completion URL so the return page
|
|
10
|
+
* knows what was asked for, but the URL alone never charges anything: the
|
|
11
|
+
* amount is also written to localStorage under a one-time nonce before the
|
|
12
|
+
* redirect, and the charge only runs when the URL's nonce, amount and tenant
|
|
13
|
+
* all match that record and it is still fresh. The record is deleted the
|
|
14
|
+
* moment it is claimed, so a reload (or a second mounted surface) can't charge
|
|
15
|
+
* twice, and a crafted link can't charge an amount the person never entered.
|
|
16
|
+
*
|
|
17
|
+
* localStorage (not sessionStorage) because the Stripe portal is a full
|
|
18
|
+
* navigation and some hosts open it in a new tab.
|
|
19
|
+
*/
|
|
20
|
+
const PENDING_CREDIT_TOP_UP_STORAGE_KEY = 'ibl_pending_credit_top_up';
|
|
21
|
+
/** Query params appended to the portal's after-completion URL. */
|
|
22
|
+
const CREDIT_TOP_UP_QUERY_PARAMS = {
|
|
23
|
+
nonce: 'credit_topup',
|
|
24
|
+
amount: 'credit_topup_amount',
|
|
25
|
+
};
|
|
26
|
+
/** A top-up that is not claimed within the hour is forgotten. */
|
|
27
|
+
const PENDING_CREDIT_TOP_UP_TTL_MS = 60 * 60 * 1000;
|
|
28
|
+
function getStorage() {
|
|
29
|
+
try {
|
|
30
|
+
if (typeof window === 'undefined' || !window.localStorage)
|
|
31
|
+
return null;
|
|
32
|
+
return window.localStorage;
|
|
33
|
+
}
|
|
34
|
+
catch (_a) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function createNonce() {
|
|
39
|
+
const cryptoApi = typeof globalThis !== 'undefined' ? globalThis.crypto : undefined;
|
|
40
|
+
if (cryptoApi && typeof cryptoApi.randomUUID === 'function') {
|
|
41
|
+
return cryptoApi.randomUUID();
|
|
42
|
+
}
|
|
43
|
+
return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 12)}`;
|
|
44
|
+
}
|
|
45
|
+
/** Normalises any accepted amount input to the "25.00" form stored and sent. */
|
|
46
|
+
function normaliseTopUpAmountUsd(amount) {
|
|
47
|
+
const num = typeof amount === 'string' ? parseFloat(amount) : amount;
|
|
48
|
+
if (!Number.isFinite(num) || num <= 0)
|
|
49
|
+
return null;
|
|
50
|
+
return num.toFixed(2);
|
|
51
|
+
}
|
|
52
|
+
/** The pending record, if one is stored, well-formed and not expired. */
|
|
53
|
+
function readPendingCreditTopUp(now = Date.now()) {
|
|
54
|
+
const storage = getStorage();
|
|
55
|
+
if (!storage)
|
|
56
|
+
return null;
|
|
57
|
+
const raw = storage.getItem(PENDING_CREDIT_TOP_UP_STORAGE_KEY);
|
|
58
|
+
if (!raw)
|
|
59
|
+
return null;
|
|
60
|
+
try {
|
|
61
|
+
const parsed = JSON.parse(raw);
|
|
62
|
+
if (!parsed ||
|
|
63
|
+
typeof parsed.nonce !== 'string' ||
|
|
64
|
+
typeof parsed.amountUsd !== 'string' ||
|
|
65
|
+
typeof parsed.tenant !== 'string' ||
|
|
66
|
+
typeof parsed.createdAt !== 'number') {
|
|
67
|
+
storage.removeItem(PENDING_CREDIT_TOP_UP_STORAGE_KEY);
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
if (now - parsed.createdAt > PENDING_CREDIT_TOP_UP_TTL_MS) {
|
|
71
|
+
storage.removeItem(PENDING_CREDIT_TOP_UP_STORAGE_KEY);
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
return parsed;
|
|
75
|
+
}
|
|
76
|
+
catch (_a) {
|
|
77
|
+
storage.removeItem(PENDING_CREDIT_TOP_UP_STORAGE_KEY);
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function clearPendingCreditTopUp() {
|
|
82
|
+
var _a;
|
|
83
|
+
(_a = getStorage()) === null || _a === void 0 ? void 0 : _a.removeItem(PENDING_CREDIT_TOP_UP_STORAGE_KEY);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Records the top-up to finish after the payment method is saved and returns
|
|
87
|
+
* the URL Stripe should send the person back to: `currentUrl` plus the amount
|
|
88
|
+
* and the one-time nonce. Any existing query (e.g. `profileTab=billing`) is
|
|
89
|
+
* kept so the person lands where they left.
|
|
90
|
+
*/
|
|
91
|
+
function beginPendingCreditTopUp({ tenant, amountUsd, currentUrl, now = Date.now(), }) {
|
|
92
|
+
var _a;
|
|
93
|
+
const pending = {
|
|
94
|
+
nonce: createNonce(),
|
|
95
|
+
amountUsd,
|
|
96
|
+
tenant,
|
|
97
|
+
createdAt: now,
|
|
98
|
+
};
|
|
99
|
+
(_a = getStorage()) === null || _a === void 0 ? void 0 : _a.setItem(PENDING_CREDIT_TOP_UP_STORAGE_KEY, JSON.stringify(pending));
|
|
100
|
+
const url = new URL(currentUrl);
|
|
101
|
+
url.searchParams.set(CREDIT_TOP_UP_QUERY_PARAMS.nonce, pending.nonce);
|
|
102
|
+
url.searchParams.set(CREDIT_TOP_UP_QUERY_PARAMS.amount, pending.amountUsd);
|
|
103
|
+
return { pending, afterCompletionUrl: url.toString() };
|
|
104
|
+
}
|
|
105
|
+
/** True when the URL carries the top-up return params at all. */
|
|
106
|
+
function hasPendingCreditTopUpParams(url) {
|
|
107
|
+
try {
|
|
108
|
+
return new URL(url).searchParams.has(CREDIT_TOP_UP_QUERY_PARAMS.nonce);
|
|
109
|
+
}
|
|
110
|
+
catch (_a) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/** The same URL without the top-up return params (for `history.replaceState`). */
|
|
115
|
+
function stripPendingCreditTopUpParams(url) {
|
|
116
|
+
try {
|
|
117
|
+
const parsed = new URL(url);
|
|
118
|
+
parsed.searchParams.delete(CREDIT_TOP_UP_QUERY_PARAMS.nonce);
|
|
119
|
+
parsed.searchParams.delete(CREDIT_TOP_UP_QUERY_PARAMS.amount);
|
|
120
|
+
return parsed.toString();
|
|
121
|
+
}
|
|
122
|
+
catch (_a) {
|
|
123
|
+
return url;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Claims the top-up the URL refers to: returns it, and deletes the stored
|
|
128
|
+
* record, only when the URL's nonce and amount match the record for this
|
|
129
|
+
* tenant. Returns null (and leaves nothing to claim) otherwise.
|
|
130
|
+
*/
|
|
131
|
+
function claimPendingCreditTopUp({ url, tenant, now = Date.now(), }) {
|
|
132
|
+
let params;
|
|
133
|
+
try {
|
|
134
|
+
params = new URL(url).searchParams;
|
|
135
|
+
}
|
|
136
|
+
catch (_a) {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
const nonce = params.get(CREDIT_TOP_UP_QUERY_PARAMS.nonce);
|
|
140
|
+
const amount = params.get(CREDIT_TOP_UP_QUERY_PARAMS.amount);
|
|
141
|
+
if (!nonce || !amount)
|
|
142
|
+
return null;
|
|
143
|
+
const pending = readPendingCreditTopUp(now);
|
|
144
|
+
if (!pending)
|
|
145
|
+
return null;
|
|
146
|
+
if (pending.nonce !== nonce || pending.tenant !== tenant)
|
|
147
|
+
return null;
|
|
148
|
+
if (normaliseTopUpAmountUsd(amount) !== pending.amountUsd)
|
|
149
|
+
return null;
|
|
150
|
+
clearPendingCreditTopUp();
|
|
151
|
+
return pending;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* The backend's plain-sentence refusal from a rejected top-up call, whatever
|
|
155
|
+
* shape the data layer threw it in (`{ data: { detail } }`, `{ data: 'text' }`
|
|
156
|
+
* or a bare `{ detail }`). Undefined when there is none.
|
|
157
|
+
*/
|
|
158
|
+
function readTopUpErrorDetail(error) {
|
|
159
|
+
if (!error || typeof error !== 'object')
|
|
160
|
+
return undefined;
|
|
161
|
+
const err = error;
|
|
162
|
+
if (typeof err.data === 'string' && err.data.trim())
|
|
163
|
+
return err.data;
|
|
164
|
+
if (err.data && typeof err.data === 'object') {
|
|
165
|
+
const detail = err.data.detail;
|
|
166
|
+
if (typeof detail === 'string' && detail.trim())
|
|
167
|
+
return detail;
|
|
168
|
+
}
|
|
169
|
+
if (typeof err.detail === 'string' && err.detail.trim())
|
|
170
|
+
return err.detail;
|
|
171
|
+
return undefined;
|
|
172
|
+
}
|
|
173
|
+
function readStringField(body, key) {
|
|
174
|
+
if (!body || typeof body !== 'object')
|
|
175
|
+
return undefined;
|
|
176
|
+
const value = body[key];
|
|
177
|
+
return typeof value === 'string' && value.trim() ? value : undefined;
|
|
178
|
+
}
|
|
179
|
+
function readTopUpError(error) {
|
|
180
|
+
if (!error || typeof error !== 'object')
|
|
181
|
+
return {};
|
|
182
|
+
const err = error;
|
|
183
|
+
const body = err.data && typeof err.data === 'object' ? err.data : error;
|
|
184
|
+
return {
|
|
185
|
+
detail: readTopUpErrorDetail(error),
|
|
186
|
+
code: readStringField(body, 'code'),
|
|
187
|
+
errorType: readStringField(body, 'error_type'),
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
/** Refusals that saving a (new) card on Stripe fixes. */
|
|
191
|
+
const PAYMENT_METHOD_ERROR_TYPES = new Set(['card_error', 'payment_method_error']);
|
|
192
|
+
/**
|
|
193
|
+
* True when the backend refused the top-up because of the payment method:
|
|
194
|
+
* the card on file was refused (expired, declined, …) or there is none.
|
|
195
|
+
*/
|
|
196
|
+
function isPaymentMethodProblem(error) {
|
|
197
|
+
const { errorType } = readTopUpError(error);
|
|
198
|
+
return errorType !== undefined && PAYMENT_METHOD_ERROR_TYPES.has(errorType);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export { CREDIT_TOP_UP_QUERY_PARAMS, PENDING_CREDIT_TOP_UP_STORAGE_KEY, PENDING_CREDIT_TOP_UP_TTL_MS, beginPendingCreditTopUp, claimPendingCreditTopUp, clearPendingCreditTopUp, hasPendingCreditTopUpParams, isPaymentMethodProblem, normaliseTopUpAmountUsd, readPendingCreditTopUp, readTopUpError, readTopUpErrorDetail, stripPendingCreditTopUpParams };
|
|
202
|
+
//# sourceMappingURL=pending-credit-top-up.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pending-credit-top-up.js","sources":["../../../../../../../src/components/profile/pending-credit-top-up.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;AAkBG;AAEI,MAAM,i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AC3C,OAAO,SAAS,KAAK,SAAS,IAAI,0BAA0B,CAAC,GAAG,CAAC,SAAS,CAAC;AAC7E;;;;"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { useState, useRef, useEffect } from 'react';
|
|
2
|
+
import { useTriggerAutoRechargeMutation } from '@iblai/data-layer';
|
|
3
|
+
import { toast } from 'sonner';
|
|
4
|
+
import { useT } from '../../i18n/context.js';
|
|
5
|
+
import '../../packages/i18n/dist/index.esm.js';
|
|
6
|
+
import { hasPendingCreditTopUpParams, claimPendingCreditTopUp, stripPendingCreditTopUpParams, readTopUpErrorDetail } from './pending-credit-top-up.js';
|
|
7
|
+
|
|
8
|
+
function formatUsd(amount) {
|
|
9
|
+
const num = parseFloat(amount);
|
|
10
|
+
return Number.isFinite(num) ? `$${num.toFixed(2)}` : `$${amount}`;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Finishes a credit top-up that was waiting for a payment method (see
|
|
14
|
+
* `pending-credit-top-up.ts`). Mount it on every surface that offers
|
|
15
|
+
* "Add Credits" — the Billing tab and the navbar credit dropdown — so whichever
|
|
16
|
+
* one is on the page Stripe returns to charges the saved card for the amount
|
|
17
|
+
* the person entered, adds the credits, and says so in a toast. The billing
|
|
18
|
+
* query is invalidated by the mutation, so the balance on screen updates too.
|
|
19
|
+
*
|
|
20
|
+
* Claiming deletes the stored record first, so with both surfaces mounted only
|
|
21
|
+
* the first effect to run charges; the other finds nothing. The return params
|
|
22
|
+
* are removed from the address bar either way so a reload can't replay them.
|
|
23
|
+
*/
|
|
24
|
+
function useCompletePendingCreditTopUp({ tenant, enabled = true, }) {
|
|
25
|
+
const t = useT();
|
|
26
|
+
const [triggerAutoRecharge] = useTriggerAutoRechargeMutation();
|
|
27
|
+
const [isCompleting, setIsCompleting] = useState(false);
|
|
28
|
+
const startedRef = useRef(false);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (!enabled || !tenant || startedRef.current)
|
|
31
|
+
return;
|
|
32
|
+
if (typeof window === 'undefined')
|
|
33
|
+
return;
|
|
34
|
+
const currentUrl = window.location.href;
|
|
35
|
+
if (!hasPendingCreditTopUpParams(currentUrl))
|
|
36
|
+
return;
|
|
37
|
+
startedRef.current = true;
|
|
38
|
+
const pending = claimPendingCreditTopUp({ url: currentUrl, tenant });
|
|
39
|
+
// A null state lets Next's patched replaceState sync the app router (and
|
|
40
|
+
// useSearchParams) with the new URL. Handing window.history.state back
|
|
41
|
+
// carries Next's internal marker, which makes it skip that sync, and a
|
|
42
|
+
// later router.replace built from the stale params would put the nonce
|
|
43
|
+
// and amount back in the address bar.
|
|
44
|
+
window.history.replaceState(null, '', stripPendingCreditTopUpParams(currentUrl));
|
|
45
|
+
if (!pending)
|
|
46
|
+
return;
|
|
47
|
+
setIsCompleting(true);
|
|
48
|
+
const toastId = toast.loading(t('profileAddCreditsModal.addingCredits'));
|
|
49
|
+
triggerAutoRecharge({ amount_usd: pending.amountUsd, platform_key: tenant })
|
|
50
|
+
.unwrap()
|
|
51
|
+
.then(() => {
|
|
52
|
+
toast.success(t('profileAddCreditsModal.creditsAddedAfterPayment', {
|
|
53
|
+
amount: formatUsd(pending.amountUsd),
|
|
54
|
+
}), { id: toastId });
|
|
55
|
+
})
|
|
56
|
+
.catch((error) => {
|
|
57
|
+
var _a;
|
|
58
|
+
toast.error((_a = readTopUpErrorDetail(error)) !== null && _a !== void 0 ? _a : t('profileAddCreditsModal.failedToAddCreditsAfterPayment'), { id: toastId });
|
|
59
|
+
})
|
|
60
|
+
.finally(() => setIsCompleting(false));
|
|
61
|
+
// The claim is one-shot by design (startedRef): re-runs from a changed
|
|
62
|
+
// dependency find nothing left to do.
|
|
63
|
+
}, [enabled, tenant, t, triggerAutoRecharge]);
|
|
64
|
+
return { isCompleting };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export { useCompletePendingCreditTopUp };
|
|
68
|
+
//# sourceMappingURL=use-complete-pending-credit-top-up.js.map
|
package/dist/web-containers/source/components/profile/use-complete-pending-credit-top-up.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-complete-pending-credit-top-up.js","sources":["../../../../../../../src/components/profile/use-complete-pending-credit-top-up.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAaA,SAAS,SAAS,CAAC,MAAc,EAAA;AAC/B,IAAA,MAAM,GAAG,GAAG,UAAU,CAAC,MAAM,CAAC;IAC9B,OAAO,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAA,CAAA,EAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA,CAAE,GAAG,CAAA,CAAA,EAAI,MAAM,CAAA,CAAE;AACnE;AAEA;;;;;;;;;;;AAWG;AACG,SAAU,6BAA6B,CAAC,EAC5C,MAAM,EACN,OAAO,GAAG,IAAI,GAIf,EAAA;AACC,IAAA,MAAM,CAAC,GAAG,IAAI,EAAE;AAChB,IAAA,MAAM,CAAC,mBAAmB,CAAC,GAAG,8BAA8B,EAAE;IAC9D,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;AACvD,IAAA,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC;IAEhC,SAAS,CAAC,MAAK;QACb,IAAI,CAAC,OAAO,IAAI,CAAC,MAAM,IAAI,UAAU,CAAC,OAAO;YAAE;QAC/C,IAAI,OAAO,MAAM,KAAK,WAAW;YAAE;AACnC,QAAA,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI;AACvC,QAAA,IAAI,CAAC,2BAA2B,CAAC,UAAU,CAAC;YAAE;AAE9C,QAAA,UAAU,CAAC,OAAO,GAAG,IAAI;AACzB,QAAA,MAAM,OAAO,GAAG,uBAAuB,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;;;;;;AAMpE,QAAA,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,6BAA6B,CAAC,UAAU,CAAC,CAAC;AAChF,QAAA,IAAI,CAAC,OAAO;YAAE;QAEd,eAAe,CAAC,IAAI,CAAC;QACrB,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,sCAAsC,CAAC,CAAC;AACxE,QAAA,mBAAmB,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE;AACxE,aAAA,MAAM;aACN,IAAI,CAAC,MAAK;AACT,YAAA,KAAK,CAAC,OAAO,CACX,CAAC,CAAC,iDAAiD,EAAE;AACnD,gBAAA,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC;AACrC,aAAA,CAAC,EACF,EAAE,EAAE,EAAE,OAAO,EAAE,CAChB;AACH,QAAA,CAAC;AACA,aAAA,KAAK,CAAC,CAAC,KAAc,KAAI;;YACxB,KAAK,CAAC,KAAK,CACT,CAAA,EAAA,GAAA,oBAAoB,CAAC,KAAK,CAAC,MAAA,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,EAAA,GAAI,CAAC,CAAC,uDAAuD,CAAC,EACzF,EAAE,EAAE,EAAE,OAAO,EAAE,CAChB;AACH,QAAA,CAAC;aACA,OAAO,CAAC,MAAM,eAAe,CAAC,KAAK,CAAC,CAAC;;;IAG1C,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,mBAAmB,CAAC,CAAC;IAE7C,OAAO,EAAE,YAAY,EAAE;AACzB;;;;"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
3
|
+
import { useSelector } from 'react-redux';
|
|
4
|
+
import { useIsStripeActivated, useTopBannerButtonHandler, isLoggedIn, SUBSCRIPTION_BANNER_PARENT_SELECTOR } from '@iblai/web-utils';
|
|
5
|
+
import { useT } from '../i18n/context.js';
|
|
6
|
+
import '../packages/i18n/dist/index.esm.js';
|
|
7
|
+
import { TopBanner } from './top-banner/index.js';
|
|
8
|
+
|
|
9
|
+
const byId = (selector) => document.querySelector(selector);
|
|
10
|
+
/**
|
|
11
|
+
* The credits banner across the top of the app ("You've run out of credits…"),
|
|
12
|
+
* driven by the `topBanner` slice the subscription flow writes to. A non-admin
|
|
13
|
+
* whose organization ran out gets `ContactAdminModal` instead. Its button does what
|
|
14
|
+
* `useTopBannerButtonHandler` maps the banner's trigger to. Shows only for a
|
|
15
|
+
* signed-in person on a tenant with billing on.
|
|
16
|
+
*
|
|
17
|
+
* While shown it shortens the sidebar shell (`[data-slot="sidebar-*"]`) and
|
|
18
|
+
* the main content container by its own height so nothing scrolls under it,
|
|
19
|
+
* and puts everything back when closed.
|
|
20
|
+
*/
|
|
21
|
+
function SubscriptionTopBanner({ hidden = false, parentContainerSelector = SUBSCRIPTION_BANNER_PARENT_SELECTOR, }) {
|
|
22
|
+
const t = useT();
|
|
23
|
+
const stripeActivated = useIsStripeActivated();
|
|
24
|
+
const topBannerOptions = useSelector((state) => { var _a; return (_a = state.topBanner) === null || _a === void 0 ? void 0 : _a.topBannerOptions; });
|
|
25
|
+
const getTopBannerButtonHandler = useTopBannerButtonHandler();
|
|
26
|
+
const [initialStyles, setInitialStyles] = useState({});
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
const sideBarWrapper = byId('[data-slot="sidebar-wrapper"]');
|
|
29
|
+
const mainContentContainer = byId('#main-content-container > div');
|
|
30
|
+
const sidebarContainer = byId('[data-slot="sidebar-container"]');
|
|
31
|
+
const sidebarInset = byId('[data-slot="sidebar-inset"]');
|
|
32
|
+
const body = byId('body');
|
|
33
|
+
setInitialStyles({
|
|
34
|
+
sideBarWrapper: sideBarWrapper
|
|
35
|
+
? {
|
|
36
|
+
maxHeight: sideBarWrapper.style.maxHeight,
|
|
37
|
+
top: sideBarWrapper.style.top,
|
|
38
|
+
position: sideBarWrapper.style.position,
|
|
39
|
+
}
|
|
40
|
+
: undefined,
|
|
41
|
+
mainContentContainer: mainContentContainer
|
|
42
|
+
? {
|
|
43
|
+
position: mainContentContainer.style.position,
|
|
44
|
+
top: mainContentContainer.style.top,
|
|
45
|
+
}
|
|
46
|
+
: undefined,
|
|
47
|
+
sidebarContainer: sidebarContainer
|
|
48
|
+
? { top: sidebarContainer.style.top, height: sidebarContainer.style.height }
|
|
49
|
+
: undefined,
|
|
50
|
+
sidebarInset: sidebarInset
|
|
51
|
+
? { top: sidebarInset.style.top, height: sidebarInset.style.height }
|
|
52
|
+
: undefined,
|
|
53
|
+
body: body ? { overflow: body.style.overflow } : undefined,
|
|
54
|
+
});
|
|
55
|
+
}, []);
|
|
56
|
+
const handleTopBannerLoad = (bannerRef) => {
|
|
57
|
+
if (!bannerRef)
|
|
58
|
+
return;
|
|
59
|
+
const bannerHeight = bannerRef.clientHeight;
|
|
60
|
+
const sideBarWrapper = byId('[data-slot="sidebar-wrapper"]');
|
|
61
|
+
if (sideBarWrapper) {
|
|
62
|
+
sideBarWrapper.style.maxHeight = `calc(100vh - ${bannerHeight}px)`;
|
|
63
|
+
sideBarWrapper.style.top = '3px';
|
|
64
|
+
sideBarWrapper.style.position = 'relative';
|
|
65
|
+
}
|
|
66
|
+
const mainContentContainer = byId('#main-content-container > div');
|
|
67
|
+
if (mainContentContainer) {
|
|
68
|
+
mainContentContainer.style.position = 'relative';
|
|
69
|
+
mainContentContainer.style.top = '-12px';
|
|
70
|
+
}
|
|
71
|
+
const sidebarContainer = byId('[data-slot="sidebar-container"]');
|
|
72
|
+
if (sidebarContainer) {
|
|
73
|
+
sidebarContainer.style.top = '48px';
|
|
74
|
+
sidebarContainer.style.height = `calc(100% - ${bannerHeight}px)`;
|
|
75
|
+
}
|
|
76
|
+
const sidebarInset = byId('[data-slot="sidebar-inset"]');
|
|
77
|
+
if (sidebarInset) {
|
|
78
|
+
sidebarInset.style.height = `calc(100dvh - ${bannerHeight}px)`;
|
|
79
|
+
}
|
|
80
|
+
const body = byId('body');
|
|
81
|
+
if (body) {
|
|
82
|
+
body.style.overflow = 'hidden';
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const handleTopBannerClose = () => {
|
|
86
|
+
var _a;
|
|
87
|
+
const sideBarWrapper = byId('[data-slot="sidebar-wrapper"]');
|
|
88
|
+
if (sideBarWrapper && initialStyles.sideBarWrapper) {
|
|
89
|
+
sideBarWrapper.style.maxHeight = initialStyles.sideBarWrapper.maxHeight;
|
|
90
|
+
sideBarWrapper.style.top = initialStyles.sideBarWrapper.top;
|
|
91
|
+
sideBarWrapper.style.position = initialStyles.sideBarWrapper.position;
|
|
92
|
+
}
|
|
93
|
+
const mainContentContainer = byId('#main-content-container > div');
|
|
94
|
+
if (mainContentContainer && initialStyles.mainContentContainer) {
|
|
95
|
+
mainContentContainer.style.position = initialStyles.mainContentContainer.position;
|
|
96
|
+
mainContentContainer.style.top = initialStyles.mainContentContainer.top;
|
|
97
|
+
}
|
|
98
|
+
const sidebarContainer = byId('[data-slot="sidebar-container"]');
|
|
99
|
+
if (sidebarContainer && initialStyles.sidebarContainer) {
|
|
100
|
+
sidebarContainer.style.top = initialStyles.sidebarContainer.top;
|
|
101
|
+
sidebarContainer.style.height = initialStyles.sidebarContainer.height;
|
|
102
|
+
}
|
|
103
|
+
const sidebarInset = byId('[data-slot="sidebar-inset"]');
|
|
104
|
+
if (sidebarInset && initialStyles.sidebarInset) {
|
|
105
|
+
sidebarInset.style.height = initialStyles.sidebarInset.height;
|
|
106
|
+
}
|
|
107
|
+
const body = byId('body');
|
|
108
|
+
if (body) {
|
|
109
|
+
body.style.overflow = ((_a = initialStyles.body) === null || _a === void 0 ? void 0 : _a.overflow) || 'auto';
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
if (hidden || !(topBannerOptions === null || topBannerOptions === void 0 ? void 0 : topBannerOptions.enabled) || !stripeActivated || !isLoggedIn()) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
return (jsx(TopBanner, { parentContainerSelector: parentContainerSelector, bannerText: topBannerOptions.bannerText, buttonHandler: getTopBannerButtonHandler(topBannerOptions.onUpgrade), buttonLabel: topBannerOptions.buttonLabel || t('creditBalance.upgrade'), loading: topBannerOptions.loading, tooltipText: topBannerOptions.tooltipText, onLoad: handleTopBannerLoad, onClose: handleTopBannerClose }));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export { SubscriptionTopBanner };
|
|
119
|
+
//# sourceMappingURL=subscription-top-banner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscription-top-banner.js","sources":["../../../../../../src/components/subscription-top-banner.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;;;;;AA6BA,MAAM,IAAI,GAAG,CAAC,QAAgB,KAAK,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAuB;AAEzF;;;;;;;;;;AAUG;AACG,SAAU,qBAAqB,CAAC,EACpC,MAAM,GAAG,KAAK,EACd,uBAAuB,GAAG,mCAAmC,GAClC,EAAA;AAC3B,IAAA,MAAM,CAAC,GAAG,IAAI,EAAE;AAChB,IAAA,MAAM,eAAe,GAAG,oBAAoB,EAAE;AAC9C,IAAA,MAAM,gBAAgB,GAAG,WAAW,CAClC,CAAC,KAAqC,KAAI,EAAA,IAAA,EAAA,CAAA,CAAC,OAAA,CAAA,EAAA,GAAA,KAAK,CAAC,SAAS,MAAA,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,MAAA,GAAA,EAAA,CAAE,gBAAgB,CAAA,CAAA,CAAA,CAC7E;AACD,IAAA,MAAM,yBAAyB,GAAG,yBAAyB,EAAE;IAC7D,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAe,EAAE,CAAC;IAEpE,SAAS,CAAC,MAAK;AACb,QAAA,MAAM,cAAc,GAAG,IAAI,CAAC,+BAA+B,CAAC;AAC5D,QAAA,MAAM,oBAAoB,GAAG,IAAI,CAAC,+BAA+B,CAAC;AAClE,QAAA,MAAM,g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IAAI,CAAC,eAAe,IAAI,CAAC,UAAU,EAAE,EAAE;AAC7E,QAAA,OAAO,IAAI;IACb;IAEA,QACEA,GAAA,CAAC,SAAS,EAAA,EACR,uBAAuB,EAAE,uBAAuB,EAChD,UAAU,EAAE,gBAAgB,CAAC,UAAU,EACvC,aAAa,EAAE,yBAAyB,CAAC,gBAAgB,CAAC,SAAS,CAAC,EACpE,WAAW,EAAE,gBAAgB,CAAC,WAAW,IAAI,CAAC,CAAC,uBAAuB,CAAC,EACvE,OAAO,EAAE,gBAAgB,CAAC,OAAO,EACjC,WAAW,EAAE,gBAAgB,CAAC,WAAW,EACzC,MAAM,EAAE,mBAAmB,EAC3B,OAAO,EAAE,oBAAoB,EAAA,CAC7B;AAEN;;;;"}
|
|
@@ -138,7 +138,15 @@ const MENTOR_MESSAGES = [
|
|
|
138
138
|
const NODE_LOCATION = / at nodes\[(\d+)\](\.data)?(?: \(field: ([^()]+)\))?$/;
|
|
139
139
|
const WORKFLOW_LOCATION = / at workflow_\w+(?: \(field: [^()]+\))?$/;
|
|
140
140
|
const QUOTED = /'([^'\s]+)'/g;
|
|
141
|
-
function problemTarget(message, steps, locationOnly = false) {
|
|
141
|
+
function problemTarget(message, steps, locationOnly = false, nodeId) {
|
|
142
|
+
const target = textTarget(message, steps, locationOnly);
|
|
143
|
+
// The step the backend names beats one read from the text, which can quote
|
|
144
|
+
// another step; only the text says which field to focus.
|
|
145
|
+
if (!nodeId || !steps.find(nodeId))
|
|
146
|
+
return target;
|
|
147
|
+
return target.stepId === nodeId ? target : { stepId: nodeId };
|
|
148
|
+
}
|
|
149
|
+
function textTarget(message, steps, locationOnly) {
|
|
142
150
|
if (WORKFLOW_LOCATION.test(message))
|
|
143
151
|
return {};
|
|
144
152
|
// The location names the step at fault; a quoted id in the same message can
|
|
@@ -160,7 +168,7 @@ function problemTarget(message, steps, locationOnly = false) {
|
|
|
160
168
|
}
|
|
161
169
|
return {};
|
|
162
170
|
}
|
|
163
|
-
function toProblem(message, t, steps) {
|
|
171
|
+
function toProblem({ message, nodeId }, t, steps) {
|
|
164
172
|
for (const { pattern, key, params, aboutEveryStep, locationOnly } of MENTOR_MESSAGES) {
|
|
165
173
|
const match = pattern.exec(message);
|
|
166
174
|
if (!match)
|
|
@@ -169,10 +177,21 @@ function toProblem(message, t, steps) {
|
|
|
169
177
|
if (values === null)
|
|
170
178
|
continue;
|
|
171
179
|
const text = t(key, values);
|
|
172
|
-
return aboutEveryStep
|
|
180
|
+
return aboutEveryStep
|
|
181
|
+
? { text }
|
|
182
|
+
: { text, ...problemTarget(message, steps, locationOnly, nodeId) };
|
|
173
183
|
}
|
|
174
|
-
return { text: message, ...problemTarget(message, steps) };
|
|
184
|
+
return { text: message, ...problemTarget(message, steps, false, nodeId) };
|
|
175
185
|
}
|
|
186
|
+
// iblai-dm-pro#3218 lists each message again in error_details /
|
|
187
|
+
// warning_details, in the same order, with the step it is about, and drops the
|
|
188
|
+
// " at nodes[<index>]" ending. A detail whose text differs is not trusted.
|
|
189
|
+
const issuesOf = (messages, details = []) => messages.map((message, index) => {
|
|
190
|
+
const detail = details[index];
|
|
191
|
+
return (detail === null || detail === void 0 ? void 0 : detail.message) === message && detail.node_id
|
|
192
|
+
? { message, nodeId: detail.node_id }
|
|
193
|
+
: { message };
|
|
194
|
+
});
|
|
176
195
|
const distinct = (lines) => Array.from(new Set(lines));
|
|
177
196
|
// A repeated line shows once and goes to the first step it was reported for;
|
|
178
197
|
// once that step is fixed, the next check moves it to the next one.
|
|
@@ -453,9 +472,10 @@ function WorkflowEditor({ tenantKey, workflowId, username, axdToken, baseWsUrl,
|
|
|
453
472
|
// locates problems by position in it.
|
|
454
473
|
const showValidation = (result, nodes) => {
|
|
455
474
|
const steps = stepsOf(nodes);
|
|
456
|
-
const problems = (
|
|
457
|
-
const errors = problems(result.errors);
|
|
458
|
-
const
|
|
475
|
+
const problems = (issues) => distinctProblems(issues.map((issue) => toProblem(issue, t, steps)));
|
|
476
|
+
const errors = problems(issuesOf(result.errors, result.error_details));
|
|
477
|
+
const kept = new Set(withoutNoteConnectivityWarnings(result.warnings, nodes));
|
|
478
|
+
const warnings = problems(issuesOf(result.warnings, result.warning_details).filter(({ message }) => kept.has(message)));
|
|
459
479
|
if (errors.length === 0 && warnings.length === 0) {
|
|
460
480
|
setValidationResult(null);
|
|
461
481
|
return;
|
|
@@ -857,7 +877,7 @@ function WorkflowEditor({ tenantKey, workflowId, username, axdToken, baseWsUrl,
|
|
|
857
877
|
const step = stepId ? shownSteps.find(stepId) : undefined;
|
|
858
878
|
if (!step)
|
|
859
879
|
return jsx("span", { children: text });
|
|
860
|
-
return (jsx(ActionTooltip, { label: t('workflowsWorkflowEditor.goToStep', { name: ((_a = step.data) === null || _a === void 0 ? void 0 : _a.label) || step.id }), children: jsx("button", { type: "button", className: PROBLEM_LINK, onClick: () => handleShowStep(step.id, field), children: text }) }));
|
|
880
|
+
return (jsx(ActionTooltip, { label: t('workflowsWorkflowEditor.goToStep', { name: ((_a = step.data) === null || _a === void 0 ? void 0 : _a.label) || step.id }), children: jsx("button", { type: "button", "data-step-id": step.id, className: PROBLEM_LINK, onClick: () => handleShowStep(step.id, field), children: text }) }));
|
|
861
881
|
};
|
|
862
882
|
canvasShownRef.current = true;
|
|
863
883
|
return (
|