@tesouro/embedded-components-react 0.11.100 → 0.11.102
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/experimental/QuickViewWidget.d.ts +62 -2
- package/dist/experimental/index.d.ts +62 -2
- package/dist/index.css +21 -17
- package/dist/index.d.ts +10 -6
- package/dist/lib/CardDetailsWidget.d.ts +6 -4
- package/dist/lib/CreditCardsWidget.d.ts +6 -4
- package/dist/lib/DebitCardsWidget.d.ts +6 -4
- package/dist/lib/SettingsWidget.d.ts +2 -1
- package/dist/lib/WidgetSuite.d.ts +8 -5
- package/dist/libs/tesouro-embedded-components-react/card-details-widget/ui/dist/lib/CardDetailsPanel/CardDetailsPanel.js +199 -168
- package/dist/libs/tesouro-embedded-components-react/card-details-widget/ui/dist/lib/CardDetailsPanel/labels.js +1 -0
- package/dist/libs/tesouro-embedded-components-react/cards-widget/ui/dist/lib/CardsList/CardsList.js +44 -43
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/approval-policies/feature/dist/index.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/approval-policies/feature/dist/index3.js +9 -9
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/approval-policies/feature/dist/index4.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/approval-policies/feature/dist/index6.js +25 -284
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/approval-policies/feature/dist/index7.js +291 -0
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/approval-policies/ui/dist/index.js +3 -3
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/approval-policies/ui/dist/index3.js +28 -17
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/approval-policies/ui/dist/index5.js +21 -34
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/approval-policies/ui/dist/index6.js +71 -78
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/approval-policies/ui/dist/index7.js +71 -77
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/approval-policies/ui/dist/index8.js +43 -49
- package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/linked-accounts-widget/ui/dist/index2.js +8 -1
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/accounts/ui/dist/index2.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/bills/ui/dist/index2.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/cards/data-access/dist/index.js +1 -0
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/cards/data-access/dist/index2.js +98 -0
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/cards/feature/dist/index.js +3 -0
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/cards/feature/dist/lib/CardsQuickViewWidget/CardsQuickViewWidgetFeature.js +80 -0
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/cards/feature/dist/lib/CardsQuickViewWidget/labels.js +27 -0
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/cards/feature/dist/lib/CardsQuickViewWidget/summarizeCardSpend.js +17 -0
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/cards/feature/dist/lib/CardsQuickViewWidget/testIds.js +7 -0
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/cards/feature/dist/lib/CardsQuickViewWidget/useCardSpendSummary.js +29 -0
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/cards/feature/dist/lib/analytics/events.js +4 -0
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/cards/ui/dist/index.js +3 -0
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/cards/ui/dist/index2.js +8 -0
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/cards/ui/dist/index3.js +31 -0
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/feature/dist/lib/QuickViewWidget/QuickViewWidget.js +57 -44
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/feature/dist/lib/QuickViewWidget/labels.js +6 -3
- package/dist/libs/tesouro-embedded-components-react/quick-view-widget/invoices/ui/dist/index2.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/settings-widget/chart-of-accounts/ui/dist/index3.js +98 -91
- package/dist/libs/tesouro-embedded-components-react/settings-widget/feature/dist/lib/ExpenseSettingsTabs/ExpenseSettingsTabs.js +24 -21
- package/dist/libs/tesouro-embedded-components-react/settings-widget/feature/dist/lib/SettingsWidget/SettingsWidget.js +14 -8
- package/dist/libs/tesouro-embedded-components-react/settings-widget/help/ui/shadcn/dist/index3.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/feature/dist/index10.js +87 -81
- package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/ui/dist/index3.js +63 -44
- package/dist/libs/tesouro-embedded-components-react/settings-widget/invoice-settings/ui/dist/index6.js +9 -6
- package/dist/libs/tesouro-embedded-components-react/settings-widget/team/feature/dist/index17.js +302 -276
- package/dist/libs/tesouro-embedded-components-react/settings-widget/team/ui/dist/index.js +10 -10
- package/dist/libs/tesouro-embedded-components-react/settings-widget/team/ui/dist/index12.js +36 -36
- package/dist/libs/tesouro-embedded-components-react/settings-widget/team/ui/dist/index17.js +27 -13
- package/dist/libs/tesouro-embedded-components-react/settings-widget/ui/dist/lib/SettingsWidgetUi/SettingsSectionContent.js +22 -0
- package/dist/libs/tesouro-embedded-components-react/settings-widget/ui/dist/lib/SettingsWidgetUi/SettingsWidgetUi.js +6 -7
- package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/feature/dist/lib/ApprovalPoliciesSettings.js +39 -37
- package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index.js +9 -9
- package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index11.js +39 -35
- package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index16.js +59 -61
- package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index4.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index6.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index7.js +3 -3
- package/dist/libs/tesouro-embedded-components-react/shared/counterpart-management/feature/dist/lib/helpers.js +114 -103
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +43 -43
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/debit-card/useAllDebitCardsQuery.js +22 -18
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +97 -97
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +166 -154
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/util/dist/index.js +12 -12
- package/dist/packages/shared-ui-shadcn/dist/index.js +18 -15
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import "./index4.js";
|
|
2
|
-
export { ExpenseApprovalPoliciesWidget } from "./
|
|
2
|
+
export { ExpenseApprovalPoliciesWidget } from "./index7.js";
|
|
@@ -14,24 +14,24 @@ function m(e, t, n) {
|
|
|
14
14
|
case o.LessThan: return { all: [p, {
|
|
15
15
|
operator: "<",
|
|
16
16
|
left_operand: { name: "transaction.amount" },
|
|
17
|
-
right_operand: (n ?? 0) * 100
|
|
17
|
+
right_operand: Math.round((n ?? 0) * 100)
|
|
18
18
|
}] };
|
|
19
19
|
case o.GreaterThanOrEqual: return { all: [p, {
|
|
20
20
|
operator: ">=",
|
|
21
21
|
left_operand: { name: "transaction.amount" },
|
|
22
|
-
right_operand: (t ?? 0) * 100
|
|
22
|
+
right_operand: Math.round((t ?? 0) * 100)
|
|
23
23
|
}] };
|
|
24
24
|
case o.InRange: return { all: [
|
|
25
25
|
p,
|
|
26
26
|
{
|
|
27
27
|
operator: ">=",
|
|
28
28
|
left_operand: { name: "transaction.amount" },
|
|
29
|
-
right_operand: (t ?? 0) * 100
|
|
29
|
+
right_operand: Math.round((t ?? 0) * 100)
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
32
|
operator: "<",
|
|
33
33
|
left_operand: { name: "transaction.amount" },
|
|
34
|
-
right_operand: (n ?? 0) * 100
|
|
34
|
+
right_operand: Math.round((n ?? 0) * 100)
|
|
35
35
|
}
|
|
36
36
|
] };
|
|
37
37
|
}
|
|
@@ -86,7 +86,7 @@ function _(e) {
|
|
|
86
86
|
let t = e;
|
|
87
87
|
if (t.left_operand?.name !== "transaction.amount") continue;
|
|
88
88
|
let i = Number(t.right_operand) / 100;
|
|
89
|
-
t.operator === ">=" && (n = i), t.operator === "<" && (r = i), t.operator === "<=" && (r =
|
|
89
|
+
t.operator === ">=" && (n = i), t.operator === "<" && (r = i), t.operator === "<=" && (r = (Number(t.right_operand) + 1) / 100);
|
|
90
90
|
}
|
|
91
91
|
return n !== void 0 && r !== void 0 ? {
|
|
92
92
|
conditionType: o.InRange,
|
|
@@ -101,16 +101,16 @@ function _(e) {
|
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
103
|
if (typeof e != "string") return { conditionType: o.All };
|
|
104
|
-
let t = e.replace(/^\{(.*)\}$/, "$1").trim().replace(/^event_name\s*==\s*["'][^'"]*["']\s*&&\s*/, "").trim(), n = t.match(/(?:transaction\.)?amount\s*>=\s*([\d.]+)\s*&&\s*(?:transaction\.)?amount\s
|
|
104
|
+
let t = e.replace(/^\{(.*)\}$/, "$1").trim().replace(/^event_name\s*==\s*["'][^'"]*["']\s*&&\s*/, "").trim(), n = t.match(/(?:transaction\.)?amount\s*>=\s*([\d.]+)\s*&&\s*(?:transaction\.)?amount\s*(<=|<)\s*([\d.]+)/);
|
|
105
105
|
if (n) return {
|
|
106
106
|
conditionType: o.InRange,
|
|
107
107
|
minAmount: Number(n[1]),
|
|
108
|
-
maxAmount: Number(n[2])
|
|
108
|
+
maxAmount: (Math.round(Number(n[3]) * 100) + +(n[2] === "<=")) / 100
|
|
109
109
|
};
|
|
110
|
-
let r = t.match(/^(?:transaction\.)?amount\s
|
|
110
|
+
let r = t.match(/^(?:transaction\.)?amount\s*(<=|<)\s*([\d.]+)$/);
|
|
111
111
|
if (r) return {
|
|
112
112
|
conditionType: o.LessThan,
|
|
113
|
-
maxAmount: Number(r[1])
|
|
113
|
+
maxAmount: (Math.round(Number(r[2]) * 100) + +(r[1] === "<=")) / 100
|
|
114
114
|
};
|
|
115
115
|
let i = t.match(/^(?:transaction\.)?amount\s*>=\s*([\d.]+)$/);
|
|
116
116
|
return i ? {
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
var e = {
|
|
3
3
|
AdminLabel: "Company admin",
|
|
4
4
|
AdminSublabel: "Any company admin can approve",
|
|
5
|
-
ReportingManagerLabel: "Reporting
|
|
5
|
+
ReportingManagerLabel: "Reporting manager",
|
|
6
6
|
ReportingManagerSublabel: "Assigned reporting managers can approve",
|
|
7
7
|
CfoLabel: "Finance admin",
|
|
8
8
|
CfoSublabel: "Any finance admin can approve"
|
|
9
9
|
}, t = {
|
|
10
10
|
InvalidMinAmount: "Enter a valid minimum amount",
|
|
11
11
|
InvalidMaxAmount: "Enter a valid maximum amount",
|
|
12
|
-
MaxLessThanOrEqualToMin: "Maximum amount
|
|
12
|
+
MaxLessThanOrEqualToMin: "Maximum amount cannot be less than the minimum amount",
|
|
13
13
|
ApproversRequired: "At least one approver is required",
|
|
14
14
|
ConflictsWithAnotherRule: "This conflicts with another rule"
|
|
15
15
|
}, n = {
|
|
@@ -1,289 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import { isOrganizationOnItsWay as t } from "../../../../shared/data-access/dist/lib/organizationStatus.js";
|
|
7
|
-
import { useEmbedApi as n } from "../../../../shared/data-access/dist/lib/EmbedApiContext.js";
|
|
8
|
-
import { Scope as r } from "../../../../shared/data-access/dist/lib/scopes.js";
|
|
9
|
-
import { useAllOrganizationRolesQuery as i } from "../../../../shared/data-access/dist/lib/role/useAllOrganizationRolesQuery.js";
|
|
10
|
-
import "../../../../shared/data-access/dist/index.js";
|
|
11
|
-
import { EmbeddedToaster as a } from "../../../../shared/ui/dist/lib/EmbeddedToaster.js";
|
|
12
|
-
import { ErrorState as o } from "../../../../shared/ui/dist/lib/ErrorState/ErrorState.js";
|
|
13
|
-
import "../../../../shared/ui/dist/index.js";
|
|
14
|
-
import { useAnalyticsTrack as s } from "../../../../shared/feature/dist/lib/analytics/hooks.js";
|
|
15
|
-
import { WidgetProvider as c } from "../../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
|
|
16
|
-
import { useWidgetConfig as ee, useWidgetLoading as te } from "../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
|
|
17
|
-
import "../../../../shared/feature/dist/index.js";
|
|
18
|
-
import { DeleteRuleDialogDefaultLabels as ne } from "../../../../shared/approval-policy/ui/dist/index18.js";
|
|
19
|
-
import { DeleteRuleDialog as re } from "../../../../shared/approval-policy/ui/dist/index19.js";
|
|
20
|
-
import "../../../../shared/approval-policy/ui/dist/index.js";
|
|
21
|
-
import { ApproverOptionLabels as l, PermissionErrorLabels as ie, ValidationErrorLabels as u } from "./index4.js";
|
|
22
|
-
import { ExpenseApprovalPoliciesAnalyticsEvent as ae, WIDGET_NAME as d } from "./index2.js";
|
|
23
|
-
import { AmountConditionType as f, ApprovalOutcomeType as p } from "../../ui/dist/index2.js";
|
|
24
|
-
import { ApprovalRuleCardLabels as oe, ApprovalRuleToastLabels as se } from "../../ui/dist/index3.js";
|
|
25
|
-
import { formatAmount as m } from "../../ui/dist/index4.js";
|
|
26
|
-
import { ExpenseApprovalsPage as ce } from "../../ui/dist/index8.js";
|
|
1
|
+
import { formatMoneyExact as e } from "../../../../shared/util/dist/lib/formatMoneyExact.js";
|
|
2
|
+
import "../../../../shared/util/dist/index.js";
|
|
3
|
+
import { formatMinorUnitsAsAmountInput as t, parseAmountInputToMinorUnits as n } from "../../../../shared/approval-policy/util/dist/lib/amountInput.js";
|
|
4
|
+
import { ApprovalOutcomeType as r } from "../../ui/dist/index2.js";
|
|
5
|
+
import { ApprovalRuleCardLabels as i } from "../../ui/dist/index3.js";
|
|
27
6
|
import "../../ui/dist/index.js";
|
|
28
|
-
import { useApprovalPolicies as le } from "./index3.js";
|
|
29
|
-
import { expenseApprovalPoliciesTestIds as h } from "./index5.js";
|
|
30
|
-
import { useEffect as g, useMemo as _, useRef as ue, useState as v } from "react";
|
|
31
|
-
import { Fragment as de, jsx as y, jsxs as fe } from "react/jsx-runtime";
|
|
32
7
|
// ../../libs/tesouro-embedded-components-react/expense-management-widget/approval-policies/feature/dist/index6.js
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
function
|
|
40
|
-
let
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
function w(e, t = l) {
|
|
50
|
-
let n = e.find((e) => e.isSystemRole === !0 && x(e.key, "admin")), r = e.find((e) => e.isSystemRole === !0 && C(e.key)), i = e.filter((e) => e.isSystemRole === !0 && e !== n && e !== r && !S(e.key, "employee") && !S(e.key, "bookkeeper")).map((e) => ({
|
|
51
|
-
id: e.id,
|
|
52
|
-
label: e.name
|
|
53
|
-
})), a = e.filter((e) => !e.isSystemRole && e.status?.toLowerCase() === "active").map((e) => ({
|
|
54
|
-
id: e.id,
|
|
55
|
-
label: e.name
|
|
56
|
-
}));
|
|
57
|
-
return [
|
|
58
|
-
...n ? [{
|
|
59
|
-
id: n.id,
|
|
60
|
-
label: t.AdminLabel,
|
|
61
|
-
sublabel: t.AdminSublabel
|
|
62
|
-
}] : [],
|
|
63
|
-
{
|
|
64
|
-
id: "reporting_manager",
|
|
65
|
-
label: t.ReportingManagerLabel,
|
|
66
|
-
sublabel: t.ReportingManagerSublabel
|
|
67
|
-
},
|
|
68
|
-
...r ? [{
|
|
69
|
-
id: r.id,
|
|
70
|
-
label: t.CfoLabel,
|
|
71
|
-
sublabel: t.CfoSublabel
|
|
72
|
-
}] : [],
|
|
73
|
-
...i,
|
|
74
|
-
...a
|
|
75
|
-
];
|
|
76
|
-
}
|
|
77
|
-
function T(e) {
|
|
78
|
-
let t = e.minAmount.trim() !== "", n = e.maxAmount.trim() !== "";
|
|
79
|
-
return t && n ? f.InRange : t ? f.GreaterThanOrEqual : n ? f.LessThan : f.All;
|
|
80
|
-
}
|
|
81
|
-
function E(e) {
|
|
82
|
-
return [e.conditionType === f.LessThan || e.conditionType === f.All ? 0 : e.minAmount ?? 0, e.conditionType === f.GreaterThanOrEqual || e.conditionType === f.All ? Infinity : e.maxAmount ?? 0];
|
|
83
|
-
}
|
|
84
|
-
function pe(e) {
|
|
85
|
-
if (e.length === 0) return !1;
|
|
86
|
-
let t = e.map(E).sort((e, t) => e[0] - t[0]);
|
|
87
|
-
if (t[0][0] > 0) return !1;
|
|
88
|
-
let n = 0;
|
|
89
|
-
for (let [e, r] of t) {
|
|
90
|
-
if (e > n) return !1;
|
|
91
|
-
n = Math.max(n, r);
|
|
92
|
-
}
|
|
93
|
-
return n === Infinity;
|
|
94
|
-
}
|
|
95
|
-
function me(e) {
|
|
96
|
-
if (e.length === 0) return [];
|
|
97
|
-
let t = e.map(E).sort((e, t) => e[0] - t[0]), n = [], r = 0;
|
|
98
|
-
for (let [e, i] of t) e > r && n.push({
|
|
99
|
-
from: r,
|
|
100
|
-
to: e
|
|
101
|
-
}), r = Math.max(r, i);
|
|
102
|
-
return r !== Infinity && n.push({
|
|
103
|
-
from: r,
|
|
104
|
-
to: null
|
|
105
|
-
}), n;
|
|
106
|
-
}
|
|
107
|
-
function D(e) {
|
|
108
|
-
let t = Number(e.minAmount) || 0, n = Number(e.maxAmount) || 0, r = T(e);
|
|
109
|
-
return [r === f.LessThan || r === f.All ? 0 : t, r === f.GreaterThanOrEqual || r === f.All ? Infinity : n];
|
|
110
|
-
}
|
|
111
|
-
function O(e, t, n) {
|
|
112
|
-
let [r, i] = D(e);
|
|
113
|
-
return t.filter((e) => e.id !== n).some((e) => {
|
|
114
|
-
let [t, n] = E(e);
|
|
115
|
-
return r < n && t < i;
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
function k(e, t, n, r = u) {
|
|
119
|
-
let i = {}, a = e.minAmount.trim() !== "", o = e.maxAmount.trim() !== "", s = Number(e.minAmount.trim()), c = Number(e.maxAmount.trim());
|
|
120
|
-
return a && (!Number.isFinite(s) || s < 0) && (i.minAmount = r.InvalidMinAmount), o && (!Number.isFinite(c) || c <= 0) && (i.maxAmount = r.InvalidMaxAmount), a && o && !i.minAmount && !i.maxAmount && s >= c && (i.maxAmount = r.MaxLessThanOrEqualToMin), e.outcome === p.RequireApproval && e.approvers.length === 0 && (i.approvers = r.ApproversRequired), !i.minAmount && !i.maxAmount && O(e, t, n) && (o ? i.maxAmount = r.ConflictsWithAnotherRule : i.minAmount = r.ConflictsWithAnotherRule), i;
|
|
121
|
-
}
|
|
122
|
-
function A(e, t) {
|
|
123
|
-
let n = T(t);
|
|
124
|
-
return {
|
|
125
|
-
id: e,
|
|
126
|
-
conditionType: n,
|
|
127
|
-
minAmount: n === f.InRange || n === f.GreaterThanOrEqual ? Number(t.minAmount) : void 0,
|
|
128
|
-
maxAmount: n === f.LessThan || n === f.InRange ? Number(t.maxAmount) : void 0,
|
|
129
|
-
outcome: t.outcome,
|
|
130
|
-
approvers: t.outcome === p.RequireApproval ? t.approvers : []
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
function he(e) {
|
|
8
|
+
function a(e) {
|
|
9
|
+
return (Math.round(e * 100) - 1) / 100;
|
|
10
|
+
}
|
|
11
|
+
function o(e) {
|
|
12
|
+
return t(Math.round(e * 100) - 1);
|
|
13
|
+
}
|
|
14
|
+
function s(e) {
|
|
15
|
+
let t = n(e);
|
|
16
|
+
if (t.status !== "ok") throw Error("Invalid maximum amount");
|
|
17
|
+
return (t.minorUnits + 1) / 100;
|
|
18
|
+
}
|
|
19
|
+
function c(t, n = i) {
|
|
20
|
+
let o = t.minAmount, s = t.maxAmount === void 0 ? void 0 : a(t.maxAmount), c = (t) => e(t, {
|
|
21
|
+
currencyCode: "USD",
|
|
22
|
+
includeSpaceAfterCurrencySymbol: !1
|
|
23
|
+
}), l = (e) => e.replace("{lower}", o === void 0 ? "" : c(o)).replace("{upper}", s === void 0 ? "" : c(s)), u = o !== void 0 && s !== void 0 ? n.TitleRange : s === void 0 ? o === void 0 ? n.TitleAll : n.TitleFrom : n.TitleUpTo, d = t.outcome === r.AutoApprove ? n.SentenceAutoApprove : o !== void 0 && s !== void 0 ? n.SentenceRange : s === void 0 ? o === void 0 ? n.SentenceAll : n.SentenceFrom : n.SentenceUpTo;
|
|
134
24
|
return {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
approvers: e.approvers
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
function j({ headerActionContainer: c, labels: d }) {
|
|
142
|
-
let S = _(() => ({
|
|
143
|
-
...l,
|
|
144
|
-
...d?.approvers
|
|
145
|
-
}), [d?.approvers]), T = _(() => ({
|
|
146
|
-
...u,
|
|
147
|
-
...d?.validation
|
|
148
|
-
}), [d?.validation]), E = _(() => ({
|
|
149
|
-
...ie,
|
|
150
|
-
...d?.errors
|
|
151
|
-
}), [d?.errors]), D = _(() => ({
|
|
152
|
-
...se,
|
|
153
|
-
...d?.toast
|
|
154
|
-
}), [d?.toast]), O = s();
|
|
155
|
-
g(() => {
|
|
156
|
-
O(ae.Mounted);
|
|
157
|
-
}, [O]);
|
|
158
|
-
let { initResponse: j } = ee(), M = te(), ge = t(n().organizationStatus), N = j?.scopes?.includes(r.RoleReadOrg) ?? !1, { data: P, isResolving: _e, isError: ve, refetch: ye } = i({ enabled: N }), be = _(() => w(P?.data ?? [], S), [P, S]), xe = _(() => {
|
|
159
|
-
let e = P?.data ?? [], t = e.find((e) => e.isSystemRole === !0 && x(e.key, "admin")), n = e.find((e) => e.isSystemRole === !0 && C(e.key)), r = { reporting_manager: S.ReportingManagerLabel };
|
|
160
|
-
t && (r[t.id] = S.AdminLabel), n && (r[n.id] = S.CfoLabel);
|
|
161
|
-
for (let t of e) r[t.id] || (r[t.id] = t.name);
|
|
162
|
-
return r;
|
|
163
|
-
}, [P, S]), { rules: F, isLoading: I, isError: Se, refetch: Ce, hasLoaded: L, saveStatus: R, createRule: we, updateRule: Te, deleteRule: Ee } = le(xe), [z, B] = v(!1), [V, H] = v(null), [U, W] = v(!1), [G, K] = v(b), [q, J] = v(null), [Y, X] = v(null), Z = ue(D);
|
|
164
|
-
g(() => {
|
|
165
|
-
Z.current = D;
|
|
166
|
-
}, [D]), g(() => {
|
|
167
|
-
R === "success" && e.success(Z.current.Saved), R === "error" && e.error(Z.current.FailedToSave);
|
|
168
|
-
}, [R]);
|
|
169
|
-
let Q = I || M && !j || ge && !L, De = pe(F), Oe = me(F), $ = Q || _e || R === "saving", ke = U && z ? k(G, F, void 0, T) : {}, Ae = Y && q && z ? k(Y, F, q, T) : {}, je = () => {
|
|
170
|
-
B(!1), W(!0), K(b);
|
|
171
|
-
}, Me = () => {
|
|
172
|
-
B(!1), W(!1);
|
|
173
|
-
}, Ne = async () => {
|
|
174
|
-
B(!0);
|
|
175
|
-
let e = k(G, F, void 0, T);
|
|
176
|
-
if (Object.keys(e).length > 0) return;
|
|
177
|
-
let t = crypto.randomUUID();
|
|
178
|
-
await we(A(t, G)) && (W(!1), K(b));
|
|
179
|
-
}, Pe = (e) => {
|
|
180
|
-
K(e);
|
|
181
|
-
}, Fe = (e) => {
|
|
182
|
-
B(!1);
|
|
183
|
-
let t = F.find((t) => t.id === e);
|
|
184
|
-
t && (W(!1), K(b), J(e), X(he(t)));
|
|
185
|
-
}, Ie = () => {
|
|
186
|
-
B(!1), J(null), X(null);
|
|
187
|
-
}, Le = async () => {
|
|
188
|
-
if (B(!0), !q || !Y) return;
|
|
189
|
-
let e = k(Y, F, q, T);
|
|
190
|
-
Object.keys(e).length > 0 || await Te(q, A(q, Y)) && (J(null), X(null));
|
|
191
|
-
}, Re = (e) => {
|
|
192
|
-
X(e);
|
|
193
|
-
}, ze = (() => {
|
|
194
|
-
let e = F.find((e) => e.id === V);
|
|
195
|
-
if (!e) return;
|
|
196
|
-
let t = {
|
|
197
|
-
...ne,
|
|
198
|
-
...d?.deleteDialog
|
|
199
|
-
}, n = {
|
|
200
|
-
...oe,
|
|
201
|
-
...d?.ruleCard
|
|
202
|
-
}, r = `${n.For} ${n.Expenses}`, i = `${n.For} ${n.All} ${n.Expenses}`;
|
|
203
|
-
e.conditionType === f.LessThan && (i = `${r} ${n.LessThan} ${m(e.maxAmount ?? 0)}`), e.conditionType === f.GreaterThanOrEqual && (i = `${r} ${n.GreaterThanOrEqual} ${m(e.minAmount ?? 0)}`), e.conditionType === f.InRange && (i = `${r} ${n.GreaterThanOrEqual} ${m(e.minAmount ?? 0)} ${n.AndLessThan} ${m(e.maxAmount ?? 0)}`);
|
|
204
|
-
let a = e.outcome === p.AutoApprove ? n.AutoApprove : `${n.RequireApprovalFrom} ${e.approvers.map((e) => e.label).join(` ${n.ApproverSeparator} `)}`;
|
|
205
|
-
return [{
|
|
206
|
-
label: t.Range,
|
|
207
|
-
value: i
|
|
208
|
-
}, {
|
|
209
|
-
label: t.Outcome,
|
|
210
|
-
value: a
|
|
211
|
-
}];
|
|
212
|
-
})(), Be = async () => {
|
|
213
|
-
V && await Ee(V) && (q === V && (J(null), X(null)), H(null));
|
|
25
|
+
...t,
|
|
26
|
+
title: l(u),
|
|
27
|
+
sentence: l(d)
|
|
214
28
|
};
|
|
215
|
-
return j !== void 0 && !N ? /* @__PURE__ */ y(o, {
|
|
216
|
-
title: E.MissingRolePermissionTitle,
|
|
217
|
-
description: E.MissingRolePermissionDescription
|
|
218
|
-
}) : ve ? /* @__PURE__ */ y(o, {
|
|
219
|
-
title: E.RolesUnavailableTitle,
|
|
220
|
-
description: E.RolesUnavailableDescription,
|
|
221
|
-
retryLabel: E.Retry,
|
|
222
|
-
onRetry: () => void ye()
|
|
223
|
-
}) : Se && !I && !L ? /* @__PURE__ */ y(o, {
|
|
224
|
-
title: E.PoliciesUnavailableTitle,
|
|
225
|
-
description: E.PoliciesUnavailableDescription,
|
|
226
|
-
retryLabel: E.Retry,
|
|
227
|
-
onRetry: () => void Ce()
|
|
228
|
-
}) : /* @__PURE__ */ fe(de, { children: [
|
|
229
|
-
/* @__PURE__ */ y(a, {}),
|
|
230
|
-
/* @__PURE__ */ y(ce, {
|
|
231
|
-
rules: F,
|
|
232
|
-
labels: d,
|
|
233
|
-
isBusy: $,
|
|
234
|
-
isLoading: Q,
|
|
235
|
-
isAddingRule: U,
|
|
236
|
-
newRuleFormValues: G,
|
|
237
|
-
newRuleValidationErrors: ke,
|
|
238
|
-
editingRuleId: q,
|
|
239
|
-
editingRuleFormValues: Y,
|
|
240
|
-
editingRuleValidationErrors: Ae,
|
|
241
|
-
approverOptions: $ ? [] : be,
|
|
242
|
-
allExpensesAreCovered: De,
|
|
243
|
-
gapIntervals: Oe,
|
|
244
|
-
onAddRuleClick: je,
|
|
245
|
-
headerActionContainer: c,
|
|
246
|
-
onCancelAddRule: Me,
|
|
247
|
-
onSaveNewRule: () => void Ne(),
|
|
248
|
-
onNewRuleFormChange: Pe,
|
|
249
|
-
onEditRule: Fe,
|
|
250
|
-
onCancelEditRule: Ie,
|
|
251
|
-
onSaveEditRule: () => void Le(),
|
|
252
|
-
onEditRuleFormChange: Re,
|
|
253
|
-
onDeleteRule: H,
|
|
254
|
-
testIds: {
|
|
255
|
-
ruleCard: { root: h.ruleCard },
|
|
256
|
-
ruleForm: {
|
|
257
|
-
root: h.ruleForm,
|
|
258
|
-
saveButton: h.ruleFormSaveButton,
|
|
259
|
-
minAmountInput: h.ruleFormMinAmountInput,
|
|
260
|
-
maxAmountInput: h.ruleFormMaxAmountInput
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}),
|
|
264
|
-
/* @__PURE__ */ y(re, {
|
|
265
|
-
labels: d?.deleteDialog,
|
|
266
|
-
details: ze,
|
|
267
|
-
open: V !== null,
|
|
268
|
-
onOpenChange: (e) => {
|
|
269
|
-
e || H(null);
|
|
270
|
-
},
|
|
271
|
-
onCancel: () => H(null),
|
|
272
|
-
onConfirm: () => void Be(),
|
|
273
|
-
isDeleting: R === "saving"
|
|
274
|
-
})
|
|
275
|
-
] });
|
|
276
|
-
}
|
|
277
|
-
function M({ token: e, orgId: t, widgetToken: n, organizationId: r, headerActionContainer: i, labels: a, ...o } = {}) {
|
|
278
|
-
return /* @__PURE__ */ y(c, {
|
|
279
|
-
...o,
|
|
280
|
-
widgetName: d,
|
|
281
|
-
widgetToken: n === void 0 ? e : n,
|
|
282
|
-
organizationId: r === void 0 ? t : r,
|
|
283
|
-
children: /* @__PURE__ */ y(j, {
|
|
284
|
-
headerActionContainer: i,
|
|
285
|
-
labels: a
|
|
286
|
-
})
|
|
287
|
-
});
|
|
288
29
|
}
|
|
289
|
-
export {
|
|
30
|
+
export { a as maximumForDisplay, s as maximumForSave, o as maximumInputForDisplay, c as ruleForDisplay };
|