@burdenoff/microfe-bigconsole 2026.1117.1 → 2026.1117.3
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/bigconsole/components/insights/DraftCheckDialog.d.ts +6 -0
- package/dist/bigconsole/components/insights/DraftCheckDialog.js +148 -47
- package/dist/bigconsole/components/reconcile/KpiReconcileDialog.d.ts +25 -0
- package/dist/bigconsole/components/reconcile/KpiReconcileDialog.js +723 -0
- package/dist/bigconsole/components/reconcile/reconcileModel.d.ts +101 -0
- package/dist/bigconsole/components/reconcile/reconcileModel.js +222 -0
- package/dist/bigconsole/components/widgets/WidgetHeader.d.ts +2 -0
- package/dist/bigconsole/components/widgets/WidgetHeader.js +3 -2
- package/dist/bigconsole/components/widgets/WidgetMenu.d.ts +2 -0
- package/dist/bigconsole/components/widgets/WidgetMenu.js +60 -41
- package/dist/bigconsole/components/widgets/WidgetWrapper.js +263 -253
- package/dist/bigconsole/pages/InsightsPage.js +551 -521
- package/dist/bigconsole/utils/boardLint.d.ts +87 -0
- package/dist/bigconsole/utils/boardLint.js +273 -0
- package/dist/bigconsole/utils/consoleDefinition.d.ts +9 -0
- package/dist/generated/wspace-operations.d.ts +403 -0
- package/dist/generated/wspace-operations.js +1248 -46
- package/dist/generated/wspace-types.d.ts +305 -0
- package/package.json +1 -1
|
@@ -0,0 +1,723 @@
|
|
|
1
|
+
import { KpiReconcilableCardsDocument as e, KpiReconciliationCardFieldsDocument as t, KpiReconciliationItemsDocument as n, ReconcileKpiCardsDocument as r } from "../../../generated/wspace-operations.js";
|
|
2
|
+
import { useBigConsole as i } from "../../context/BigConsoleContext.js";
|
|
3
|
+
import "../../context/index.js";
|
|
4
|
+
import { Section as a } from "../common/Section.js";
|
|
5
|
+
import "../common/index.js";
|
|
6
|
+
import { applySuggestions as o, assistantFocus as s, browserTimezone as c, buildInput as l, currencyFromConfig as u, loadSavedSide as d, missingForRun as f, previousMonth as p, restoreSavedSide as m, saveDraft as h, swapSides as g } from "./reconcileModel.js";
|
|
7
|
+
import { memo as _, useCallback as v, useEffect as y, useMemo as b, useRef as x, useState as S } from "react";
|
|
8
|
+
import { ArrowLeftRight as C, CheckCircle as w, Loader2 as T, MessageSquare as E, Play as D, ShieldAlert as O, XCircle as k } from "lucide-react";
|
|
9
|
+
import { Button as A, ResponsiveDialog as ee, ResponsiveDialogContent as te, ResponsiveDialogDescription as ne, ResponsiveDialogHeader as re, ResponsiveDialogTitle as ie } from "@burdenoff/fe-libs/ui";
|
|
10
|
+
import { useI18n as j } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
11
|
+
import { useApolloClient as ae, useQuery as M } from "@apollo/client/react";
|
|
12
|
+
import { Fragment as oe, jsx as N, jsxs as P } from "react/jsx-runtime";
|
|
13
|
+
import { askAssistantAbout as se } from "@burdenoff/fe-libs/shared/assistant/askAbout/useAskable";
|
|
14
|
+
// src/bigconsole/components/reconcile/KpiReconcileDialog.tsx
|
|
15
|
+
var F = 50, I = {
|
|
16
|
+
width: "100%",
|
|
17
|
+
minHeight: "var(--size-controlHeight-md)",
|
|
18
|
+
padding: "0 var(--space-controlGap)",
|
|
19
|
+
borderRadius: "var(--radius-input)",
|
|
20
|
+
border: "1px solid var(--color-border-default)",
|
|
21
|
+
backgroundColor: "var(--color-bg-canvas)",
|
|
22
|
+
color: "var(--color-text-primary)",
|
|
23
|
+
fontSize: "var(--font-size-body-sm)"
|
|
24
|
+
}, L = {
|
|
25
|
+
display: "block",
|
|
26
|
+
marginBottom: "2px",
|
|
27
|
+
fontSize: "var(--font-size-body-sm)",
|
|
28
|
+
fontWeight: "var(--font-weight-medium)",
|
|
29
|
+
color: "var(--color-text-secondary)"
|
|
30
|
+
}, R = {
|
|
31
|
+
display: "grid",
|
|
32
|
+
gridTemplateColumns: "repeat(auto-fit, minmax(min(150px, 100%), 1fr))",
|
|
33
|
+
gap: "var(--space-controlGap)"
|
|
34
|
+
}, z = (e) => ({
|
|
35
|
+
requiredWorkspaceAuth: !0,
|
|
36
|
+
requiredWorkspaceId: e,
|
|
37
|
+
queryDeduplication: !1
|
|
38
|
+
});
|
|
39
|
+
function B() {
|
|
40
|
+
try {
|
|
41
|
+
return typeof window > "u" ? null : window.localStorage;
|
|
42
|
+
} catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function V(e, t, n) {
|
|
47
|
+
return {
|
|
48
|
+
widgetId: e,
|
|
49
|
+
title: t,
|
|
50
|
+
keyField: "",
|
|
51
|
+
amountField: "",
|
|
52
|
+
dateField: "",
|
|
53
|
+
currency: n,
|
|
54
|
+
refundEvidenceField: "",
|
|
55
|
+
recordsPath: "",
|
|
56
|
+
mappingSettled: !1
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function H(e) {
|
|
60
|
+
return !e || /^-?0(\.0+)?$/.test(e) ? "text-text-primary" : e.startsWith("-") ? "text-status-error-text" : "text-status-success-text";
|
|
61
|
+
}
|
|
62
|
+
var U = _(function({ side: e, role: n, disabled: r, onChange: a }) {
|
|
63
|
+
let { t: s } = j(), { workspaceId: c } = i(), { data: l, loading: u } = M(t, {
|
|
64
|
+
variables: {
|
|
65
|
+
widgetId: e.widgetId,
|
|
66
|
+
recordsPath: e.recordsPath.trim() || null
|
|
67
|
+
},
|
|
68
|
+
skip: !e.widgetId,
|
|
69
|
+
fetchPolicy: "network-only",
|
|
70
|
+
context: z(c)
|
|
71
|
+
}), d = l?.kpiReconciliationCardFields, f = b(() => d?.fields ?? [], [d]);
|
|
72
|
+
y(() => {
|
|
73
|
+
let t = o(e, f);
|
|
74
|
+
t && a(t);
|
|
75
|
+
}, [
|
|
76
|
+
f,
|
|
77
|
+
e,
|
|
78
|
+
a
|
|
79
|
+
]);
|
|
80
|
+
let p = (t, n, i, o, c = !1) => /* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("label", {
|
|
81
|
+
htmlFor: t,
|
|
82
|
+
style: L,
|
|
83
|
+
children: n
|
|
84
|
+
}), /* @__PURE__ */ P("select", {
|
|
85
|
+
id: t,
|
|
86
|
+
value: i,
|
|
87
|
+
disabled: r || u,
|
|
88
|
+
onChange: (t) => a({
|
|
89
|
+
...e,
|
|
90
|
+
[o]: t.target.value
|
|
91
|
+
}),
|
|
92
|
+
style: I,
|
|
93
|
+
"data-testid": t,
|
|
94
|
+
children: [
|
|
95
|
+
/* @__PURE__ */ N("option", {
|
|
96
|
+
value: "",
|
|
97
|
+
children: c ? s("bigconsole.reconcile.none", "None") : s("bigconsole.reconcile.choose", "Choose…")
|
|
98
|
+
}),
|
|
99
|
+
f.map((e) => /* @__PURE__ */ P("option", {
|
|
100
|
+
value: e.name,
|
|
101
|
+
disabled: e.restricted,
|
|
102
|
+
children: [e.name, e.restricted ? ` (${s("bigconsole.reconcile.restricted", "restricted")})` : ""]
|
|
103
|
+
}, e.name)),
|
|
104
|
+
i && !f.some((e) => e.name === i) ? /* @__PURE__ */ N("option", {
|
|
105
|
+
value: i,
|
|
106
|
+
children: i
|
|
107
|
+
}) : null
|
|
108
|
+
]
|
|
109
|
+
})] });
|
|
110
|
+
return /* @__PURE__ */ P("fieldset", {
|
|
111
|
+
className: "space-y-2 rounded-md border border-[var(--color-border-subtle)] p-3",
|
|
112
|
+
"data-testid": `reconcile-side-${n}`,
|
|
113
|
+
children: [
|
|
114
|
+
/* @__PURE__ */ P("legend", {
|
|
115
|
+
className: "px-1 text-sm font-medium text-text-primary",
|
|
116
|
+
children: [
|
|
117
|
+
n === "left" ? s("bigconsole.reconcile.leftCard", "Subtract from") : s("bigconsole.reconcile.rightCard", "Subtract"),
|
|
118
|
+
": ",
|
|
119
|
+
/* @__PURE__ */ N("span", {
|
|
120
|
+
className: "font-semibold",
|
|
121
|
+
children: e.title
|
|
122
|
+
})
|
|
123
|
+
]
|
|
124
|
+
}),
|
|
125
|
+
d && !d.available ? /* @__PURE__ */ N("p", {
|
|
126
|
+
className: "text-xs text-status-error-text",
|
|
127
|
+
role: "alert",
|
|
128
|
+
children: d.message
|
|
129
|
+
}) : null,
|
|
130
|
+
d?.available ? /* @__PURE__ */ N("p", {
|
|
131
|
+
className: "text-xs text-text-secondary",
|
|
132
|
+
children: s("bigconsole.reconcile.recordCount", "{{count}} records visible to you", { count: d.recordCount })
|
|
133
|
+
}) : null,
|
|
134
|
+
/* @__PURE__ */ P("div", {
|
|
135
|
+
style: R,
|
|
136
|
+
children: [
|
|
137
|
+
p(`reconcile-${n}-key`, s("bigconsole.reconcile.keyField", "Match on (key)"), e.keyField, "keyField"),
|
|
138
|
+
p(`reconcile-${n}-amount`, s("bigconsole.reconcile.amountField", "Amount"), e.amountField, "amountField"),
|
|
139
|
+
p(`reconcile-${n}-date`, s("bigconsole.reconcile.dateField", "Date field"), e.dateField, "dateField"),
|
|
140
|
+
/* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("label", {
|
|
141
|
+
htmlFor: `reconcile-${n}-currency`,
|
|
142
|
+
style: L,
|
|
143
|
+
children: s("bigconsole.reconcile.currency", "Currency")
|
|
144
|
+
}), /* @__PURE__ */ N("input", {
|
|
145
|
+
id: `reconcile-${n}-currency`,
|
|
146
|
+
value: e.currency,
|
|
147
|
+
maxLength: 3,
|
|
148
|
+
placeholder: "INR",
|
|
149
|
+
disabled: r,
|
|
150
|
+
onChange: (t) => a({
|
|
151
|
+
...e,
|
|
152
|
+
currency: t.target.value.toUpperCase()
|
|
153
|
+
}),
|
|
154
|
+
style: I,
|
|
155
|
+
"data-testid": `reconcile-${n}-currency`
|
|
156
|
+
})] }),
|
|
157
|
+
p(`reconcile-${n}-refund`, s("bigconsole.reconcile.refundField", "Linked refund (evidence)"), e.refundEvidenceField, "refundEvidenceField", !0),
|
|
158
|
+
/* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("label", {
|
|
159
|
+
htmlFor: `reconcile-${n}-records-path`,
|
|
160
|
+
style: L,
|
|
161
|
+
children: s("bigconsole.reconcile.recordsPath", "Records path (optional)")
|
|
162
|
+
}), /* @__PURE__ */ N("input", {
|
|
163
|
+
id: `reconcile-${n}-records-path`,
|
|
164
|
+
value: e.recordsPath,
|
|
165
|
+
placeholder: "rows",
|
|
166
|
+
disabled: r,
|
|
167
|
+
onChange: (t) => a({
|
|
168
|
+
...e,
|
|
169
|
+
recordsPath: t.target.value
|
|
170
|
+
}),
|
|
171
|
+
style: I
|
|
172
|
+
})] })
|
|
173
|
+
]
|
|
174
|
+
})
|
|
175
|
+
]
|
|
176
|
+
});
|
|
177
|
+
}), W = _(function({ input: e, group: t, leftTitle: r, rightTitle: a }) {
|
|
178
|
+
let { t: o } = j(), s = ae(), { workspaceId: c } = i(), l = M(n, {
|
|
179
|
+
variables: {
|
|
180
|
+
input: e,
|
|
181
|
+
group: t,
|
|
182
|
+
first: F,
|
|
183
|
+
offset: 0
|
|
184
|
+
},
|
|
185
|
+
fetchPolicy: "network-only",
|
|
186
|
+
context: z(c)
|
|
187
|
+
}), [u, d] = S([]), [f, p] = S(!1), [m, h] = S(null), g = x(!0);
|
|
188
|
+
y(() => (g.current = !0, () => {
|
|
189
|
+
g.current = !1;
|
|
190
|
+
}), []);
|
|
191
|
+
let _ = l.data?.kpiReconciliationItems, b = _ ? [_, ...u] : [], C = l.loading || f, w = l.error?.message ?? m, E = v(async (r) => {
|
|
192
|
+
p(!0), h(null);
|
|
193
|
+
try {
|
|
194
|
+
let i = await s.query({
|
|
195
|
+
query: n,
|
|
196
|
+
variables: {
|
|
197
|
+
input: e,
|
|
198
|
+
group: t,
|
|
199
|
+
first: F,
|
|
200
|
+
offset: r
|
|
201
|
+
},
|
|
202
|
+
fetchPolicy: "network-only",
|
|
203
|
+
context: z(c)
|
|
204
|
+
});
|
|
205
|
+
if (!g.current) return;
|
|
206
|
+
let a = i.data?.kpiReconciliationItems;
|
|
207
|
+
if (!a) throw Error("No records were returned.");
|
|
208
|
+
d((e) => [...e, a]);
|
|
209
|
+
} catch (e) {
|
|
210
|
+
g.current && h(e instanceof Error ? e.message : "Could not load the records.");
|
|
211
|
+
} finally {
|
|
212
|
+
g.current && p(!1);
|
|
213
|
+
}
|
|
214
|
+
}, [
|
|
215
|
+
s,
|
|
216
|
+
e,
|
|
217
|
+
t,
|
|
218
|
+
c
|
|
219
|
+
]), D = b[b.length - 1], O = b.flatMap((e) => e.items);
|
|
220
|
+
return D && D.status !== "OK" ? /* @__PURE__ */ N("p", {
|
|
221
|
+
className: "text-xs text-status-error-text",
|
|
222
|
+
role: "alert",
|
|
223
|
+
"data-testid": "reconcile-items-restricted",
|
|
224
|
+
children: D.problems.map((e) => e.message).join(" ") || o("bigconsole.reconcile.itemsUnavailable", "These records are not available.")
|
|
225
|
+
}) : /* @__PURE__ */ P("div", {
|
|
226
|
+
className: "space-y-2",
|
|
227
|
+
"data-testid": `reconcile-items-${t}`,
|
|
228
|
+
children: [
|
|
229
|
+
w ? /* @__PURE__ */ N("p", {
|
|
230
|
+
className: "text-xs text-status-error-text",
|
|
231
|
+
role: "alert",
|
|
232
|
+
children: w
|
|
233
|
+
}) : null,
|
|
234
|
+
O.length === 0 && !C && !w ? /* @__PURE__ */ N("p", {
|
|
235
|
+
className: "text-xs text-text-secondary",
|
|
236
|
+
children: o("bigconsole.reconcile.noItems", "No records in this group.")
|
|
237
|
+
}) : null,
|
|
238
|
+
O.length > 0 ? /* @__PURE__ */ N("div", {
|
|
239
|
+
className: "overflow-x-auto",
|
|
240
|
+
children: /* @__PURE__ */ P("table", {
|
|
241
|
+
className: "w-full text-xs tabular-nums",
|
|
242
|
+
children: [/* @__PURE__ */ N("thead", { children: /* @__PURE__ */ P("tr", {
|
|
243
|
+
className: "text-left text-text-secondary",
|
|
244
|
+
children: [
|
|
245
|
+
/* @__PURE__ */ N("th", {
|
|
246
|
+
className: "py-1 pr-2 font-medium",
|
|
247
|
+
children: o("bigconsole.reconcile.key", "Key")
|
|
248
|
+
}),
|
|
249
|
+
/* @__PURE__ */ N("th", {
|
|
250
|
+
className: "py-1 pr-2 font-medium",
|
|
251
|
+
children: o("bigconsole.reconcile.match", "Match")
|
|
252
|
+
}),
|
|
253
|
+
/* @__PURE__ */ N("th", {
|
|
254
|
+
className: "py-1 pr-2 text-right font-medium",
|
|
255
|
+
children: r
|
|
256
|
+
}),
|
|
257
|
+
/* @__PURE__ */ N("th", {
|
|
258
|
+
className: "py-1 pr-2 text-right font-medium",
|
|
259
|
+
children: a
|
|
260
|
+
}),
|
|
261
|
+
/* @__PURE__ */ N("th", {
|
|
262
|
+
className: "py-1 pr-2 text-right font-medium",
|
|
263
|
+
children: o("bigconsole.reconcile.contribution", "Contribution")
|
|
264
|
+
}),
|
|
265
|
+
/* @__PURE__ */ N("th", {
|
|
266
|
+
className: "py-1 font-medium",
|
|
267
|
+
children: o("bigconsole.reconcile.evidence", "Evidence")
|
|
268
|
+
})
|
|
269
|
+
]
|
|
270
|
+
}) }), /* @__PURE__ */ N("tbody", { children: O.map((e) => /* @__PURE__ */ P("tr", {
|
|
271
|
+
className: "border-t border-[var(--color-border-subtle)] align-top",
|
|
272
|
+
"data-testid": "reconcile-item",
|
|
273
|
+
children: [
|
|
274
|
+
/* @__PURE__ */ N("td", {
|
|
275
|
+
className: "py-1 pr-2 font-medium text-text-primary",
|
|
276
|
+
children: e.key ?? o("bigconsole.reconcile.noKey", "(no key)")
|
|
277
|
+
}),
|
|
278
|
+
/* @__PURE__ */ P("td", {
|
|
279
|
+
className: "py-1 pr-2 text-text-secondary",
|
|
280
|
+
children: [e.statusLabel, e.leftCount > 1 || e.rightCount > 1 ? ` (${e.leftCount}/${e.rightCount})` : ""]
|
|
281
|
+
}),
|
|
282
|
+
/* @__PURE__ */ N("td", {
|
|
283
|
+
className: "py-1 pr-2 text-right",
|
|
284
|
+
children: e.leftAmount?.display ?? "—"
|
|
285
|
+
}),
|
|
286
|
+
/* @__PURE__ */ N("td", {
|
|
287
|
+
className: "py-1 pr-2 text-right",
|
|
288
|
+
children: e.rightAmount?.display ?? "—"
|
|
289
|
+
}),
|
|
290
|
+
/* @__PURE__ */ N("td", {
|
|
291
|
+
className: `py-1 pr-2 text-right font-medium ${H(e.contribution.amount)}`,
|
|
292
|
+
children: e.contribution.display
|
|
293
|
+
}),
|
|
294
|
+
/* @__PURE__ */ N("td", {
|
|
295
|
+
className: "py-1 text-text-secondary",
|
|
296
|
+
children: e.evidence ?? e.note ?? "—"
|
|
297
|
+
})
|
|
298
|
+
]
|
|
299
|
+
}, e.id)) })]
|
|
300
|
+
})
|
|
301
|
+
}) : null,
|
|
302
|
+
C ? /* @__PURE__ */ N(T, {
|
|
303
|
+
className: "size-4 animate-spin text-text-secondary",
|
|
304
|
+
"aria-label": "Loading"
|
|
305
|
+
}) : null,
|
|
306
|
+
D?.hasMore && !C ? /* @__PURE__ */ N(A, {
|
|
307
|
+
variant: "outline",
|
|
308
|
+
size: "sm",
|
|
309
|
+
onClick: () => void E(O.length),
|
|
310
|
+
"data-testid": "reconcile-items-more",
|
|
311
|
+
children: o("bigconsole.reconcile.more", "Show more ({{shown}} of {{total}})", {
|
|
312
|
+
shown: O.length,
|
|
313
|
+
total: D.totalCount
|
|
314
|
+
})
|
|
315
|
+
}) : null
|
|
316
|
+
]
|
|
317
|
+
});
|
|
318
|
+
}), ce = _(function({ result: e, input: t, onAsk: n }) {
|
|
319
|
+
let { t: r } = j(), [i, o] = S(null);
|
|
320
|
+
if (e.status !== "OK" || !e.left || !e.right) return /* @__PURE__ */ N(a, {
|
|
321
|
+
headingLevel: 3,
|
|
322
|
+
tone: "danger",
|
|
323
|
+
padding: "compact",
|
|
324
|
+
icon: e.status === "RESTRICTED" ? /* @__PURE__ */ N(O, { className: "size-4" }) : /* @__PURE__ */ N(k, { className: "size-4" }),
|
|
325
|
+
title: e.status === "RESTRICTED" ? r("bigconsole.reconcile.restrictedTitle", "You cannot reconcile these cards") : r("bigconsole.reconcile.unsupportedTitle", "These cards cannot be reconciled yet"),
|
|
326
|
+
"data-testid": "reconcile-problems",
|
|
327
|
+
children: /* @__PURE__ */ N("ul", {
|
|
328
|
+
className: "list-disc space-y-1 pl-5 text-sm text-text-primary",
|
|
329
|
+
children: e.problems.map((e, t) => /* @__PURE__ */ N("li", {
|
|
330
|
+
"data-problem-code": e.code,
|
|
331
|
+
children: e.message
|
|
332
|
+
}, `${e.code}-${t}`))
|
|
333
|
+
})
|
|
334
|
+
});
|
|
335
|
+
let s = e.left, c = e.right;
|
|
336
|
+
return /* @__PURE__ */ P("div", {
|
|
337
|
+
className: "space-y-4",
|
|
338
|
+
"data-testid": "reconcile-result",
|
|
339
|
+
children: [
|
|
340
|
+
/* @__PURE__ */ N("div", {
|
|
341
|
+
style: R,
|
|
342
|
+
children: [s, c].map((e, t) => /* @__PURE__ */ P("div", {
|
|
343
|
+
className: "rounded-md border border-[var(--color-border-subtle)] p-3",
|
|
344
|
+
"data-testid": `reconcile-total-${t === 0 ? "left" : "right"}`,
|
|
345
|
+
children: [
|
|
346
|
+
/* @__PURE__ */ P("div", {
|
|
347
|
+
className: "text-xs text-text-secondary",
|
|
348
|
+
children: [
|
|
349
|
+
e.dashboardName,
|
|
350
|
+
" · ",
|
|
351
|
+
e.dateField
|
|
352
|
+
]
|
|
353
|
+
}),
|
|
354
|
+
/* @__PURE__ */ N("div", {
|
|
355
|
+
className: "text-sm font-medium text-text-primary",
|
|
356
|
+
children: e.title
|
|
357
|
+
}),
|
|
358
|
+
/* @__PURE__ */ N("div", {
|
|
359
|
+
className: "text-lg font-semibold tabular-nums text-text-primary",
|
|
360
|
+
children: e.total.display
|
|
361
|
+
}),
|
|
362
|
+
/* @__PURE__ */ P("div", {
|
|
363
|
+
className: "flex items-center gap-1 text-xs text-text-secondary",
|
|
364
|
+
children: [
|
|
365
|
+
e.tieOut.ties ? /* @__PURE__ */ N(w, {
|
|
366
|
+
className: "size-3 text-status-success-text",
|
|
367
|
+
"aria-hidden": "true"
|
|
368
|
+
}) : /* @__PURE__ */ N(k, {
|
|
369
|
+
className: "size-3 text-status-error-text",
|
|
370
|
+
"aria-hidden": "true"
|
|
371
|
+
}),
|
|
372
|
+
e.tieOut.scope === "PERIOD" ? r("bigconsole.reconcile.tiesPeriod", "Ties to the card ({{value}})", { value: e.tieOut.cardValue ?? "" }) : r("bigconsole.reconcile.tiesAll", "Card shows {{value}} for all its records", { value: e.tieOut.cardValue ?? "" }),
|
|
373
|
+
" · ",
|
|
374
|
+
r("bigconsole.reconcile.records", "{{count}} records", { count: e.recordCount })
|
|
375
|
+
]
|
|
376
|
+
})
|
|
377
|
+
]
|
|
378
|
+
}, e.widgetId))
|
|
379
|
+
}),
|
|
380
|
+
/* @__PURE__ */ P("div", {
|
|
381
|
+
className: "rounded-md bg-bg-sunken p-3",
|
|
382
|
+
children: [/* @__PURE__ */ P("div", {
|
|
383
|
+
className: "text-xs text-text-secondary",
|
|
384
|
+
children: [
|
|
385
|
+
e.direction,
|
|
386
|
+
" · ",
|
|
387
|
+
e.period.start,
|
|
388
|
+
" – ",
|
|
389
|
+
e.period.end,
|
|
390
|
+
" (",
|
|
391
|
+
e.period.timezone,
|
|
392
|
+
") ·",
|
|
393
|
+
" ",
|
|
394
|
+
e.currency
|
|
395
|
+
]
|
|
396
|
+
}), /* @__PURE__ */ N("div", {
|
|
397
|
+
className: `text-xl font-semibold tabular-nums ${H(e.gap?.amount)}`,
|
|
398
|
+
"data-testid": "reconcile-gap",
|
|
399
|
+
children: e.gap?.display
|
|
400
|
+
})]
|
|
401
|
+
}),
|
|
402
|
+
/* @__PURE__ */ N("div", {
|
|
403
|
+
className: "space-y-2",
|
|
404
|
+
children: e.groups.map((e) => {
|
|
405
|
+
let n = i === e.group;
|
|
406
|
+
return /* @__PURE__ */ P("div", {
|
|
407
|
+
className: "rounded-md border border-[var(--color-border-subtle)]",
|
|
408
|
+
children: [/* @__PURE__ */ P("button", {
|
|
409
|
+
type: "button",
|
|
410
|
+
className: "flex w-full items-center justify-between gap-2 px-3 py-2 text-left text-sm hover:bg-bg-sunken",
|
|
411
|
+
"aria-expanded": n,
|
|
412
|
+
onClick: () => o(n ? null : e.group),
|
|
413
|
+
"data-testid": `reconcile-group-${e.group}`,
|
|
414
|
+
children: [/* @__PURE__ */ P("span", {
|
|
415
|
+
className: "font-medium text-text-primary",
|
|
416
|
+
children: [e.label, /* @__PURE__ */ N("span", {
|
|
417
|
+
className: "ml-2 text-xs font-normal text-text-secondary",
|
|
418
|
+
children: e.itemCount === 1 ? r("bigconsole.reconcile.itemCountOne", "1 key") : r("bigconsole.reconcile.itemCount", "{{count}} keys", { count: e.itemCount })
|
|
419
|
+
})]
|
|
420
|
+
}), /* @__PURE__ */ N("span", {
|
|
421
|
+
className: `tabular-nums font-semibold ${H(e.total.amount)}`,
|
|
422
|
+
children: e.total.display
|
|
423
|
+
})]
|
|
424
|
+
}), n ? /* @__PURE__ */ N("div", {
|
|
425
|
+
className: "border-t border-[var(--color-border-subtle)] p-3",
|
|
426
|
+
children: /* @__PURE__ */ N(W, {
|
|
427
|
+
input: t,
|
|
428
|
+
group: e.group,
|
|
429
|
+
leftTitle: s.title,
|
|
430
|
+
rightTitle: c.title
|
|
431
|
+
}, `${e.group}:${JSON.stringify(t)}`)
|
|
432
|
+
}) : null]
|
|
433
|
+
}, e.group);
|
|
434
|
+
})
|
|
435
|
+
}),
|
|
436
|
+
/* @__PURE__ */ P(a, {
|
|
437
|
+
headingLevel: 3,
|
|
438
|
+
padding: "compact",
|
|
439
|
+
title: r("bigconsole.reconcile.explanation", "Explanation"),
|
|
440
|
+
children: [/* @__PURE__ */ N("p", {
|
|
441
|
+
className: "text-sm text-text-primary",
|
|
442
|
+
"data-testid": "reconcile-explanation",
|
|
443
|
+
children: e.explanation
|
|
444
|
+
}), e.limitations.length > 0 ? /* @__PURE__ */ N("ul", {
|
|
445
|
+
className: "mt-2 list-disc space-y-1 pl-5 text-xs text-text-secondary",
|
|
446
|
+
"data-testid": "reconcile-limitations",
|
|
447
|
+
children: e.limitations.map((e) => /* @__PURE__ */ N("li", { children: e }, e))
|
|
448
|
+
}) : null]
|
|
449
|
+
}),
|
|
450
|
+
/* @__PURE__ */ P(A, {
|
|
451
|
+
variant: "outline",
|
|
452
|
+
onClick: n,
|
|
453
|
+
"data-testid": "reconcile-ask-assistant",
|
|
454
|
+
children: [/* @__PURE__ */ N(E, {
|
|
455
|
+
className: "size-4",
|
|
456
|
+
"aria-hidden": "true"
|
|
457
|
+
}), r("bigconsole.reconcile.ask", "Ask the assistant about this difference")]
|
|
458
|
+
})
|
|
459
|
+
]
|
|
460
|
+
});
|
|
461
|
+
}), G = _(function({ open: t, onClose: n, widget: a }) {
|
|
462
|
+
let { t: o } = j(), _ = ae(), { workspaceId: y } = i(), w = u(a.config), [E, O] = S(() => ({
|
|
463
|
+
left: V(a.id, a.title, w),
|
|
464
|
+
right: V("", "", w),
|
|
465
|
+
month: p(/* @__PURE__ */ new Date()),
|
|
466
|
+
timezone: c(),
|
|
467
|
+
cutoffWindowDays: 0
|
|
468
|
+
})), [k, F] = S(""), [H, W] = S(!1), [G, K] = S(null), [q, J] = S(null), le = x(null), Y = M(e, {
|
|
469
|
+
variables: {
|
|
470
|
+
search: k.trim() || null,
|
|
471
|
+
first: 50
|
|
472
|
+
},
|
|
473
|
+
skip: !t,
|
|
474
|
+
fetchPolicy: "cache-and-network",
|
|
475
|
+
context: z(y)
|
|
476
|
+
}), X = (Y.data?.kpiReconcilableCards ?? []).filter((e) => e.widgetId !== a.id), ue = v((e) => {
|
|
477
|
+
let t = X.find((t) => t.widgetId === e);
|
|
478
|
+
if (!t) return;
|
|
479
|
+
let n = B();
|
|
480
|
+
O((r) => {
|
|
481
|
+
let i = r.left.widgetId === a.id, o = i ? r.left : r.right, s = d(o.widgetId, e, n), c = d(e, o.widgetId, n), l = c ? m(c.side, t.title) : V(t.widgetId, t.title, o.currency || w), u = s ? m(s.side, o.title) : o, f = s?.cutoffWindowDays ?? r.cutoffWindowDays;
|
|
482
|
+
return i ? {
|
|
483
|
+
...r,
|
|
484
|
+
left: u,
|
|
485
|
+
right: l,
|
|
486
|
+
cutoffWindowDays: f
|
|
487
|
+
} : {
|
|
488
|
+
...r,
|
|
489
|
+
left: l,
|
|
490
|
+
right: u,
|
|
491
|
+
cutoffWindowDays: f
|
|
492
|
+
};
|
|
493
|
+
}), J(null);
|
|
494
|
+
}, [
|
|
495
|
+
X,
|
|
496
|
+
a.id,
|
|
497
|
+
w
|
|
498
|
+
]), Z = v((e) => (t) => {
|
|
499
|
+
O((n) => ({
|
|
500
|
+
...n,
|
|
501
|
+
[e]: t
|
|
502
|
+
})), J(null);
|
|
503
|
+
}, []), de = b(() => Z("left"), [Z]), fe = b(() => Z("right"), [Z]), Q = f(E), $ = v(async (e) => {
|
|
504
|
+
let t = l(e);
|
|
505
|
+
if (t) {
|
|
506
|
+
W(!0), K(null);
|
|
507
|
+
try {
|
|
508
|
+
let n = (await _.query({
|
|
509
|
+
query: r,
|
|
510
|
+
variables: { input: t },
|
|
511
|
+
fetchPolicy: "network-only",
|
|
512
|
+
context: z(y)
|
|
513
|
+
})).data?.reconcileKpiCards;
|
|
514
|
+
if (!n) throw Error("The comparison returned no result.");
|
|
515
|
+
J({
|
|
516
|
+
data: n,
|
|
517
|
+
input: t
|
|
518
|
+
}), n.status === "OK" && h(e, B());
|
|
519
|
+
} catch (e) {
|
|
520
|
+
J(null), K(e instanceof Error ? e.message : "The comparison failed. Please try again.");
|
|
521
|
+
} finally {
|
|
522
|
+
W(!1);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}, [_, y]), pe = v(() => {
|
|
526
|
+
let e = g(E);
|
|
527
|
+
O(e), q && $(e);
|
|
528
|
+
}, [
|
|
529
|
+
E,
|
|
530
|
+
q,
|
|
531
|
+
$
|
|
532
|
+
]), me = v(() => {
|
|
533
|
+
if (!q) return;
|
|
534
|
+
let e = s(q.input, {
|
|
535
|
+
left: q.data.left?.title ?? E.left.title,
|
|
536
|
+
right: q.data.right?.title ?? E.right.title
|
|
537
|
+
}, q.data.gap?.display ?? null);
|
|
538
|
+
se(e, le.current) || K(o("bigconsole.reconcile.noAssistant", "The assistant is not available on this page."));
|
|
539
|
+
}, [
|
|
540
|
+
q,
|
|
541
|
+
E.left.title,
|
|
542
|
+
E.right.title,
|
|
543
|
+
o
|
|
544
|
+
]);
|
|
545
|
+
return /* @__PURE__ */ N(ee, {
|
|
546
|
+
open: t,
|
|
547
|
+
onOpenChange: (e) => !e && !H && n(),
|
|
548
|
+
children: /* @__PURE__ */ P(te, {
|
|
549
|
+
className: "sm:max-w-3xl flex max-h-[calc(100dvh-3rem)] flex-col overflow-hidden",
|
|
550
|
+
"data-testid": "reconcile-dialog",
|
|
551
|
+
children: [/* @__PURE__ */ P(re, {
|
|
552
|
+
className: "shrink-0",
|
|
553
|
+
children: [/* @__PURE__ */ N(ie, { children: o("bigconsole.reconcile.title", "Reconcile “{{title}}”", { title: a.title }) }), /* @__PURE__ */ N(ne, { children: o("bigconsole.reconcile.description", "Compare this card with another card for one month, match records on a shared key, and see which records explain the difference. Neither dashboard is changed.") })]
|
|
554
|
+
}), /* @__PURE__ */ P("div", {
|
|
555
|
+
ref: le,
|
|
556
|
+
className: "min-h-0 flex-1 space-y-4 overflow-y-auto py-4",
|
|
557
|
+
children: [
|
|
558
|
+
/* @__PURE__ */ P("div", {
|
|
559
|
+
style: R,
|
|
560
|
+
children: [
|
|
561
|
+
/* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("label", {
|
|
562
|
+
htmlFor: "reconcile-card-search",
|
|
563
|
+
style: L,
|
|
564
|
+
children: o("bigconsole.reconcile.findCard", "Find a card")
|
|
565
|
+
}), /* @__PURE__ */ N("input", {
|
|
566
|
+
id: "reconcile-card-search",
|
|
567
|
+
value: k,
|
|
568
|
+
onChange: (e) => F(e.target.value),
|
|
569
|
+
placeholder: o("bigconsole.reconcile.searchPlaceholder", "Card title"),
|
|
570
|
+
style: I
|
|
571
|
+
})] }),
|
|
572
|
+
/* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("label", {
|
|
573
|
+
htmlFor: "reconcile-card",
|
|
574
|
+
style: L,
|
|
575
|
+
children: o("bigconsole.reconcile.compareWith", "Compare with")
|
|
576
|
+
}), /* @__PURE__ */ P("select", {
|
|
577
|
+
id: "reconcile-card",
|
|
578
|
+
value: E.left.widgetId === a.id ? E.right.widgetId : E.left.widgetId,
|
|
579
|
+
onChange: (e) => ue(e.target.value),
|
|
580
|
+
disabled: H,
|
|
581
|
+
style: I,
|
|
582
|
+
"data-testid": "reconcile-card-select",
|
|
583
|
+
children: [/* @__PURE__ */ N("option", {
|
|
584
|
+
value: "",
|
|
585
|
+
children: Y.loading && !Y.data ? o("bigconsole.reconcile.loadingCards", "Loading cards…") : o("bigconsole.reconcile.choose", "Choose…")
|
|
586
|
+
}), X.map((e) => /* @__PURE__ */ P("option", {
|
|
587
|
+
value: e.widgetId,
|
|
588
|
+
children: [
|
|
589
|
+
e.title,
|
|
590
|
+
" — ",
|
|
591
|
+
e.dashboardName,
|
|
592
|
+
" / ",
|
|
593
|
+
e.pageName
|
|
594
|
+
]
|
|
595
|
+
}, e.widgetId))]
|
|
596
|
+
})] }),
|
|
597
|
+
/* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("label", {
|
|
598
|
+
htmlFor: "reconcile-month",
|
|
599
|
+
style: L,
|
|
600
|
+
children: o("bigconsole.reconcile.month", "Month")
|
|
601
|
+
}), /* @__PURE__ */ N("input", {
|
|
602
|
+
id: "reconcile-month",
|
|
603
|
+
type: "month",
|
|
604
|
+
value: E.month,
|
|
605
|
+
onChange: (e) => {
|
|
606
|
+
O((t) => ({
|
|
607
|
+
...t,
|
|
608
|
+
month: e.target.value
|
|
609
|
+
})), J(null);
|
|
610
|
+
},
|
|
611
|
+
disabled: H,
|
|
612
|
+
style: I,
|
|
613
|
+
"data-testid": "reconcile-month"
|
|
614
|
+
})] }),
|
|
615
|
+
/* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("label", {
|
|
616
|
+
htmlFor: "reconcile-timezone",
|
|
617
|
+
style: L,
|
|
618
|
+
children: o("bigconsole.reconcile.timezone", "Timezone")
|
|
619
|
+
}), /* @__PURE__ */ N("input", {
|
|
620
|
+
id: "reconcile-timezone",
|
|
621
|
+
value: E.timezone,
|
|
622
|
+
onChange: (e) => {
|
|
623
|
+
O((t) => ({
|
|
624
|
+
...t,
|
|
625
|
+
timezone: e.target.value
|
|
626
|
+
})), J(null);
|
|
627
|
+
},
|
|
628
|
+
disabled: H,
|
|
629
|
+
style: I,
|
|
630
|
+
"data-testid": "reconcile-timezone"
|
|
631
|
+
})] }),
|
|
632
|
+
/* @__PURE__ */ P("div", { children: [/* @__PURE__ */ N("label", {
|
|
633
|
+
htmlFor: "reconcile-cutoff",
|
|
634
|
+
style: L,
|
|
635
|
+
children: o("bigconsole.reconcile.cutoff", "Cutoff rule window (days, 0 = off)")
|
|
636
|
+
}), /* @__PURE__ */ N("input", {
|
|
637
|
+
id: "reconcile-cutoff",
|
|
638
|
+
type: "number",
|
|
639
|
+
min: 0,
|
|
640
|
+
max: 31,
|
|
641
|
+
value: E.cutoffWindowDays,
|
|
642
|
+
onChange: (e) => {
|
|
643
|
+
O((t) => ({
|
|
644
|
+
...t,
|
|
645
|
+
cutoffWindowDays: Number(e.target.value) || 0
|
|
646
|
+
})), J(null);
|
|
647
|
+
},
|
|
648
|
+
disabled: H,
|
|
649
|
+
style: I,
|
|
650
|
+
"data-testid": "reconcile-cutoff"
|
|
651
|
+
})] })
|
|
652
|
+
]
|
|
653
|
+
}),
|
|
654
|
+
E.left.widgetId && E.right.widgetId ? /* @__PURE__ */ P(oe, { children: [
|
|
655
|
+
/* @__PURE__ */ P("div", {
|
|
656
|
+
className: "flex items-center justify-between gap-2",
|
|
657
|
+
children: [/* @__PURE__ */ N("p", {
|
|
658
|
+
className: "text-sm text-text-secondary",
|
|
659
|
+
"data-testid": "reconcile-direction",
|
|
660
|
+
children: o("bigconsole.reconcile.directionHint", "Gap = {{left}} − {{right}}", {
|
|
661
|
+
left: E.left.title,
|
|
662
|
+
right: E.right.title
|
|
663
|
+
})
|
|
664
|
+
}), /* @__PURE__ */ P(A, {
|
|
665
|
+
variant: "outline",
|
|
666
|
+
size: "sm",
|
|
667
|
+
onClick: pe,
|
|
668
|
+
disabled: H,
|
|
669
|
+
"data-testid": "reconcile-swap",
|
|
670
|
+
children: [/* @__PURE__ */ N(C, {
|
|
671
|
+
className: "size-4",
|
|
672
|
+
"aria-hidden": "true"
|
|
673
|
+
}), o("bigconsole.reconcile.swap", "Swap")]
|
|
674
|
+
})]
|
|
675
|
+
}),
|
|
676
|
+
/* @__PURE__ */ N(U, {
|
|
677
|
+
side: E.left,
|
|
678
|
+
role: "left",
|
|
679
|
+
disabled: H,
|
|
680
|
+
onChange: de
|
|
681
|
+
}, `l-${E.left.widgetId}`),
|
|
682
|
+
/* @__PURE__ */ N(U, {
|
|
683
|
+
side: E.right,
|
|
684
|
+
role: "right",
|
|
685
|
+
disabled: H,
|
|
686
|
+
onChange: fe
|
|
687
|
+
}, `r-${E.right.widgetId}`)
|
|
688
|
+
] }) : null,
|
|
689
|
+
/* @__PURE__ */ P("div", {
|
|
690
|
+
className: "flex items-center gap-3",
|
|
691
|
+
children: [/* @__PURE__ */ P(A, {
|
|
692
|
+
onClick: () => void $(E),
|
|
693
|
+
disabled: H || !!Q,
|
|
694
|
+
"data-testid": "reconcile-run",
|
|
695
|
+
children: [H ? /* @__PURE__ */ N(T, {
|
|
696
|
+
className: "size-4 animate-spin",
|
|
697
|
+
"aria-hidden": "true"
|
|
698
|
+
}) : /* @__PURE__ */ N(D, {
|
|
699
|
+
className: "size-4",
|
|
700
|
+
"aria-hidden": "true"
|
|
701
|
+
}), o("bigconsole.reconcile.run", "Reconcile")]
|
|
702
|
+
}), Q && !H ? /* @__PURE__ */ N("span", {
|
|
703
|
+
className: "text-xs text-text-secondary",
|
|
704
|
+
children: Q
|
|
705
|
+
}) : null]
|
|
706
|
+
}),
|
|
707
|
+
G ? /* @__PURE__ */ N("p", {
|
|
708
|
+
className: "text-sm text-status-error-text",
|
|
709
|
+
role: "alert",
|
|
710
|
+
"data-testid": "reconcile-error",
|
|
711
|
+
children: G
|
|
712
|
+
}) : null,
|
|
713
|
+
q ? /* @__PURE__ */ N(ce, {
|
|
714
|
+
result: q.data,
|
|
715
|
+
input: q.input,
|
|
716
|
+
onAsk: me
|
|
717
|
+
}) : null
|
|
718
|
+
]
|
|
719
|
+
})]
|
|
720
|
+
})
|
|
721
|
+
});
|
|
722
|
+
});
|
|
723
|
+
export { G as KpiReconcileDialog, G as default, ce as ResultView, U as SideMapping };
|