@nivaro/react 0.3.75 → 0.3.76
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.
|
@@ -4,26 +4,26 @@ import { useMemo as A } from "react";
|
|
|
4
4
|
import { get as L } from "../../lib/commands.js";
|
|
5
5
|
import { cn as l, formatDate as R, titleCase as U } from "../../lib/utils.js";
|
|
6
6
|
import { diffAddendumLines as B } from "./AddendumLinesDiff.js";
|
|
7
|
-
const
|
|
7
|
+
const p = new Intl.NumberFormat("en-US", { style: "currency", currency: "USD" }), J = (m) => m == null || m === "";
|
|
8
8
|
function H({
|
|
9
9
|
client: m,
|
|
10
|
-
addendums:
|
|
11
|
-
parentCollection:
|
|
12
|
-
parentId:
|
|
13
|
-
relations:
|
|
10
|
+
addendums: y,
|
|
11
|
+
parentCollection: N,
|
|
12
|
+
parentId: _,
|
|
13
|
+
relations: v,
|
|
14
14
|
fieldMap: j
|
|
15
15
|
}) {
|
|
16
16
|
const x = A(
|
|
17
|
-
() => [...
|
|
18
|
-
[
|
|
19
|
-
),
|
|
17
|
+
() => [...y].sort((e, a) => String(e.created_at).localeCompare(String(a.created_at))),
|
|
18
|
+
[y]
|
|
19
|
+
), b = A(() => {
|
|
20
20
|
const e = /* @__PURE__ */ new Set();
|
|
21
21
|
for (const a of x)
|
|
22
22
|
for (const [t, d] of Object.entries(a.data ?? {})) Array.isArray(d) && e.add(t);
|
|
23
23
|
return [...e].map((a) => ({
|
|
24
24
|
field: a,
|
|
25
|
-
rel:
|
|
26
|
-
(t) => t.one_collection ===
|
|
25
|
+
rel: v.find(
|
|
26
|
+
(t) => t.one_collection === N && !t.junction_field && (t.one_field === a || t.many_collection === a)
|
|
27
27
|
)
|
|
28
28
|
})).filter(
|
|
29
29
|
(a) => {
|
|
@@ -31,19 +31,19 @@ function H({
|
|
|
31
31
|
return !!((t = a.rel) != null && t.many_collection) && !!a.rel.many_field;
|
|
32
32
|
}
|
|
33
33
|
);
|
|
34
|
-
}, [x,
|
|
35
|
-
queries:
|
|
36
|
-
queryKey: ["o2m-rows", e.many_collection, e.many_field,
|
|
34
|
+
}, [x, v, N]), S = K({
|
|
35
|
+
queries: b.map(({ rel: e }) => ({
|
|
36
|
+
queryKey: ["o2m-rows", e.many_collection, e.many_field, _],
|
|
37
37
|
queryFn: () => m.request(
|
|
38
38
|
L(`/items/${e.many_collection}`, {
|
|
39
|
-
filter: JSON.stringify({ [e.many_field]: { _eq:
|
|
39
|
+
filter: JSON.stringify({ [e.many_field]: { _eq: _ } }),
|
|
40
40
|
limit: 200
|
|
41
41
|
})
|
|
42
42
|
).then((a) => a.data ?? []),
|
|
43
43
|
staleTime: 3e4
|
|
44
44
|
}))
|
|
45
45
|
}), q = Object.fromEntries(
|
|
46
|
-
|
|
46
|
+
b.map((e, a) => {
|
|
47
47
|
var t;
|
|
48
48
|
return [e.field, ((t = S[a]) == null ? void 0 : t.data) ?? null];
|
|
49
49
|
})
|
|
@@ -53,20 +53,20 @@ function H({
|
|
|
53
53
|
}, F = (e) => Object.entries(e.data ?? {}).filter(([a, t]) => !a.startsWith("__") && !Array.isArray(t) && !J(t)).map(([a]) => a), M = (e) => typeof e.cost_impact == "number" ? e.cost_impact : typeof e.new_amount == "number" && typeof e.previous_amount == "number" ? e.new_amount - e.previous_amount : null, O = (e) => {
|
|
54
54
|
var s;
|
|
55
55
|
let a = 0, t = 0, d = 0, o = !1;
|
|
56
|
-
for (const { field:
|
|
57
|
-
const k = (s = e.data) == null ? void 0 : s[
|
|
56
|
+
for (const { field: u, rel: E } of b) {
|
|
57
|
+
const k = (s = e.data) == null ? void 0 : s[u], w = q[u];
|
|
58
58
|
if (!Array.isArray(k) || !w) continue;
|
|
59
59
|
o = !0;
|
|
60
|
-
const
|
|
60
|
+
const g = B(
|
|
61
61
|
k,
|
|
62
62
|
w,
|
|
63
63
|
E.many_field
|
|
64
64
|
);
|
|
65
|
-
a +=
|
|
65
|
+
a += g.added.length, t += g.changed.length, d += g.removed.length;
|
|
66
66
|
}
|
|
67
67
|
return o ? { added: a, changed: t, removed: d } : null;
|
|
68
68
|
}, D = (e) => e === "approved" ? "bg-emerald-50 text-emerald-700 dark:bg-emerald-500/10 dark:text-emerald-400" : e === "rejected" || e === "reverted" ? "bg-red-50 text-red-600 dark:bg-red-500/10 dark:text-red-400" : "bg-amber-50 text-amber-700 dark:bg-amber-500/10 dark:text-amber-300";
|
|
69
|
-
let
|
|
69
|
+
let h = 0, f = 0;
|
|
70
70
|
const i = "px-2 py-1.5 text-left text-[10px] font-semibold uppercase tracking-wide text-slate-400 dark:text-slate-500", c = "px-2 py-1.5 align-top text-[11.5px]";
|
|
71
71
|
return /* @__PURE__ */ r("div", { className: "overflow-x-auto", children: /* @__PURE__ */ n("table", { className: "w-full min-w-[640px] border-collapse", children: [
|
|
72
72
|
/* @__PURE__ */ r("thead", { className: "border-b border-slate-200 dark:border-border", children: /* @__PURE__ */ n("tr", { children: [
|
|
@@ -85,8 +85,9 @@ function H({
|
|
|
85
85
|
)
|
|
86
86
|
] }) }),
|
|
87
87
|
/* @__PURE__ */ r("tbody", { children: x.map((e, a) => {
|
|
88
|
+
var u;
|
|
88
89
|
const t = M(e), d = e.status !== "rejected" && e.status !== "reverted";
|
|
89
|
-
t != null && d && (
|
|
90
|
+
t != null && d && (h += t), t != null && e.status === "approved" && (f += t);
|
|
90
91
|
const o = F(e), s = O(e);
|
|
91
92
|
return /* @__PURE__ */ n("tr", { className: "border-b border-slate-100 last:border-0 dark:border-border", children: [
|
|
92
93
|
/* @__PURE__ */ n("td", { className: c, children: [
|
|
@@ -106,7 +107,7 @@ function H({
|
|
|
106
107
|
"rounded-full px-1.5 py-px text-[10px] font-medium",
|
|
107
108
|
D(e.status)
|
|
108
109
|
),
|
|
109
|
-
children: e.status
|
|
110
|
+
children: ((u = e.workflow_state) == null ? void 0 : u.label) ?? e.status
|
|
110
111
|
}
|
|
111
112
|
) }),
|
|
112
113
|
/* @__PURE__ */ n("td", { className: l(c, "text-right tabular-nums"), children: [
|
|
@@ -119,14 +120,14 @@ function H({
|
|
|
119
120
|
),
|
|
120
121
|
children: [
|
|
121
122
|
t > 0 ? "+" : t < 0 ? "−" : "",
|
|
122
|
-
|
|
123
|
+
p.format(Math.abs(t))
|
|
123
124
|
]
|
|
124
125
|
}
|
|
125
126
|
),
|
|
126
127
|
typeof e.previous_amount == "number" && typeof e.new_amount == "number" && /* @__PURE__ */ n("div", { className: "text-[10.5px] text-slate-500", children: [
|
|
127
|
-
|
|
128
|
+
p.format(e.previous_amount),
|
|
128
129
|
" → ",
|
|
129
|
-
|
|
130
|
+
p.format(e.new_amount)
|
|
130
131
|
] })
|
|
131
132
|
] }),
|
|
132
133
|
/* @__PURE__ */ r("td", { className: c, children: o.length === 0 ? /* @__PURE__ */ r("span", { className: "text-slate-400", children: "none" }) : /* @__PURE__ */ n("span", { className: "text-slate-700 dark:text-slate-300", children: [
|
|
@@ -159,15 +160,15 @@ function H({
|
|
|
159
160
|
d ? "text-foreground" : "text-slate-400 line-through"
|
|
160
161
|
),
|
|
161
162
|
children: [
|
|
162
|
-
|
|
163
|
-
|
|
163
|
+
h > 0 ? "+" : h < 0 ? "−" : "",
|
|
164
|
+
p.format(Math.abs(h))
|
|
164
165
|
]
|
|
165
166
|
}
|
|
166
167
|
),
|
|
167
168
|
/* @__PURE__ */ n("div", { className: "text-[10.5px] text-slate-500", children: [
|
|
168
169
|
"approved ",
|
|
169
|
-
|
|
170
|
-
|
|
170
|
+
f > 0 ? "+" : f < 0 ? "−" : "",
|
|
171
|
+
p.format(Math.abs(f))
|
|
171
172
|
] })
|
|
172
173
|
] })
|
|
173
174
|
] }, e.id);
|