@tesouro/embedded-components-react 0.7.41 → 0.7.43

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.
Files changed (34) hide show
  1. package/README.md +110 -23
  2. package/dist/index.css +11 -0
  3. package/dist/libs/tesouro-embedded-components-react/accept-disclosures-widget/feature/dist/mocks/acceptDisclosures.js +33 -28
  4. package/dist/libs/tesouro-embedded-components-react/accept-disclosures-widget/feature/dist/mocks/labels.js +6 -2
  5. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/lib/BankAccountOnboardingWidget/BankAccountOnboardingWidget.js +2 -2
  6. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/lib/BankAccountOnboardingWidget/BusinessDetailsStep.js +2 -2
  7. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/lib/BankAccountOnboardingWidget/PersonalDetailsStep.js +1 -1
  8. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/lib/BankAccountOnboardingWidget/businessDetailsPanelMapping.js +1 -1
  9. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/lib/BankAccountOnboardingWidget/personalDetailsPanelMapping.js +1 -1
  10. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/mocks/bankAccountOnboarding.js +40 -22
  11. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/mocks/labels.js +14 -2
  12. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index.js +8 -10
  13. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index17.js +274 -2
  14. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index18.js +30 -4
  15. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index19.js +21 -272
  16. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index20.js +65 -26
  17. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index21.js +341 -21
  18. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index22.js +27 -65
  19. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index23.js +26 -341
  20. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index24.js +72 -27
  21. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index25.js +85 -26
  22. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index26.js +8 -74
  23. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index27.js +55 -83
  24. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index28.js +7 -6
  25. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index29.js +42 -37
  26. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/mocks/expenseManagement.js +163 -140
  27. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/mocks/labels.js +22 -16
  28. package/dist/libs/tesouro-embedded-components-react/settings-widget/feature/dist/mocks/labels.js +12 -0
  29. package/dist/libs/tesouro-embedded-components-react/settings-widget/feature/dist/mocks/settings.js +255 -88
  30. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  31. package/dist/scenarios/index.d.ts +1 -1
  32. package/package.json +1 -1
  33. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index30.js +0 -11
  34. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index31.js +0 -64
@@ -2,12 +2,13 @@ import { Scope as e } from "../../../../shared/data-access/dist/lib/scopes.js";
2
2
  import "../../../../shared/data-access/dist/index.js";
3
3
  import { AN_APPROVAL_POLICY as t, AN_ENTITY_USER as n, AN_ORGANIZATION_USER as r, A_RECEIPT as i, A_TRANSACTION as a, A_WIDGET_INIT as o } from "../../../../shared/data-access-mocks/dist/lib/fixtures.js";
4
4
  import { ENGINEERING as s, GRACE as c, HEADQUARTERS as l, REMOTE as u, SALES as d, TYLER as f } from "../../../../shared/data-access-mocks/dist/mocks/scenarios/team.js";
5
- import { FINOPS as p, IDENTITY as m, bodyOf as h, endpoint as g, initRoute as _, json as v, noContent as ee, problem as y, wait as te } from "../../../../shared/data-access-mocks/dist/mocks/scenarios/scenario.js";
6
- import { finopsOffsetPage as b } from "../../../../shared/data-access-mocks/dist/mocks/scenarios/worlds.js";
7
- import { AN_APPROVAL_REQUEST as x, AN_EXPENSE_HISTORY_ENTRY as ne, A_LEDGER_ACCOUNT as S, A_RECEIPTS_MAILBOX as C, A_TRANSACTION_VALIDATION as w } from "./fixtures.js";
8
- import { EXPENSE_MANAGEMENT_LABELS as T } from "./labels.js";
5
+ import { SCENARIO_LABELS as p } from "../../../../shared/data-access-mocks/dist/mocks/scenarios/labels.js";
6
+ import { FINOPS as ee, IDENTITY as m, LOADING_DELAY_MS as h, bodyOf as g, endpoint as _, initRoute as v, json as y, noContent as te, problem as b, wait as x } from "../../../../shared/data-access-mocks/dist/mocks/scenarios/scenario.js";
7
+ import { finopsOffsetPage as S } from "../../../../shared/data-access-mocks/dist/mocks/scenarios/worlds.js";
8
+ import { AN_APPROVAL_REQUEST as C, AN_EXPENSE_HISTORY_ENTRY as ne, A_LEDGER_ACCOUNT as w, A_RECEIPTS_MAILBOX as re, A_TRANSACTION_VALIDATION as T } from "./fixtures.js";
9
+ import { EXPENSE_MANAGEMENT_LABELS as E } from "./labels.js";
9
10
  //#region ../../libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/mocks/expenseManagement.js
10
- var E = (e) => `00000000-0000-4000-8000-000000000${String(400 + e).padStart(3, "0")}`, D = o.userId, O = i.file_url, k = (e) => w.required_fields.find((t) => t.field === e)?.amount_threshold ?? 0, re = k("receipt_id"), ie = k("description"), A = (e) => {
11
+ var D = (e) => `00000000-0000-4000-8000-000000000${String(400 + e).padStart(3, "0")}`, O = o.userId, k = i.file_url, A = (e) => T.required_fields.find((t) => t.field === e)?.amount_threshold ?? 0, ie = A("receipt_id"), ae = A("description"), j = (e) => {
11
12
  let [t = "", ...r] = e.name.split(" ");
12
13
  return {
13
14
  ...n,
@@ -17,31 +18,31 @@ var E = (e) => `00000000-0000-4000-8000-000000000${String(400 + e).padStart(3, "
17
18
  first_name: t,
18
19
  last_name: r.join(" ")
19
20
  };
20
- }, j = [
21
+ }, M = [
21
22
  n,
22
- A(f),
23
- A(c)
24
- ], M = [
23
+ j(f),
24
+ j(c)
25
+ ], oe = [
25
26
  r,
26
27
  f,
27
28
  c
28
29
  ], N = [
29
- S,
30
+ w,
30
31
  {
31
- ...S,
32
- id: E(31),
32
+ ...w,
33
+ id: D(31),
33
34
  name: "Meals & entertainment",
34
35
  nominal_code: "6300"
35
36
  },
36
37
  {
37
- ...S,
38
- id: E(32),
38
+ ...w,
39
+ id: D(32),
39
40
  name: "Software",
40
41
  nominal_code: "6500"
41
42
  },
42
43
  {
43
- ...S,
44
- id: E(33),
44
+ ...w,
45
+ id: D(33),
45
46
  name: "Office supplies",
46
47
  nominal_code: "6600"
47
48
  }
@@ -56,15 +57,15 @@ var E = (e) => `00000000-0000-4000-8000-000000000${String(400 + e).padStart(3, "
56
57
  } : t;
57
58
  }, I = (e, t) => ({
58
59
  ...a,
59
- id: E(e),
60
+ id: D(e),
60
61
  payment_processing_status: "succeeded",
61
62
  amount: t.merchant_amount,
62
63
  receipt_id: null,
63
64
  receipt_file_url: null,
64
65
  ...t
65
66
  }), L = (e, t = !1) => ({
66
- receipt_id: E(e + 100),
67
- receipt_file_url: O,
67
+ receipt_id: D(e + 100),
68
+ receipt_file_url: k,
68
69
  source_of_data: { receipt_id: t ? "automatched" : "user" }
69
70
  }), R = t.id, z = [
70
71
  {
@@ -156,12 +157,12 @@ var E = (e) => `00000000-0000-4000-8000-000000000${String(400 + e).padStart(3, "
156
157
  })
157
158
  ], V = [i, {
158
159
  ...i,
159
- id: E(170),
160
+ id: D(170),
160
161
  file_name: "parking.svg",
161
162
  merchant_name: "City Parking",
162
163
  issued_at: "2026-09-20",
163
164
  total_amount: 1200
164
- }], ae = (e) => e.receipt_id ? {
165
+ }], se = (e) => e.receipt_id ? {
165
166
  ...i,
166
167
  id: e.receipt_id,
167
168
  created_by_entity_user_id: e.entity_user_id,
@@ -171,14 +172,14 @@ var E = (e) => `00000000-0000-4000-8000-000000000${String(400 + e).padStart(3, "
171
172
  total_amount: Math.abs(e.merchant_amount),
172
173
  transaction_id: e.id
173
174
  } : void 0, H = (e, t, n) => ({
174
- ...x,
175
- id: E(e),
175
+ ...C,
176
+ id: D(e),
176
177
  created_at: t.started_at,
177
178
  updated_at: t.started_at,
178
- approved_by: n === "approved" ? [D] : [],
179
- rejected_by: n === "rejected" ? D : null,
179
+ approved_by: n === "approved" ? [O] : [],
180
+ rejected_by: n === "rejected" ? O : null,
180
181
  reject_reason: t.reject_reason ?? null,
181
- caller_is_policy_approver: t.entity_user_id !== D,
182
+ caller_is_policy_approver: t.entity_user_id !== O,
182
183
  created_by: t.entity_user_id,
183
184
  submitted_by: t.entity_user_id,
184
185
  object_id: t.id,
@@ -186,12 +187,12 @@ var E = (e) => `00000000-0000-4000-8000-000000000${String(400 + e).padStart(3, "
186
187
  }), U = (e, t) => e.getAll(t).flatMap((e) => e.split(",")).filter(Boolean), W = (e, t) => {
187
188
  let n = e.get(t);
188
189
  return n === null ? void 0 : n === "true";
189
- }, oe = (e) => `${p}${e}`, G = 400, K = 2e3;
190
- function q(e) {
191
- let n = e.transactions.map((e) => ({ ...e })), r = [...e.inbox.map((e) => ({ ...e })), ...e.transactions.flatMap((e) => ae(e) ?? [])], a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), f = 0, _ = 0, x = (e) => j.find((t) => t.id === e), S = (e, t, n, r, i = (/* @__PURE__ */ new Date()).toISOString()) => {
192
- let a = x(r), o = {
190
+ }, G = (e) => `${ee}${e}`, ce = 400, le = 2e3;
191
+ function K(e) {
192
+ let n = e.transactions.map((e) => ({ ...e })), r = [...e.inbox.map((e) => ({ ...e })), ...e.transactions.flatMap((e) => se(e) ?? [])], a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), f = 0, p = 0, h = (e) => M.find((t) => t.id === e), v = (e, t, n, r, i = (/* @__PURE__ */ new Date()).toISOString()) => {
193
+ let a = h(r), o = {
193
194
  ...ne,
194
- id: `${e.id}.${_ += 1}`,
195
+ id: `${e.id}.${p += 1}`,
195
196
  transaction_id: e.id,
196
197
  event_type: t,
197
198
  event_data: n,
@@ -204,204 +205,204 @@ function q(e) {
204
205
  entity_user_role_name: null
205
206
  };
206
207
  c.set(e.id, [o, ...c.get(e.id) ?? []]);
207
- }, T = (e, t) => new Date(Date.parse(e) + t * 36e5).toISOString();
208
+ }, C = (e, t) => new Date(Date.parse(e) + t * 36e5).toISOString();
208
209
  for (let e of n) {
209
210
  let n = e.entity_user_id ?? null;
210
- if (S(e, "expense_created", {
211
+ if (v(e, "expense_created", {
211
212
  created_via: "feed",
212
213
  expense_status: "new"
213
214
  }, null, e.started_at), e.expense_status === "new") continue;
214
- if (S(e, "submitted", {
215
+ if (v(e, "submitted", {
215
216
  old_status: "new",
216
217
  new_status: e.applied_policy_id ? "approve_in_progress" : "approved",
217
218
  bypass_receipt_validation: !1
218
- }, n, T(e.started_at, 2)), !e.applied_policy_id) {
219
- S(e, "auto_approved", {}, null, T(e.started_at, 2));
219
+ }, n, C(e.started_at, 2)), !e.applied_policy_id) {
220
+ v(e, "auto_approved", {}, null, C(e.started_at, 2));
220
221
  continue;
221
222
  }
222
223
  let r = e.expense_status === "approved" || e.expense_status === "rejected", i = H(200 + o.size, e, e.expense_status === "approved" ? "approved" : e.expense_status === "rejected" ? "rejected" : "waiting");
223
- o.set(e.id, i), r && S(e, "approval_action", {
224
+ o.set(e.id, i), r && v(e, "approval_action", {
224
225
  action: e.expense_status,
225
226
  approval_source: "user",
226
227
  approval_policy_id: R,
227
228
  approval_policy_name: t.name,
228
229
  approval_request_id: i.id,
229
230
  reject_reason: e.reject_reason ?? null
230
- }, D, T(e.started_at, 26));
231
+ }, O, C(e.started_at, 26));
231
232
  }
232
- let O = () => {
233
+ let w = () => {
233
234
  let e = Date.now();
234
235
  for (let [t, i] of a) {
235
236
  if (i > e) continue;
236
237
  a.delete(t);
237
- let o = r.find((e) => e.id === t)?.transaction_id ? void 0 : n.find((e) => e.entity_user_id === D && !e.receipt_id && (e.expense_status === "new" || e.expense_status === "rejected"));
238
- k(t, {
238
+ let o = r.find((e) => e.id === t)?.transaction_id ? void 0 : n.find((e) => e.entity_user_id === O && !e.receipt_id && (e.expense_status === "new" || e.expense_status === "rejected"));
239
+ E(t, {
239
240
  ocr_status: "success",
240
241
  merchant_name: o?.merchant_name ?? "Corner Hardware",
241
242
  total_amount: o ? Math.abs(o.merchant_amount) : 2499,
242
243
  issued_at: (o?.started_at ?? (/* @__PURE__ */ new Date()).toISOString()).slice(0, 10)
243
- }), o && L(t, o.id, "automatched");
244
+ }), o && F(t, o.id, "automatched");
244
245
  }
245
- }, k = (e, t) => (r = r.map((n) => n.id === e ? {
246
+ }, E = (e, t) => (r = r.map((n) => n.id === e ? {
246
247
  ...n,
247
248
  ...t
248
- } : n), r.find((t) => t.id === e)), A = (e) => {
249
+ } : n), r.find((t) => t.id === e)), k = (e) => {
249
250
  if (e.expense_status !== "new" && e.expense_status !== "rejected") return !1;
250
251
  let t = Math.abs(e.merchant_amount);
251
- return t >= re && !e.receipt_id && !e.no_receipt_reason || t >= ie && !e.description;
252
- }, P = (e) => ({
252
+ return t >= ie && !e.receipt_id && !e.no_receipt_reason || t >= ae && !e.description;
253
+ }, A = (e) => ({
253
254
  ...e,
254
- has_validation_errors: A(e)
255
- }), F = (e) => n.find((t) => t.id === e), I = (e, t) => (n = n.map((n) => n.id === e ? {
255
+ has_validation_errors: k(e)
256
+ }), j = (e) => n.find((t) => t.id === e), P = (e, t) => (n = n.map((n) => n.id === e ? {
256
257
  ...n,
257
258
  ...t
258
- } : n), F(e)), L = (e, t, n = "user") => {
259
+ } : n), j(e)), F = (e, t, n = "user") => {
259
260
  let i = r.find((t) => t.id === e);
260
261
  if (!i) return;
261
262
  let a = i.transaction_id;
262
263
  if (a) {
263
- let t = F(a);
264
- I(a, {
264
+ let t = j(a);
265
+ P(a, {
265
266
  receipt_id: null,
266
267
  receipt_file_url: null
267
- }), t && S(t, "receipt_unlinked", { receipt_id: e }, D);
268
+ }), t && v(t, "receipt_unlinked", { receipt_id: e }, O);
268
269
  }
269
- let o = k(e, { transaction_id: t });
270
+ let o = E(e, { transaction_id: t });
270
271
  if (t) {
271
- let r = I(t, {
272
+ let r = P(t, {
272
273
  receipt_id: e,
273
274
  receipt_file_url: i.file_url,
274
275
  source_of_data: {
275
- ...F(t)?.source_of_data,
276
+ ...j(t)?.source_of_data,
276
277
  receipt_id: n
277
278
  }
278
279
  });
279
- r && S(r, "receipt_matched", {
280
+ r && v(r, "receipt_matched", {
280
281
  receipt_id: e,
281
282
  link_source: n
282
- }, n === "user" ? D : null);
283
+ }, n === "user" ? O : null);
283
284
  }
284
285
  return o;
285
- }, z = () => e.selfOnly ? n.filter((e) => e.entity_user_id === D) : n, B = (e, t) => {
286
+ }, I = () => e.selfOnly ? n.filter((e) => e.entity_user_id === O) : n, L = (e, t) => {
286
287
  let n = (e, n) => {
287
288
  let r = U(t, e);
288
289
  return r.length === 0 || n != null && r.includes(n);
289
290
  }, r = Math.abs(e.merchant_amount), i = t.get("amount__gt"), a = t.get("amount__lt"), o = t.get("created_at__gt"), s = t.get("created_at__lt"), c = t.get("merchant_name__icontains")?.toLowerCase(), l = W(t, "has_receipt"), u = W(t, "has_validation_errors");
290
- return n("entity_user_id__in", e.entity_user_id) && n("expense_status__in", e.expense_status) && n("type__in", e.type) && n("payment_processing_status__in", e.payment_processing_status) && n("payment_method__in", e.payment_method.type) && (l === void 0 || l === !!e.receipt_id) && (u === void 0 || u === A(e)) && (!c || e.merchant_name.toLowerCase().includes(c)) && (i === null || r > Number(i)) && (a === null || r < Number(a)) && (o === null || e.started_at > o) && (s === null || e.started_at < s);
291
- }, V = (e) => {
291
+ return n("entity_user_id__in", e.entity_user_id) && n("expense_status__in", e.expense_status) && n("type__in", e.type) && n("payment_processing_status__in", e.payment_processing_status) && n("payment_method__in", e.payment_method.type) && (l === void 0 || l === !!e.receipt_id) && (u === void 0 || u === k(e)) && (!c || e.merchant_name.toLowerCase().includes(c)) && (i === null || r > Number(i)) && (a === null || r < Number(a)) && (o === null || e.started_at > o) && (s === null || e.started_at < s);
292
+ }, z = (e) => {
292
293
  let t = e.get("sort") === "merchant_amount" ? "merchant_amount" : "started_at", n = e.get("order") === "asc" ? 1 : -1;
293
- return z().filter((t) => B(t, e)).sort((e, r) => (e[t] < r[t] ? -1 : +(e[t] > r[t])) * n).map(P);
294
- }, q = () => y(403, "Forbidden", "This token cannot change expenses."), J = (t, n, r) => g(t, oe(n), async (t, n) => e.canWrite ? (await te(G), O(), r(t, n)) : q()), Y = (e, t, n = p) => g("GET", `${n}${e}`, (e, n) => (O(), t(e, n))), X = () => y(404, "Not Found", "No such expense."), Z = (e, n, r, i) => {
294
+ return I().filter((t) => L(t, e)).sort((e, r) => (e[t] < r[t] ? -1 : +(e[t] > r[t])) * n).map(A);
295
+ }, B = () => b(403, "Forbidden", "This token cannot change expenses."), V = (t, n, r) => _(t, G(n), async (t, n) => e.canWrite ? (await x(ce), w(), r(t, n)) : B()), K = (e, t, n = ee) => _("GET", `${n}${e}`, (e, n) => (w(), t(e, n))), q = () => b(404, "Not Found", "No such expense."), J = (e, n, r, i) => {
295
296
  let a = o.get(e.id);
296
297
  a && o.set(e.id, {
297
298
  ...a,
298
299
  status: n,
299
- approved_by: n === "approved" ? [...a.approved_by, D] : a.approved_by,
300
- rejected_by: n === "rejected" ? D : null,
300
+ approved_by: n === "approved" ? [...a.approved_by, O] : a.approved_by,
301
+ rejected_by: n === "rejected" ? O : null,
301
302
  reject_reason: i ?? null
302
303
  });
303
- let s = I(e.id, {
304
+ let s = P(e.id, {
304
305
  expense_status: n,
305
306
  reject_reason: n === "rejected" ? i ?? null : null
306
307
  });
307
- return s && S(s, "approval_action", {
308
+ return s && v(s, "approval_action", {
308
309
  action: n,
309
310
  approval_source: r,
310
311
  approval_policy_id: s.applied_policy_id ?? null,
311
312
  approval_policy_name: s.applied_policy_id ? t.name : null,
312
313
  approval_request_id: a?.id ?? null,
313
314
  reject_reason: i ?? null
314
- }, D), s;
315
- }, Q = (e) => v({ data: [{ metric_value: e }] }), $ = (e) => {
315
+ }, O), s;
316
+ }, Y = (e) => y({ data: [{ metric_value: e }] }), X = (e) => {
316
317
  let t = U(e, "id__in"), n = W(e, "has_transaction"), i = e.get("created_by_entity_user_id");
317
318
  return r.filter((e) => (t.length === 0 || t.includes(e.id)) && (n === void 0 || n === !!e.transaction_id) && (!i || e.created_by_entity_user_id === i));
318
319
  };
319
320
  return [
320
- Y("/mailboxes", () => v({ data: [C] })),
321
- Y("/transactions/validations", () => v(w)),
322
- Y("/approval-policies", ({ query: e }) => v(b([t], e))),
323
- Y("/ledger-accounts", ({ query: e }) => v(b(N, e))),
324
- Y("/entity-users", ({ query: e }) => {
321
+ K("/mailboxes", () => y({ data: [re] })),
322
+ K("/transactions/validations", () => y(T)),
323
+ K("/approval-policies", ({ query: e }) => y(S([t], e))),
324
+ K("/ledger-accounts", ({ query: e }) => y(S(N, e))),
325
+ K("/entity-users", ({ query: e }) => {
325
326
  let t = U(e, "id__in");
326
- return v(b(j.filter((e) => t.length === 0 || t.includes(e.id)), e));
327
+ return y(S(M.filter((e) => t.length === 0 || t.includes(e.id)), e));
327
328
  }),
328
- Y("/users", ({ query: t }) => v({
329
- data: e.selfOnly && t.get("ReportingManagerUserId") ? [] : M,
329
+ K("/users", ({ query: t }) => y({
330
+ data: e.selfOnly && t.get("ReportingManagerUserId") ? [] : oe,
330
331
  nextPaginationToken: null
331
332
  }), m),
332
- Y("/departments", () => v({
333
+ K("/departments", () => y({
333
334
  data: [s, d],
334
335
  nextPaginationToken: null
335
336
  }), m),
336
- Y("/locations", () => v({
337
+ K("/locations", () => y({
337
338
  data: [l, u],
338
339
  nextPaginationToken: null
339
340
  }), m),
340
- Y("/analytics/transactions", ({ query: e }) => Q(z().filter((t) => B(t, e)).length)),
341
- Y("/analytics/receipts", ({ query: e }) => Q($(e).length)),
342
- Y("/transactions", ({ query: e }) => v(b(V(e), e))),
343
- Y("/transactions/:id", (e, { id: t }) => {
344
- let n = F(t);
345
- return n ? v(P(n)) : X();
341
+ K("/analytics/transactions", ({ query: e }) => Y(I().filter((t) => L(t, e)).length)),
342
+ K("/analytics/receipts", ({ query: e }) => Y(X(e).length)),
343
+ K("/transactions", ({ query: e }) => y(S(z(e), e))),
344
+ K("/transactions/:id", (e, { id: t }) => {
345
+ let n = j(t);
346
+ return n ? y(A(n)) : q();
346
347
  }),
347
- Y("/transactions/:id/expense-history", ({ query: e }, { id: t }) => v(b(c.get(t) ?? [], e))),
348
- Y("/approval-requests", ({ query: e }) => {
348
+ K("/transactions/:id/expense-history", ({ query: e }, { id: t }) => y(S(c.get(t) ?? [], e))),
349
+ K("/approval-requests", ({ query: e }) => {
349
350
  let t = o.get(e.get("object_id") ?? "");
350
- return v(b(t ? [t] : [], e));
351
+ return y(S(t ? [t] : [], e));
351
352
  }),
352
- J("PATCH", "/transactions/:id", (e, { id: t }) => {
353
- let n = h(e), r = F(t);
354
- if (!r) return X();
355
- let i = Object.fromEntries(Object.keys(n).map((e) => [e, "user"])), a = I(t, {
353
+ V("PATCH", "/transactions/:id", (e, { id: t }) => {
354
+ let n = g(e), r = j(t);
355
+ if (!r) return q();
356
+ let i = Object.fromEntries(Object.keys(n).map((e) => [e, "user"])), a = P(t, {
356
357
  ...n,
357
358
  source_of_data: {
358
359
  ...r.source_of_data,
359
360
  ...i
360
361
  }
361
362
  });
362
- return a && S(a, "expense_updated", { fields: Object.keys(n) }, D), a ? v(P(a)) : X();
363
+ return a && v(a, "expense_updated", { fields: Object.keys(n) }, O), a ? y(A(a)) : q();
363
364
  }),
364
- J("POST", "/transactions/:id/submit", (e, { id: n }) => {
365
- let r = h(e), i = F(n);
366
- if (!i) return X();
367
- let a = Math.abs(i.merchant_amount) >= 1e4, s = I(n, {
365
+ V("POST", "/transactions/:id/submit", (e, { id: n }) => {
366
+ let r = g(e), i = j(n);
367
+ if (!i) return q();
368
+ let a = Math.abs(i.merchant_amount) >= 1e4, s = P(n, {
368
369
  expense_status: a ? "approve_in_progress" : "approved",
369
370
  applied_policy_id: a ? R : null,
370
371
  no_receipt_reason: r.no_receipt_reason ?? i.no_receipt_reason ?? null
371
372
  });
372
- return s ? (S(s, "submitted", {
373
+ return s ? (v(s, "submitted", {
373
374
  old_status: i.expense_status,
374
375
  new_status: s.expense_status,
375
376
  bypass_receipt_validation: !!r.no_receipt_reason,
376
377
  no_receipt_reason: r.no_receipt_reason ?? null
377
- }, D), a ? (o.set(n, H(200 + o.size, s, "waiting")), S(s, "approval_requested", { approval_policy_name: t.name }, null)) : S(s, "auto_approved", {}, null), v(P(s))) : X();
378
+ }, O), a ? (o.set(n, H(200 + o.size, s, "waiting")), v(s, "approval_requested", { approval_policy_name: t.name }, null)) : v(s, "auto_approved", {}, null), y(A(s))) : q();
378
379
  }),
379
- J("POST", "/transactions/:id/reopen", (e, { id: t }) => {
380
- let n = I(t, {
380
+ V("POST", "/transactions/:id/reopen", (e, { id: t }) => {
381
+ let n = P(t, {
381
382
  expense_status: "new",
382
383
  reject_reason: null
383
384
  });
384
- return n && S(n, "reopened", {}, D), n ? v(P(n)) : X();
385
+ return n && v(n, "reopened", {}, O), n ? y(A(n)) : q();
385
386
  }),
386
- J("POST", "/transactions/:id/approve", (e, { id: t }) => {
387
- let n = F(t), r = n && Z(n, "approved", "force");
388
- return r ? v(P(r)) : X();
387
+ V("POST", "/transactions/:id/approve", (e, { id: t }) => {
388
+ let n = j(t), r = n && J(n, "approved", "force");
389
+ return r ? y(A(r)) : q();
389
390
  }),
390
- J("POST", "/transactions/:id/reject", (e, { id: t }) => {
391
- let n = F(t), r = h(e)?.reject_reason, i = n && Z(n, "rejected", "force", r);
392
- return i ? v(P(i)) : X();
391
+ V("POST", "/transactions/:id/reject", (e, { id: t }) => {
392
+ let n = j(t), r = g(e)?.reject_reason, i = n && J(n, "rejected", "force", r);
393
+ return i ? y(A(i)) : q();
393
394
  }),
394
- J("POST", "/approval-requests/:id/:action", (e, { id: t, action: n }) => {
395
- let r = [...o.entries()].find(([, e]) => e.id === t), i = r && F(r[0]);
396
- if (!i || n !== "approve" && n !== "reject") return X();
397
- let a = h(e)?.reject_reason;
398
- return Z(i, n === "approve" ? "approved" : "rejected", "user", a), v(o.get(i.id));
395
+ V("POST", "/approval-requests/:id/:action", (e, { id: t, action: n }) => {
396
+ let r = [...o.entries()].find(([, e]) => e.id === t), i = r && j(r[0]);
397
+ if (!i || n !== "approve" && n !== "reject") return q();
398
+ let a = g(e)?.reject_reason;
399
+ return J(i, n === "approve" ? "approved" : "rejected", "user", a), y(o.get(i.id));
399
400
  }),
400
- Y("/receipts", ({ query: e }) => v(b($(e), e))),
401
- J("POST", "/receipts/upload-from-file", (e) => {
402
- let t = h(e)?.file, n = {
401
+ K("/receipts", ({ query: e }) => y(S(X(e), e))),
402
+ V("POST", "/receipts/upload-from-file", (e) => {
403
+ let t = g(e)?.file, n = {
403
404
  ...i,
404
- id: E(300 + (f += 1)),
405
+ id: D(300 + (f += 1)),
405
406
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
406
407
  updated_at: (/* @__PURE__ */ new Date()).toISOString(),
407
408
  file_name: t?.name ?? "receipt.png",
@@ -411,16 +412,16 @@ function q(e) {
411
412
  ocr_status: "processing",
412
413
  transaction_id: null
413
414
  };
414
- return r = [...r, n], a.set(n.id, Date.now() + K), v(n, 201);
415
+ return r = [...r, n], a.set(n.id, Date.now() + le), y(n, 201);
415
416
  }),
416
- J("PATCH", "/receipts/:id", (e, { id: t }) => {
417
- let n = h(e), i = n && "transaction_id" in n ? L(t, n.transaction_id ?? null) : r.find((e) => e.id === t);
418
- return i ? v(i) : y(404, "Not Found", "No such receipt.");
417
+ V("PATCH", "/receipts/:id", (e, { id: t }) => {
418
+ let n = g(e), i = n && "transaction_id" in n ? F(t, n.transaction_id ?? null) : r.find((e) => e.id === t);
419
+ return i ? y(i) : b(404, "Not Found", "No such receipt.");
419
420
  }),
420
- J("DELETE", "/receipts/:id", (e, { id: t }) => (r = r.filter((e) => e.id !== t), ee()))
421
+ V("DELETE", "/receipts/:id", (e, { id: t }) => (r = r.filter((e) => e.id !== t), te()))
421
422
  ];
422
423
  }
423
- var J = [
424
+ var q = [
424
425
  e.ExpenseReadOrg,
425
426
  e.ExpenseWriteOrg,
426
427
  e.ExpenseApproveOrg,
@@ -428,38 +429,60 @@ var J = [
428
429
  e.ExpenseReadSelf,
429
430
  e.ExpenseWriteSelf,
430
431
  e.MailboxReadOrg
431
- ], Y = (t, n, r) => ({
432
- key: t,
433
- ...T.scenarios[t],
434
- routes: () => [_(n), ...q({
435
- ...r,
436
- canWrite: n.includes(e.ExpenseWriteOrg) || n.includes(e.ExpenseWriteSelf)
437
- })]
438
- }), X = {
432
+ ], J = ({ method: e, path: t }) => e === "GET" && (t === G("/transactions") || t.startsWith(G("/analytics/"))), Y = (e) => async (t) => {
433
+ if (J(t)) {
434
+ if (e === "failing") return b(500, "Internal Server Error", "Something went wrong.");
435
+ await x(h);
436
+ }
437
+ }, X = (t, n, r) => [
438
+ v(t),
439
+ ...r ? [Y(r)] : [],
440
+ ...K({
441
+ ...n,
442
+ canWrite: t.includes(e.ExpenseWriteOrg) || t.includes(e.ExpenseWriteSelf)
443
+ })
444
+ ], Z = (e, t, n) => ({
445
+ key: e,
446
+ ...E.scenarios[e],
447
+ routes: () => X(t, n)
448
+ }), Q = (e, t, n, r) => ({
449
+ key: e,
450
+ label: p[e].label,
451
+ blurb: E.blurbs[e],
452
+ routes: () => X(t, n, r)
453
+ }), $ = {
439
454
  transactions: [...z, ...B],
440
455
  inbox: V
441
- }, Z = [
442
- Y("team-queue", J, {
443
- ...X,
456
+ }, ue = [
457
+ Z("team-queue", q, {
458
+ ...$,
444
459
  selfOnly: !1
445
460
  }),
446
- Y("mine-only", [
461
+ Z("mine-only", [
447
462
  e.ExpenseReadSelf,
448
463
  e.ExpenseWriteSelf,
449
464
  e.MailboxReadOrg
450
465
  ], {
451
- ...X,
466
+ ...$,
452
467
  selfOnly: !0
453
468
  }),
454
- Y("read-only", [e.ExpenseReadOrg], {
455
- ...X,
469
+ Z("read-only", [e.ExpenseReadOrg], {
470
+ ...$,
456
471
  selfOnly: !1
457
472
  }),
458
- Y("empty", J, {
473
+ Z("empty", q, {
459
474
  transactions: [],
460
475
  inbox: [],
461
476
  selfOnly: !1
462
- })
477
+ }),
478
+ Q("loading", q, {
479
+ ...$,
480
+ selfOnly: !1
481
+ }, "held"),
482
+ Q("error", q, {
483
+ ...$,
484
+ selfOnly: !1
485
+ }, "failing")
463
486
  ];
464
487
  //#endregion
465
- export { Z as expenseManagementScenarios };
488
+ export { ue as expenseManagementScenarios };
@@ -1,21 +1,27 @@
1
1
  //#region ../../libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/mocks/labels.js
2
- var e = { scenarios: {
3
- "team-queue": {
4
- label: "Approver queue",
5
- blurb: "An expense admin who also approves. My transactions has action items for their own two expenses to submit, one rejected and two receipts to match. Team transactions adds the two expenses waiting for approval and every rejection. Press Review on an action item, or open any row, to approve, reject, submit, attach a receipt, or edit the memo and accounting. Upload receipts takes files: the first is matched to Example Coffee and the rest wait in the receipt inbox."
2
+ var e = {
3
+ blurbs: {
4
+ loading: "An expense admin whose transactions list and counts are held open. The tabs render, and the table shows its loading rows with no badges or action items yet.",
5
+ error: "An expense admin whose transactions list and counts fail with a 500. The widget has no error panel for this, so both tabs read No results., the same as Empty."
6
6
  },
7
- "mine-only": {
8
- label: "Cardholder",
9
- blurb: "A cardholder with expense:read:self and expense:write:self only. There is no Team tab, so the table lists their own four expenses, with action items for the two to submit, the rejected one and the receipts to match."
10
- },
11
- "read-only": {
12
- label: "Read only",
13
- blurb: "Init grants expense:read:org alone. Both tabs list expenses, but there are no action items and no Add receipt, and a row opens the review dialog view-only. Upload receipts is still offered, and the upload is refused."
14
- },
15
- empty: {
16
- label: "Empty",
17
- blurb: "An expense admin in an organization with no card spend yet. Both tabs say No results., with no badges and no action items."
7
+ scenarios: {
8
+ "team-queue": {
9
+ label: "Approver queue",
10
+ blurb: "An expense admin who also approves. My transactions has action items for their own two expenses to submit, one rejected and two receipts to match. Team transactions adds the two expenses waiting for approval and every rejection. Press Review on an action item, or open any row, to approve, reject, submit, attach a receipt, or edit the memo and accounting. Upload receipts takes files: the first is matched to Example Coffee and the rest wait in the receipt inbox."
11
+ },
12
+ "mine-only": {
13
+ label: "Cardholder",
14
+ blurb: "A cardholder with expense:read:self and expense:write:self only. There is no Team tab, so the table lists their own four expenses, with action items for the two to submit, the rejected one and the receipts to match."
15
+ },
16
+ "read-only": {
17
+ label: "Read only",
18
+ blurb: "Init grants expense:read:org alone. Both tabs list expenses, but there are no action items and no Add receipt, and a row opens the review dialog view-only. Upload receipts is still offered, and the upload is refused."
19
+ },
20
+ empty: {
21
+ label: "Empty",
22
+ blurb: "An expense admin in an organization with no card spend yet. Both tabs say No results., with no badges and no action items."
23
+ }
18
24
  }
19
- } };
25
+ };
20
26
  //#endregion
21
27
  export { e as EXPENSE_MANAGEMENT_LABELS };
@@ -23,6 +23,18 @@ var e = { scenarios: {
23
23
  "no-team": {
24
24
  label: "No Team access",
25
25
  blurb: "Init returns no scopes, so only Profile, Legal and Help are in the sidebar. The host asked for Team, and the widget opens on the first visible section instead."
26
+ },
27
+ expense: {
28
+ label: "Expense settings",
29
+ blurb: "A finance admin on the Expenses section. Approvals lists three rules: under $100 is approved automatically, $100 to $1,000 goes to the reporting manager, and $1,000 or more needs a Company admin. Add, edit or delete a rule. Requirements asks for a receipt from $75 and a memo from $200; change either and press Save."
30
+ },
31
+ "bill-pay": {
32
+ label: "Bill pay approvals",
33
+ blurb: "A finance admin on the Bill pay section. Bills up to $500 need Tyler Brooks or Grace Hopper; bills of $1,000 and above need Grace Hopper and a Company admin. Nothing covers $500.01 to $999.99, so the gap alert names that range. Edit a rule, add one, or delete one."
34
+ },
35
+ accounting: {
36
+ label: "Chart of accounts",
37
+ blurb: "A finance admin on the Chart of accounts section: five GL accounts sorted by name. Rent is synced from the accounting system, so it offers no edit or delete. Add an account, or edit or delete one of the others."
26
38
  }
27
39
  } };
28
40
  //#endregion