@nivaro/react 0.3.67 → 0.3.68
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/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.js +836 -835
- package/dist/shared/components/ConformanceView.js +34 -34
- package/dist/shared/components/ReportView.js +196 -196
- package/dist/shared/components/SlaRulesView.js +36 -36
- package/dist/shared/components/chat/ChatPanel.js +484 -487
- package/dist/shared/components/chat/ChatViews.js +66 -66
- package/dist/shared/components/chat/RoomParts.js +159 -157
- package/dist/shared/components/help-videos/editor/StatsTab.js +48 -47
- package/dist/shared/components/help-videos/editor/VersionsTab.js +17 -16
- package/dist/shared/components/imports/CollectionImportPanel.js +72 -72
- package/dist/shared/components/item-edit/FieldRow.js +87 -87
- package/dist/shared/components/item-edit/FilePickerField.js +281 -297
- package/dist/shared/components/item-edit/RecordInsights.js +90 -91
- package/dist/shared/components/item-edit/SummaryPanel.js +31 -31
- package/dist/shared/components/layout-editor/assist/ExplainDiff.js +12 -12
- package/dist/shared/components/panels/AddendumPanel.js +409 -411
- package/dist/shared/components/panels/CommentPanel.js +169 -162
- package/dist/shared/components/panels/PipelinePanel.js +75 -75
- package/dist/shared/components/panels/RevisionsPanel.js +103 -103
- package/dist/shared/components/queue/QueueWorklist.js +142 -141
- package/dist/shared/lib/format-value.js +15 -15
- package/dist/shared/lib/utils.js +58 -53
- package/package.json +1 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { jsxs as i, Fragment as Ne, jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import { useQueryClient as
|
|
3
|
-
import { FileDiff as Ze, ChevronDown as et, Paperclip as
|
|
4
|
-
import { useState as
|
|
2
|
+
import { useQueryClient as Ue, useQuery as V, useQueries as Te, useMutation as pe } from "@tanstack/react-query";
|
|
3
|
+
import { FileDiff as Ze, ChevronDown as et, Paperclip as Qe, Loader2 as tt, Upload as rt } from "lucide-react";
|
|
4
|
+
import { useState as O, useRef as Me, useEffect as Be, useMemo as oe, Fragment as Ce, useCallback as Ee, memo as nt } from "react";
|
|
5
5
|
import { toast as z } from "sonner";
|
|
6
6
|
import { useNivaroClient as xe, useItemEditAuth as at } from "../../context.js";
|
|
7
|
-
import { get as
|
|
7
|
+
import { get as U, post as ve, del as lt } from "../../lib/commands.js";
|
|
8
8
|
import { sanitizeHtml as st } from "../../lib/sanitize-html.js";
|
|
9
9
|
import { titleCase as fe } from "../../lib/utils.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
10
|
+
import { DocumentAutofillButton as it } from "../import/DocumentAutofillButton.js";
|
|
11
|
+
import { FieldRenderer as ot } from "../item-edit/FieldRenderer.js";
|
|
12
|
+
import { useFileDownload as dt } from "../item-edit/file-download.js";
|
|
13
13
|
import { evalClientFormula as ct } from "../item-edit/InlineTableField.js";
|
|
14
14
|
import { parseRollupParentFilter as Le, matchesRollupFilter as mt, computeLiveRollup as Ie, parseRollupSources as Je } from "../item-edit/live-rollups.js";
|
|
15
15
|
import { useLocalLiveRows as ut, LiveRowsContext as pt, O2MStagingContext as ft, useLiveRows as ht } from "../item-edit/O2MStagingContext.js";
|
|
@@ -24,46 +24,46 @@ import { AddendumLinesDiff as Ke } from "./AddendumLinesDiff.js";
|
|
|
24
24
|
import { resolveAddendumAmounts as kt } from "./addendum-summary.js";
|
|
25
25
|
const ye = new Intl.NumberFormat("en-US", { style: "currency", currency: "USD" }), _t = (r) => r.replace(/<[^>]+>/g, " ").replace(/ /g, " ").replace(/\s+/g, " ").trim();
|
|
26
26
|
function ze(r) {
|
|
27
|
-
const
|
|
28
|
-
return !r || Number.isNaN(
|
|
27
|
+
const c = Number(r);
|
|
28
|
+
return !r || Number.isNaN(c) || c === 0 ? null : /* @__PURE__ */ i(
|
|
29
29
|
"span",
|
|
30
30
|
{
|
|
31
|
-
className:
|
|
31
|
+
className: T(
|
|
32
32
|
"inline-flex items-center rounded-full px-2 py-0.5 text-[11px] font-medium tabular-nums",
|
|
33
|
-
|
|
33
|
+
c > 0 ? "bg-emerald-50 text-emerald-700 dark:bg-emerald-500/10 dark:text-emerald-400" : "bg-red-50 text-red-600 dark:bg-red-500/10 dark:text-red-400"
|
|
34
34
|
),
|
|
35
35
|
children: [
|
|
36
|
-
|
|
37
|
-
ye.format(Math.abs(
|
|
36
|
+
c > 0 ? "+" : "−",
|
|
37
|
+
ye.format(Math.abs(c))
|
|
38
38
|
]
|
|
39
39
|
}
|
|
40
40
|
);
|
|
41
41
|
}
|
|
42
42
|
function wt({ amounts: r }) {
|
|
43
|
-
const { previous:
|
|
43
|
+
const { previous: c, next: N, change: h } = r, k = h != null && h !== 0, u = [
|
|
44
44
|
{
|
|
45
45
|
label: "Previous",
|
|
46
|
-
value:
|
|
46
|
+
value: c == null ? "—" : ye.format(c),
|
|
47
47
|
className: "text-slate-500 dark:text-slate-400"
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
50
|
label: "New",
|
|
51
|
-
value:
|
|
51
|
+
value: N == null ? "—" : ye.format(N),
|
|
52
52
|
className: "font-semibold text-foreground"
|
|
53
53
|
},
|
|
54
54
|
{
|
|
55
55
|
label: "Change",
|
|
56
|
-
value:
|
|
57
|
-
className:
|
|
56
|
+
value: h == null ? "—" : k ? `${h > 0 ? "+" : "−"}${ye.format(Math.abs(h))}` : "No change",
|
|
57
|
+
className: k ? h > 0 ? "font-semibold text-emerald-600 dark:text-emerald-400" : "font-semibold text-red-600 dark:text-red-400" : "text-slate-500 dark:text-slate-400"
|
|
58
58
|
}
|
|
59
59
|
];
|
|
60
|
-
return /* @__PURE__ */ t("div", { className: "flex flex-wrap items-start gap-x-8 gap-y-2", children:
|
|
61
|
-
/* @__PURE__ */ t("p", { className:
|
|
62
|
-
/* @__PURE__ */ t("p", { className: "text-[11px] leading-4 text-slate-400 dark:text-slate-500", children:
|
|
63
|
-
] },
|
|
60
|
+
return /* @__PURE__ */ t("div", { className: "flex flex-wrap items-start gap-x-8 gap-y-2", children: u.map((x) => /* @__PURE__ */ i("div", { className: "min-w-0", children: [
|
|
61
|
+
/* @__PURE__ */ t("p", { className: T("text-[13px] leading-5 tabular-nums", x.className), children: x.value }),
|
|
62
|
+
/* @__PURE__ */ t("p", { className: "text-[11px] leading-4 text-slate-400 dark:text-slate-500", children: x.label })
|
|
63
|
+
] }, x.label)) });
|
|
64
64
|
}
|
|
65
65
|
const We = "grid grid-cols-1 items-baseline text-[12.5px] sm:grid-cols-[140px_minmax(0,1fr)] sm:gap-x-6 sm:gap-y-2.5", de = "text-[12px] text-slate-500 dark:text-slate-400", ce = "mb-2.5 min-w-0 text-slate-700 sm:mb-0 dark:text-slate-200";
|
|
66
|
-
function
|
|
66
|
+
function T(...r) {
|
|
67
67
|
return r.filter(Boolean).join(" ");
|
|
68
68
|
}
|
|
69
69
|
const Ae = {
|
|
@@ -87,41 +87,41 @@ const Ae = {
|
|
|
87
87
|
badge: "bg-amber-50 text-amber-700 dark:bg-amber-500/10 dark:text-amber-400",
|
|
88
88
|
dot: "bg-amber-500"
|
|
89
89
|
}
|
|
90
|
-
}, Ct = (r,
|
|
91
|
-
function St(r,
|
|
92
|
-
if (!
|
|
93
|
-
const
|
|
94
|
-
return
|
|
90
|
+
}, Ct = (r, c) => Math.round(Number(r) * 100) === Math.round(Number(c) * 100);
|
|
91
|
+
function St(r, c, N) {
|
|
92
|
+
if (!N || r.computed_type !== "rollup" || !r.computed_formula) return r;
|
|
93
|
+
const h = Ie(Je(r.computed_formula), N.rows);
|
|
94
|
+
return h === null || c != null && Ct(c, h) ? r : {
|
|
95
95
|
...r,
|
|
96
96
|
options: {
|
|
97
97
|
...r.options ?? {},
|
|
98
|
-
__live_delta: { original:
|
|
98
|
+
__live_delta: { original: c, live: h }
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
|
-
function
|
|
102
|
+
function $t({
|
|
103
103
|
current: r,
|
|
104
|
-
value:
|
|
105
|
-
onChange:
|
|
106
|
-
currentLabel:
|
|
107
|
-
newLabel:
|
|
104
|
+
value: c,
|
|
105
|
+
onChange: N,
|
|
106
|
+
currentLabel: h,
|
|
107
|
+
newLabel: k
|
|
108
108
|
}) {
|
|
109
|
-
const [
|
|
110
|
-
const
|
|
111
|
-
return !Number.isFinite(
|
|
112
|
-
}), _ =
|
|
109
|
+
const [u, x] = O(() => {
|
|
110
|
+
const v = Number(c);
|
|
111
|
+
return !Number.isFinite(v) || Math.round(v * 100) === Math.round(r * 100) ? "" : String(Math.round((v - r) * 100) / 100);
|
|
112
|
+
}), _ = u.trim() === "" ? 0 : Number(u), f = Number.isFinite(_), $ = f ? Math.round((r + _) * 100) / 100 : r, m = (v) => v.toLocaleString("en-US", { style: "currency", currency: "USD" });
|
|
113
113
|
return /* @__PURE__ */ i("div", { className: "space-y-1.5", children: [
|
|
114
114
|
/* @__PURE__ */ i("div", { className: "flex items-center gap-0", children: [
|
|
115
115
|
/* @__PURE__ */ t("span", { className: "flex h-9 items-center rounded-l-md border border-r-0 border-slate-200 bg-slate-50 px-2.5 text-[13px] text-slate-500 dark:border-border dark:bg-muted", children: "$" }),
|
|
116
116
|
/* @__PURE__ */ t(
|
|
117
117
|
Pe,
|
|
118
118
|
{
|
|
119
|
-
value:
|
|
120
|
-
onChange: (
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
const
|
|
124
|
-
Number.isFinite(
|
|
119
|
+
value: u,
|
|
120
|
+
onChange: (v) => {
|
|
121
|
+
const w = v.target.value;
|
|
122
|
+
x(w);
|
|
123
|
+
const S = w.trim() === "" ? 0 : Number(w);
|
|
124
|
+
Number.isFinite(S) && N(Math.round((r + S) * 100) / 100);
|
|
125
125
|
},
|
|
126
126
|
placeholder: "Negative numbers to decrease",
|
|
127
127
|
className: "h-9 rounded-l-none text-[13px]"
|
|
@@ -130,22 +130,22 @@ function Ft({
|
|
|
130
130
|
] }),
|
|
131
131
|
/* @__PURE__ */ i("p", { className: "text-[12px]", children: [
|
|
132
132
|
/* @__PURE__ */ i("span", { className: "font-medium text-slate-600 dark:text-slate-300", children: [
|
|
133
|
-
|
|
133
|
+
h ?? "Current REQ Amount",
|
|
134
134
|
":"
|
|
135
135
|
] }),
|
|
136
136
|
" ",
|
|
137
|
-
/* @__PURE__ */ t("span", { className: "tabular-nums text-slate-700 dark:text-slate-200", children:
|
|
137
|
+
/* @__PURE__ */ t("span", { className: "tabular-nums text-slate-700 dark:text-slate-200", children: m(r) }),
|
|
138
138
|
/* @__PURE__ */ t("span", { className: "mx-2 text-slate-300", children: "·" }),
|
|
139
139
|
/* @__PURE__ */ i("span", { className: "font-medium text-slate-600 dark:text-slate-300", children: [
|
|
140
|
-
|
|
140
|
+
k ?? "New REQ Total",
|
|
141
141
|
":"
|
|
142
142
|
] }),
|
|
143
143
|
" ",
|
|
144
144
|
/* @__PURE__ */ t(
|
|
145
145
|
"span",
|
|
146
146
|
{
|
|
147
|
-
className: "tabular-nums font-semibold " + (
|
|
148
|
-
children:
|
|
147
|
+
className: "tabular-nums font-semibold " + ($ > r ? "text-emerald-600 dark:text-emerald-400" : $ < r ? "text-red-600 dark:text-red-400" : "text-slate-700 dark:text-slate-200"),
|
|
148
|
+
children: m($)
|
|
149
149
|
}
|
|
150
150
|
),
|
|
151
151
|
!f && /* @__PURE__ */ t("span", { className: "ml-2 text-[11px] text-red-500", children: "Enter a number" })
|
|
@@ -153,122 +153,122 @@ function Ft({
|
|
|
153
153
|
] });
|
|
154
154
|
}
|
|
155
155
|
const qt = nt(function({
|
|
156
|
-
configuredFields:
|
|
157
|
-
fieldMap:
|
|
158
|
-
formData:
|
|
159
|
-
onFieldChange:
|
|
160
|
-
relations:
|
|
161
|
-
collection:
|
|
156
|
+
configuredFields: c,
|
|
157
|
+
fieldMap: N,
|
|
158
|
+
formData: h,
|
|
159
|
+
onFieldChange: k,
|
|
160
|
+
relations: u,
|
|
161
|
+
collection: x,
|
|
162
162
|
prefillParentId: _,
|
|
163
163
|
parentData: f
|
|
164
164
|
}) {
|
|
165
|
-
const
|
|
166
|
-
return
|
|
165
|
+
const $ = ht();
|
|
166
|
+
return c.length === 0 ? /* @__PURE__ */ t("div", { className: "rounded-lg border border-dashed border-slate-200 bg-slate-50 px-4 py-6 text-center dark:border-border dark:bg-muted/30", children: /* @__PURE__ */ t("p", { className: "text-[12px] text-slate-400 dark:text-slate-500", children: "No fields configured for addendum. Set up the field list in Data Model → Layouts → Addendum Form." }) }) : /* @__PURE__ */ i("div", { className: "border-t border-slate-100 dark:border-border pt-3", children: [
|
|
167
167
|
/* @__PURE__ */ t("p", { className: "mb-3 text-[11px] font-semibold uppercase tracking-wide text-slate-400 dark:text-slate-500", children: "Proposed changes" }),
|
|
168
|
-
/* @__PURE__ */ t("div", { className: "space-y-3", children:
|
|
169
|
-
const
|
|
170
|
-
if (!
|
|
168
|
+
/* @__PURE__ */ t("div", { className: "space-y-3", children: c.map((m) => {
|
|
169
|
+
const v = N[m.field], w = m.label_override ?? fe((v == null ? void 0 : v.field) ?? m.field);
|
|
170
|
+
if (!v)
|
|
171
171
|
return /* @__PURE__ */ i("div", { children: [
|
|
172
|
-
/* @__PURE__ */ t(he, { className: "mb-1 block text-[11px] font-medium text-slate-600 dark:text-slate-400", children:
|
|
172
|
+
/* @__PURE__ */ t(he, { className: "mb-1 block text-[11px] font-medium text-slate-600 dark:text-slate-400", children: w }),
|
|
173
173
|
/* @__PURE__ */ t(
|
|
174
174
|
Pe,
|
|
175
175
|
{
|
|
176
|
-
value: String(
|
|
177
|
-
onChange: (
|
|
176
|
+
value: String(h[m.field] ?? ""),
|
|
177
|
+
onChange: (j) => k(m.field, j.target.value),
|
|
178
178
|
className: "h-8 text-[12px]"
|
|
179
179
|
}
|
|
180
180
|
)
|
|
181
|
-
] },
|
|
182
|
-
const
|
|
181
|
+
] }, m.field);
|
|
182
|
+
const D = (typeof m.overrides == "string" ? (() => {
|
|
183
183
|
try {
|
|
184
|
-
return JSON.parse(
|
|
184
|
+
return JSON.parse(m.overrides);
|
|
185
185
|
} catch {
|
|
186
186
|
return {};
|
|
187
187
|
}
|
|
188
|
-
})() :
|
|
189
|
-
if (
|
|
190
|
-
const
|
|
188
|
+
})() : m.overrides ?? {}).options ?? {};
|
|
189
|
+
if (D.entry_mode === "delta") {
|
|
190
|
+
const j = Number((f == null ? void 0 : f[m.field]) ?? 0);
|
|
191
191
|
return /* @__PURE__ */ i("div", { children: [
|
|
192
|
-
/* @__PURE__ */ t(he, { className: "mb-1 block text-[11px] font-medium text-slate-600 dark:text-slate-400", children:
|
|
192
|
+
/* @__PURE__ */ t(he, { className: "mb-1 block text-[11px] font-medium text-slate-600 dark:text-slate-400", children: w }),
|
|
193
193
|
/* @__PURE__ */ t(
|
|
194
|
-
|
|
194
|
+
$t,
|
|
195
195
|
{
|
|
196
|
-
current: Number.isFinite(
|
|
197
|
-
value:
|
|
198
|
-
onChange: (P) =>
|
|
199
|
-
currentLabel: typeof
|
|
200
|
-
newLabel: typeof
|
|
196
|
+
current: Number.isFinite(j) ? j : 0,
|
|
197
|
+
value: h[m.field],
|
|
198
|
+
onChange: (P) => k(m.field, P),
|
|
199
|
+
currentLabel: typeof D.current_label == "string" ? D.current_label : void 0,
|
|
200
|
+
newLabel: typeof D.new_label == "string" ? D.new_label : void 0
|
|
201
201
|
}
|
|
202
202
|
)
|
|
203
|
-
] },
|
|
203
|
+
] }, m.field);
|
|
204
204
|
}
|
|
205
205
|
return /* @__PURE__ */ i("div", { children: [
|
|
206
|
-
/* @__PURE__ */ t(he, { className: "mb-1 block text-[11px] font-medium text-slate-600 dark:text-slate-400", children:
|
|
206
|
+
/* @__PURE__ */ t(he, { className: "mb-1 block text-[11px] font-medium text-slate-600 dark:text-slate-400", children: w }),
|
|
207
207
|
/* @__PURE__ */ t(
|
|
208
|
-
|
|
208
|
+
ot,
|
|
209
209
|
{
|
|
210
|
-
field: St(
|
|
211
|
-
value:
|
|
212
|
-
onChange: (
|
|
213
|
-
relations:
|
|
214
|
-
collection:
|
|
210
|
+
field: St(v, h[m.field], $),
|
|
211
|
+
value: h[m.field],
|
|
212
|
+
onChange: (j) => k(m.field, j),
|
|
213
|
+
relations: u,
|
|
214
|
+
collection: x,
|
|
215
215
|
itemId: "new",
|
|
216
216
|
prefillParentId: _
|
|
217
217
|
}
|
|
218
218
|
)
|
|
219
|
-
] },
|
|
219
|
+
] }, m.field);
|
|
220
220
|
}) })
|
|
221
221
|
] });
|
|
222
222
|
});
|
|
223
|
-
function
|
|
224
|
-
const
|
|
223
|
+
function Ft({ addendumId: r }) {
|
|
224
|
+
const c = xe(), { data: N, isLoading: h } = V({
|
|
225
225
|
queryKey: ["pipeline-instance", "nivaro_addendums", r],
|
|
226
|
-
queryFn: () =>
|
|
226
|
+
queryFn: () => c.request(U(`/pipelines/instance/nivaro_addendums/${r}`)).then((x) => x.data),
|
|
227
227
|
staleTime: 1e4
|
|
228
228
|
});
|
|
229
|
-
if (
|
|
230
|
-
if (!(
|
|
229
|
+
if (h) return /* @__PURE__ */ t(le, { className: "h-8 w-full" });
|
|
230
|
+
if (!(N != null && N.instance))
|
|
231
231
|
return /* @__PURE__ */ t("p", { className: "text-[12px] text-slate-400 italic", children: "No workflow instance found." });
|
|
232
|
-
const { instance:
|
|
232
|
+
const { instance: k } = N, u = k.current_state_obj;
|
|
233
233
|
return /* @__PURE__ */ i("div", { className: "space-y-3", children: [
|
|
234
|
-
|
|
234
|
+
u && /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
|
|
235
235
|
/* @__PURE__ */ t("span", { className: "text-[11px] text-slate-500", children: "Current state:" }),
|
|
236
236
|
/* @__PURE__ */ t(
|
|
237
237
|
"span",
|
|
238
238
|
{
|
|
239
239
|
className: "inline-flex items-center rounded-full px-2.5 py-0.5 text-[11px] font-medium",
|
|
240
240
|
style: {
|
|
241
|
-
backgroundColor:
|
|
242
|
-
color:
|
|
243
|
-
border: `1px solid ${
|
|
241
|
+
backgroundColor: u.color ? `${u.color}22` : "#f1f5f9",
|
|
242
|
+
color: u.color ?? "#475569",
|
|
243
|
+
border: `1px solid ${u.color ? `${u.color}44` : "#e2e8f0"}`
|
|
244
244
|
},
|
|
245
|
-
children:
|
|
245
|
+
children: u.label
|
|
246
246
|
}
|
|
247
247
|
)
|
|
248
248
|
] }),
|
|
249
|
-
|
|
249
|
+
k.completed_at && /* @__PURE__ */ t("p", { className: "text-[11px] text-slate-400 italic", children: "Workflow complete." })
|
|
250
250
|
] });
|
|
251
251
|
}
|
|
252
252
|
function At({
|
|
253
253
|
collection: r,
|
|
254
|
-
itemId:
|
|
255
|
-
assignments:
|
|
256
|
-
workflowTemplateId:
|
|
257
|
-
resolvedLayoutId:
|
|
258
|
-
fields:
|
|
259
|
-
relations:
|
|
254
|
+
itemId: c,
|
|
255
|
+
assignments: N,
|
|
256
|
+
workflowTemplateId: h,
|
|
257
|
+
resolvedLayoutId: k,
|
|
258
|
+
fields: u,
|
|
259
|
+
relations: x,
|
|
260
260
|
parentData: _,
|
|
261
261
|
onClose: f,
|
|
262
|
-
onCreated:
|
|
262
|
+
onCreated: $
|
|
263
263
|
}) {
|
|
264
|
-
const
|
|
264
|
+
const m = xe(), v = N.filter(
|
|
265
265
|
(a) => !String(a.field).startsWith("__") && (a.is_visible || a.is_visible === 1)
|
|
266
|
-
), [
|
|
266
|
+
), [w, S] = O(""), [D, j] = O(""), [P, J] = O([]), [ee, A] = O(0), G = Me(null), M = async (a) => {
|
|
267
267
|
if (a.length !== 0) {
|
|
268
268
|
A((s) => s + a.length);
|
|
269
269
|
for (const s of a)
|
|
270
270
|
try {
|
|
271
|
-
const d = await
|
|
271
|
+
const d = await m.upload(s);
|
|
272
272
|
J((o) => [...o, { id: String(d.id), name: s.name }]);
|
|
273
273
|
} catch {
|
|
274
274
|
z.error(`Failed to upload ${s.name}`);
|
|
@@ -276,9 +276,9 @@ function At({
|
|
|
276
276
|
A((d) => d - 1);
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
|
-
}, [te, E] =
|
|
279
|
+
}, [te, E] = O(() => {
|
|
280
280
|
const a = {};
|
|
281
|
-
for (const s of
|
|
281
|
+
for (const s of v) {
|
|
282
282
|
const d = typeof s.overrides == "string" ? (() => {
|
|
283
283
|
try {
|
|
284
284
|
return JSON.parse(s.overrides);
|
|
@@ -291,112 +291,112 @@ function At({
|
|
|
291
291
|
return a;
|
|
292
292
|
}), me = oe(() => {
|
|
293
293
|
const a = {};
|
|
294
|
-
for (const s of
|
|
294
|
+
for (const s of u) a[s.field] = s;
|
|
295
295
|
return a;
|
|
296
|
-
}, [
|
|
296
|
+
}, [u]), X = Ee((a, s) => {
|
|
297
297
|
E((d) => ({ ...d, [a]: s }));
|
|
298
298
|
}, []), W = Ee(
|
|
299
299
|
(a) => {
|
|
300
|
-
E((s) => ({ ...s, ...a.values })), !
|
|
300
|
+
E((s) => ({ ...s, ...a.values })), !w.trim() && a.summary && S(a.summary.slice(0, 120));
|
|
301
301
|
for (const [s, d] of Object.entries(a.lines_by_alias)) {
|
|
302
|
-
const o =
|
|
303
|
-
(
|
|
302
|
+
const o = x.find(
|
|
303
|
+
(C) => C.one_collection === r && !C.junction_field && (C.one_field === s || C.many_collection === s)
|
|
304
304
|
);
|
|
305
305
|
if (!(o != null && o.many_collection) || !o.many_field) continue;
|
|
306
|
-
const
|
|
307
|
-
L((
|
|
308
|
-
const q = new Map(
|
|
306
|
+
const b = o.many_field, y = `${o.many_collection}.${b}`;
|
|
307
|
+
L((C) => {
|
|
308
|
+
const q = new Map(C);
|
|
309
309
|
return q.set(y, [
|
|
310
310
|
...q.get(y) ?? [],
|
|
311
|
-
...d.map((ae) => ({ ...ae.values, [
|
|
311
|
+
...d.map((ae) => ({ ...ae.values, [b]: c }))
|
|
312
312
|
]), q;
|
|
313
313
|
});
|
|
314
314
|
}
|
|
315
315
|
a.file_id && J((s) => [...s, { id: a.file_id, name: a.document_name }]);
|
|
316
316
|
},
|
|
317
|
-
[r,
|
|
318
|
-
), [Y, L] =
|
|
317
|
+
[r, c, x, w]
|
|
318
|
+
), [Y, L] = O(
|
|
319
319
|
/* @__PURE__ */ new Map()
|
|
320
|
-
), [re, se] =
|
|
320
|
+
), [re, se] = O(/* @__PURE__ */ new Map()), [ne, ie] = O(/* @__PURE__ */ new Map()), Z = Me(Y);
|
|
321
321
|
Be(() => {
|
|
322
322
|
Z.current = Y;
|
|
323
323
|
}, [Y]);
|
|
324
|
-
const
|
|
324
|
+
const Q = ut(), R = oe(
|
|
325
325
|
() => ({
|
|
326
326
|
getPendingRows: (a, s) => Y.get(`${a}.${s}`) ?? [],
|
|
327
327
|
queueRow: (a, s, d) => L((o) => {
|
|
328
|
-
const
|
|
329
|
-
return
|
|
328
|
+
const b = new Map(o), y = `${a}.${s}`;
|
|
329
|
+
return b.set(y, [...b.get(y) ?? [], d]), b;
|
|
330
330
|
}),
|
|
331
331
|
removeRow: (a, s, d) => L((o) => {
|
|
332
|
-
const
|
|
333
|
-
return
|
|
332
|
+
const b = new Map(o), y = `${a}.${s}`, C = [...b.get(y) ?? []];
|
|
333
|
+
return C.splice(d, 1), b.set(y, C), b;
|
|
334
334
|
}),
|
|
335
|
-
updateRow: (a, s, d, o) => L((
|
|
336
|
-
const y = new Map(
|
|
337
|
-
return q[d] = { ...q[d], ...o }, y.set(
|
|
335
|
+
updateRow: (a, s, d, o) => L((b) => {
|
|
336
|
+
const y = new Map(b), C = `${a}.${s}`, q = [...y.get(C) ?? []];
|
|
337
|
+
return q[d] = { ...q[d], ...o }, y.set(C, q), y;
|
|
338
338
|
}),
|
|
339
|
-
reorderRows: (a, s, d, o) => L((
|
|
340
|
-
const y = new Map(
|
|
341
|
-
return q.splice(o, 0, ae), y.set(
|
|
339
|
+
reorderRows: (a, s, d, o) => L((b) => {
|
|
340
|
+
const y = new Map(b), C = `${a}.${s}`, q = [...y.get(C) ?? []], [ae] = q.splice(d, 1);
|
|
341
|
+
return q.splice(o, 0, ae), y.set(C, q), y;
|
|
342
342
|
}),
|
|
343
343
|
getPendingEdits: (a, s) => re.get(`${a}.${s}`) ?? /* @__PURE__ */ new Map(),
|
|
344
344
|
getPendingDeletes: (a, s) => ne.get(`${a}.${s}`) ?? /* @__PURE__ */ new Set(),
|
|
345
|
-
queueEdit: (a, s, d, o) => se((
|
|
346
|
-
const y = new Map(
|
|
347
|
-
return q.set(d, { ...q.get(d) ?? {}, ...o }), y.set(
|
|
345
|
+
queueEdit: (a, s, d, o) => se((b) => {
|
|
346
|
+
const y = new Map(b), C = `${a}.${s}`, q = new Map(y.get(C) ?? []);
|
|
347
|
+
return q.set(d, { ...q.get(d) ?? {}, ...o }), y.set(C, q), y;
|
|
348
348
|
}),
|
|
349
349
|
queueDelete: (a, s, d) => ie((o) => {
|
|
350
|
-
const
|
|
351
|
-
return
|
|
350
|
+
const b = new Map(o), y = `${a}.${s}`;
|
|
351
|
+
return b.set(y, /* @__PURE__ */ new Set([...b.get(y) ?? [], d])), b;
|
|
352
352
|
}),
|
|
353
353
|
cancelPendingEdit: (a, s, d) => se((o) => {
|
|
354
|
-
const
|
|
355
|
-
return
|
|
354
|
+
const b = new Map(o), y = `${a}.${s}`, C = new Map(b.get(y) ?? []);
|
|
355
|
+
return C.delete(d), b.set(y, C), b;
|
|
356
356
|
}),
|
|
357
357
|
cancelPendingDelete: (a, s, d) => ie((o) => {
|
|
358
|
-
const
|
|
359
|
-
return
|
|
358
|
+
const b = new Map(o), y = `${a}.${s}`, C = new Set(b.get(y) ?? []);
|
|
359
|
+
return C.delete(d), b.set(y, C), b;
|
|
360
360
|
})
|
|
361
361
|
}),
|
|
362
362
|
[Y, re, ne]
|
|
363
|
-
),
|
|
363
|
+
), p = pe({
|
|
364
364
|
mutationFn: () => {
|
|
365
365
|
const a = {};
|
|
366
366
|
for (const [s, d] of Object.entries(te)) {
|
|
367
367
|
const o = me[s];
|
|
368
368
|
(o == null ? void 0 : o.computed_type) === "rollup" || (o == null ? void 0 : o.computed_type) === "write" || d !== void 0 && String(d ?? "") !== String(_[s] ?? "") && (a[s] = d);
|
|
369
369
|
}
|
|
370
|
-
for (const s of
|
|
371
|
-
const d =
|
|
370
|
+
for (const s of v) {
|
|
371
|
+
const d = x.find(
|
|
372
372
|
(o) => o.one_collection === r && !o.junction_field && (o.one_field === s.field || o.many_collection === s.field)
|
|
373
373
|
);
|
|
374
374
|
if (d != null && d.many_collection && d.many_field) {
|
|
375
|
-
const o = (Z.current.get(`${d.many_collection}.${d.many_field}`) ?? []).map(({ __prefilled:
|
|
375
|
+
const o = (Z.current.get(`${d.many_collection}.${d.many_field}`) ?? []).map(({ __prefilled: b, ...y }) => y);
|
|
376
376
|
o.length > 0 && (a[s.field] = o);
|
|
377
377
|
}
|
|
378
378
|
}
|
|
379
|
-
return
|
|
379
|
+
return m.request(
|
|
380
380
|
ve("/addendums", {
|
|
381
381
|
parent_collection: r,
|
|
382
|
-
parent_id:
|
|
383
|
-
title:
|
|
384
|
-
description:
|
|
385
|
-
workflow_template_id:
|
|
386
|
-
addendum_layout_id:
|
|
382
|
+
parent_id: c,
|
|
383
|
+
title: w.trim(),
|
|
384
|
+
description: D.trim() || void 0,
|
|
385
|
+
workflow_template_id: h ?? void 0,
|
|
386
|
+
addendum_layout_id: k,
|
|
387
387
|
data: a,
|
|
388
|
-
fields_schema:
|
|
388
|
+
fields_schema: v.map((s) => s.field),
|
|
389
389
|
attachments: P.length > 0 ? P.map((s) => s.id) : void 0
|
|
390
390
|
})
|
|
391
391
|
);
|
|
392
392
|
},
|
|
393
393
|
onSuccess: (a) => {
|
|
394
394
|
var s;
|
|
395
|
-
z.success("Addendum created"),
|
|
395
|
+
z.success("Addendum created"), $(((s = a == null ? void 0 : a.data) == null ? void 0 : s.id) != null ? String(a.data.id) : null), f();
|
|
396
396
|
},
|
|
397
397
|
onError: () => z.error("Failed to create addendum")
|
|
398
398
|
});
|
|
399
|
-
return /* @__PURE__ */ t(pt.Provider, { value:
|
|
399
|
+
return /* @__PURE__ */ t(pt.Provider, { value: Q, children: /* @__PURE__ */ t(ft.Provider, { value: R, children: /* @__PURE__ */ i("div", { className: "flex h-full flex-col", children: [
|
|
400
400
|
/* @__PURE__ */ i(gt, { className: "shrink-0 border-b border-slate-200 px-5 py-4 dark:border-border", children: [
|
|
401
401
|
/* @__PURE__ */ t(vt, { className: "text-[14px] font-semibold text-slate-900 dark:text-slate-100", children: "New Addendum" }),
|
|
402
402
|
/* @__PURE__ */ t("p", { className: "mt-0.5 text-[12px] text-slate-500 dark:text-slate-400", children: "Propose changes to this record. Fields are pre-filled with current values — edit what's changing." })
|
|
@@ -411,8 +411,8 @@ function At({
|
|
|
411
411
|
/* @__PURE__ */ t(
|
|
412
412
|
Pe,
|
|
413
413
|
{
|
|
414
|
-
value:
|
|
415
|
-
onChange: (a) =>
|
|
414
|
+
value: w,
|
|
415
|
+
onChange: (a) => S(a.target.value),
|
|
416
416
|
className: "h-8 text-[12px]",
|
|
417
417
|
placeholder: "Brief description of this addendum",
|
|
418
418
|
autoFocus: !0
|
|
@@ -424,8 +424,8 @@ function At({
|
|
|
424
424
|
/* @__PURE__ */ t(
|
|
425
425
|
yt,
|
|
426
426
|
{
|
|
427
|
-
value:
|
|
428
|
-
onChange: (a) =>
|
|
427
|
+
value: D,
|
|
428
|
+
onChange: (a) => j(a.target.value),
|
|
429
429
|
rows: 2,
|
|
430
430
|
className: "text-[12px]",
|
|
431
431
|
placeholder: "Why is this change needed?"
|
|
@@ -452,7 +452,7 @@ function At({
|
|
|
452
452
|
{
|
|
453
453
|
className: "inline-flex max-w-[240px] items-center gap-1 rounded border border-slate-200 bg-slate-50 px-2 py-1 text-[11px] text-slate-700 dark:border-border dark:bg-muted dark:text-slate-200",
|
|
454
454
|
children: [
|
|
455
|
-
/* @__PURE__ */ t(
|
|
455
|
+
/* @__PURE__ */ t(Qe, { className: "h-3 w-3 shrink-0 text-slate-400" }),
|
|
456
456
|
/* @__PURE__ */ t("span", { className: "truncate", children: a.name }),
|
|
457
457
|
/* @__PURE__ */ t(
|
|
458
458
|
"button",
|
|
@@ -484,10 +484,10 @@ function At({
|
|
|
484
484
|
}
|
|
485
485
|
),
|
|
486
486
|
/* @__PURE__ */ t(
|
|
487
|
-
|
|
487
|
+
it,
|
|
488
488
|
{
|
|
489
489
|
collection: r,
|
|
490
|
-
layoutId:
|
|
490
|
+
layoutId: k,
|
|
491
491
|
label: "Fill from document",
|
|
492
492
|
onApply: W,
|
|
493
493
|
className: "h-7 px-2.5 text-[11px]"
|
|
@@ -500,13 +500,13 @@ function At({
|
|
|
500
500
|
qt,
|
|
501
501
|
{
|
|
502
502
|
parentData: _,
|
|
503
|
-
configuredFields:
|
|
503
|
+
configuredFields: v,
|
|
504
504
|
fieldMap: me,
|
|
505
505
|
formData: te,
|
|
506
506
|
onFieldChange: X,
|
|
507
|
-
relations:
|
|
507
|
+
relations: x,
|
|
508
508
|
collection: r,
|
|
509
|
-
prefillParentId:
|
|
509
|
+
prefillParentId: c
|
|
510
510
|
}
|
|
511
511
|
)
|
|
512
512
|
] }),
|
|
@@ -517,49 +517,49 @@ function At({
|
|
|
517
517
|
{
|
|
518
518
|
size: "sm",
|
|
519
519
|
className: "h-8 bg-nvr-cyan text-[12px] font-medium text-white hover:bg-nvr-cyan/90",
|
|
520
|
-
disabled: !
|
|
521
|
-
onClick: () =>
|
|
522
|
-
children:
|
|
520
|
+
disabled: !w.trim() || p.isPending,
|
|
521
|
+
onClick: () => p.mutate(),
|
|
522
|
+
children: p.isPending ? "Creating…" : "Create Addendum"
|
|
523
523
|
}
|
|
524
524
|
)
|
|
525
525
|
] })
|
|
526
526
|
] }) }) });
|
|
527
527
|
}
|
|
528
528
|
function Mt({ addendum: r }) {
|
|
529
|
-
var
|
|
530
|
-
const
|
|
531
|
-
queryKey: ["addendum-users", ...
|
|
529
|
+
var $;
|
|
530
|
+
const c = xe(), N = [r.created_by, r.approved_by].filter(Boolean), { data: h = {} } = V({
|
|
531
|
+
queryKey: ["addendum-users", ...N.sort()],
|
|
532
532
|
queryFn: async () => {
|
|
533
|
-
const
|
|
534
|
-
|
|
535
|
-
filter: JSON.stringify({ id: { _in:
|
|
533
|
+
const m = await c.request(
|
|
534
|
+
U("/items/nivaro_users", {
|
|
535
|
+
filter: JSON.stringify({ id: { _in: N } }),
|
|
536
536
|
fields: "id,first_name,last_name"
|
|
537
537
|
})
|
|
538
|
-
).then((
|
|
538
|
+
).then((v) => v.data ?? []);
|
|
539
539
|
return Object.fromEntries(
|
|
540
|
-
|
|
541
|
-
String(
|
|
542
|
-
[
|
|
540
|
+
m.map((v) => [
|
|
541
|
+
String(v.id).toUpperCase(),
|
|
542
|
+
[v.first_name, v.last_name].filter(Boolean).join(" ")
|
|
543
543
|
])
|
|
544
544
|
);
|
|
545
545
|
},
|
|
546
|
-
enabled:
|
|
546
|
+
enabled: N.length > 0,
|
|
547
547
|
staleTime: 3e5
|
|
548
|
-
}),
|
|
548
|
+
}), k = (m) => m && h[String(m).toUpperCase()] || null, u = (m) => m ? new Date(m).toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric" }) : null, x = k(r.created_by), _ = k(r.approved_by), f = [];
|
|
549
549
|
return r.timeline_impact_days != null && Number(r.timeline_impact_days) !== 0 && f.push({
|
|
550
550
|
label: "Timeline impact",
|
|
551
551
|
value: `${r.timeline_impact_days > 0 ? "+" : ""}${r.timeline_impact_days} days`
|
|
552
552
|
}), r.created_at && f.push({
|
|
553
553
|
label: "Created",
|
|
554
|
-
value: [
|
|
554
|
+
value: [u(r.created_at), x].filter(Boolean).join(" · ")
|
|
555
555
|
}), r.status === "approved" && (r.approved_at || _) && f.push({
|
|
556
556
|
label: "Approved",
|
|
557
|
-
value: [
|
|
558
|
-
}), f.length === 0 && !r.description && !((
|
|
559
|
-
f.map((
|
|
560
|
-
/* @__PURE__ */ t("dt", { className: de, children:
|
|
561
|
-
/* @__PURE__ */ t("dd", { className: ce, children:
|
|
562
|
-
] },
|
|
557
|
+
value: [u(r.approved_at), _].filter(Boolean).join(" · ")
|
|
558
|
+
}), f.length === 0 && !r.description && !(($ = r.attachments) != null && $.length) ? null : /* @__PURE__ */ i("dl", { className: T(We, "px-4 py-3.5"), children: [
|
|
559
|
+
f.map((m) => /* @__PURE__ */ i(Ce, { children: [
|
|
560
|
+
/* @__PURE__ */ t("dt", { className: de, children: m.label }),
|
|
561
|
+
/* @__PURE__ */ t("dd", { className: ce, children: m.value })
|
|
562
|
+
] }, m.label)),
|
|
563
563
|
r.description && /* @__PURE__ */ i(Ne, { children: [
|
|
564
564
|
/* @__PURE__ */ t("dt", { className: de, children: "Justification" }),
|
|
565
565
|
/* @__PURE__ */ t("dd", { className: ce, children: /^\s*</.test(r.description) ? /* @__PURE__ */ t(
|
|
@@ -574,114 +574,112 @@ function Mt({ addendum: r }) {
|
|
|
574
574
|
] });
|
|
575
575
|
}
|
|
576
576
|
function Pt({ ids: r }) {
|
|
577
|
-
const
|
|
578
|
-
queryKey: ["addendum-files", ...
|
|
577
|
+
const c = xe(), N = dt(), h = Array.isArray(r) ? r.filter(Boolean) : [], { data: k = [] } = V({
|
|
578
|
+
queryKey: ["addendum-files", ...h],
|
|
579
579
|
queryFn: () => Promise.all(
|
|
580
|
-
|
|
581
|
-
(
|
|
582
|
-
var
|
|
580
|
+
h.map(
|
|
581
|
+
(u) => c.request(U(`/files/${u}/meta`)).then((x) => {
|
|
582
|
+
var _, f, $, m, v, w;
|
|
583
583
|
return {
|
|
584
|
-
id:
|
|
585
|
-
filename: ((
|
|
586
|
-
size: ((
|
|
587
|
-
type: ((
|
|
588
|
-
missing: !!((w =
|
|
584
|
+
id: u,
|
|
585
|
+
filename: ((_ = x.data) == null ? void 0 : _.filename_download) ?? ((f = x.data) == null ? void 0 : f.filename) ?? (($ = x.data) == null ? void 0 : $.title) ?? null,
|
|
586
|
+
size: ((m = x.data) == null ? void 0 : m.filesize) ?? null,
|
|
587
|
+
type: ((v = x.data) == null ? void 0 : v.type) ?? null,
|
|
588
|
+
missing: !!((w = x.data) != null && w.missing_at)
|
|
589
589
|
};
|
|
590
|
-
}).catch(() => ({ id:
|
|
590
|
+
}).catch(() => ({ id: u, filename: null, size: null, type: null, missing: !1 }))
|
|
591
591
|
)
|
|
592
592
|
),
|
|
593
|
-
enabled:
|
|
593
|
+
enabled: h.length > 0,
|
|
594
594
|
staleTime: 3e5
|
|
595
595
|
});
|
|
596
|
-
return
|
|
596
|
+
return h.length === 0 ? null : /* @__PURE__ */ i(Ne, { children: [
|
|
597
597
|
/* @__PURE__ */ t("dt", { className: de, children: "Attachments" }),
|
|
598
|
-
/* @__PURE__ */ i("dd", { className:
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
N.length,
|
|
598
|
+
/* @__PURE__ */ i("dd", { className: T(ce, "flex flex-wrap gap-x-4 gap-y-1"), children: [
|
|
599
|
+
k.length === 0 && /* @__PURE__ */ i("span", { className: "text-slate-400 dark:text-slate-500", children: [
|
|
600
|
+
h.length,
|
|
602
601
|
" ",
|
|
603
|
-
|
|
602
|
+
h.length === 1 ? "file" : "files",
|
|
604
603
|
"…"
|
|
605
604
|
] }),
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
p.id
|
|
605
|
+
k.map((u) => (
|
|
606
|
+
// Every file click downloads (2026-11-08): no in-app preview.
|
|
607
|
+
/* @__PURE__ */ i(
|
|
608
|
+
"a",
|
|
609
|
+
{
|
|
610
|
+
href: `${c.fileUrl(u.id)}?download=1`,
|
|
611
|
+
download: u.filename || !0,
|
|
612
|
+
onClick: N(`${c.fileUrl(u.id)}?download=1`, u.filename),
|
|
613
|
+
title: "Download",
|
|
614
|
+
className: "inline-flex min-w-0 items-center gap-1.5 rounded text-slate-700 underline-offset-2 transition-colors hover:text-nvr-cyan hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/40 dark:text-slate-200",
|
|
615
|
+
children: [
|
|
616
|
+
u.missing && /* @__PURE__ */ t(
|
|
617
|
+
"span",
|
|
618
|
+
{
|
|
619
|
+
className: "rounded bg-red-500/10 px-1 py-px text-[9px] font-semibold uppercase tracking-wide text-red-600 dark:text-red-400",
|
|
620
|
+
title: "The stored file is missing from storage — preview/download will fail. Re-upload it.",
|
|
621
|
+
children: "missing"
|
|
622
|
+
}
|
|
623
|
+
),
|
|
624
|
+
/* @__PURE__ */ t(Qe, { className: "h-3 w-3 shrink-0 text-slate-400" }),
|
|
625
|
+
/* @__PURE__ */ t("span", { className: "max-w-[320px] truncate", children: u.filename ?? `File ${u.id.slice(0, 8)}…` })
|
|
626
|
+
]
|
|
627
|
+
},
|
|
628
|
+
u.id
|
|
629
|
+
)
|
|
632
630
|
))
|
|
633
631
|
] })
|
|
634
632
|
] });
|
|
635
633
|
}
|
|
636
634
|
function jt({
|
|
637
635
|
addendum: r,
|
|
638
|
-
configuredFields:
|
|
639
|
-
onRefresh:
|
|
640
|
-
isActive:
|
|
641
|
-
relations:
|
|
642
|
-
parentCollection:
|
|
643
|
-
parentId:
|
|
636
|
+
configuredFields: c,
|
|
637
|
+
onRefresh: N,
|
|
638
|
+
isActive: h,
|
|
639
|
+
relations: k = [],
|
|
640
|
+
parentCollection: u,
|
|
641
|
+
parentId: x,
|
|
644
642
|
fieldMap: _ = {}
|
|
645
643
|
}) {
|
|
646
644
|
var je, Re;
|
|
647
|
-
const f = xe(), [
|
|
648
|
-
const n =
|
|
649
|
-
(l) => l.one_collection ===
|
|
645
|
+
const f = xe(), [$, m] = O(!1), v = r.workflow_template_id && ["draft", "review"].includes(r.status) ? "in approvals" : r.status, w = v === "in approvals" ? Ae.review : Ae[r.status] ?? Ae.draft, S = r.data ?? {}, j = Object.keys(S).filter((e) => Array.isArray(S[e])).map((e) => c.find((n) => n.field === e) ?? { field: e }).map((e) => {
|
|
646
|
+
const n = k.find(
|
|
647
|
+
(l) => l.one_collection === u && !l.junction_field && (l.one_field === e.field || l.many_collection === e.field)
|
|
650
648
|
);
|
|
651
649
|
return { field: e.field, rel: n };
|
|
652
650
|
}).filter((e) => {
|
|
653
651
|
var n, l;
|
|
654
652
|
return ((n = e.rel) == null ? void 0 : n.many_collection) && ((l = e.rel) == null ? void 0 : l.many_field);
|
|
655
|
-
}), P =
|
|
656
|
-
queries:
|
|
657
|
-
queryKey: ["o2m-rows", e.many_collection, e.many_field,
|
|
653
|
+
}), P = Te({
|
|
654
|
+
queries: j.map(({ rel: e }) => ({
|
|
655
|
+
queryKey: ["o2m-rows", e.many_collection, e.many_field, x],
|
|
658
656
|
queryFn: () => f.request(
|
|
659
|
-
|
|
660
|
-
filter: JSON.stringify({ [e.many_field]: { _eq:
|
|
657
|
+
U(`/items/${e.many_collection}`, {
|
|
658
|
+
filter: JSON.stringify({ [e.many_field]: { _eq: x } }),
|
|
661
659
|
limit: 200
|
|
662
660
|
})
|
|
663
661
|
).then((n) => n.data ?? []),
|
|
664
662
|
staleTime: 3e4,
|
|
665
|
-
enabled: !!
|
|
663
|
+
enabled: !!x
|
|
666
664
|
}))
|
|
667
665
|
}), J = ["approved", "reverted"].includes(r.status), { data: ee } = V({
|
|
668
666
|
queryKey: ["addendum-lines", r.id],
|
|
669
|
-
queryFn: () => f.request(
|
|
670
|
-
enabled:
|
|
667
|
+
queryFn: () => f.request(U(`/addendums/${r.id}/lines`)).then((e) => e.data ?? {}),
|
|
668
|
+
enabled: $ && J,
|
|
671
669
|
staleTime: 6e4
|
|
672
670
|
}), A = Object.fromEntries(
|
|
673
671
|
P.map((e, n) => [
|
|
674
|
-
|
|
672
|
+
j[n].field,
|
|
675
673
|
e.data ?? null
|
|
676
674
|
])
|
|
677
675
|
), G = pe({
|
|
678
676
|
mutationFn: () => f.request(ve(`/addendums/${r.id}/approve`)),
|
|
679
677
|
onSuccess: () => {
|
|
680
|
-
|
|
678
|
+
N(), z.success("Addendum approved — changes applied to record");
|
|
681
679
|
},
|
|
682
680
|
onError: (e) => {
|
|
683
|
-
var l,
|
|
684
|
-
const n = (
|
|
681
|
+
var l, g;
|
|
682
|
+
const n = (g = (l = e == null ? void 0 : e.response) == null ? void 0 : l.data) == null ? void 0 : g.error;
|
|
685
683
|
z.error(n ?? "Failed to approve");
|
|
686
684
|
}
|
|
687
685
|
}), M = pe({
|
|
@@ -690,84 +688,84 @@ function jt({
|
|
|
690
688
|
Y(), z.success("Addendum reverted — the record is back to its pre-approval values");
|
|
691
689
|
},
|
|
692
690
|
onError: (e) => {
|
|
693
|
-
var l,
|
|
694
|
-
const n = (
|
|
691
|
+
var l, g;
|
|
692
|
+
const n = (g = (l = e == null ? void 0 : e.response) == null ? void 0 : l.data) == null ? void 0 : g.error;
|
|
695
693
|
z.error(n ?? "Failed to revert", { duration: 1e4 });
|
|
696
694
|
}
|
|
697
|
-
}), [te, E] =
|
|
698
|
-
|
|
695
|
+
}), [te, E] = O(!1), [me, X] = O(!1), W = Ue(), Y = () => {
|
|
696
|
+
N(), W.invalidateQueries({ queryKey: ["addendums"] }), W.invalidateQueries({ queryKey: ["item-actions"] }), W.invalidateQueries({ queryKey: ["ext-item-actions"] }), W.invalidateQueries({ queryKey: ["pipeline-all-owners"] }), W.invalidateQueries({ queryKey: ["item"] }), W.invalidateQueries({ queryKey: ["o2m-rows"] }), W.invalidateQueries({ queryKey: ["pipeline-instance"] });
|
|
699
697
|
}, L = pe({
|
|
700
698
|
mutationFn: () => f.request(lt(`/addendums/${r.id}`)),
|
|
701
699
|
onSuccess: () => {
|
|
702
700
|
Y(), z.success("Addendum deleted");
|
|
703
701
|
},
|
|
704
702
|
onError: (e) => {
|
|
705
|
-
var l,
|
|
706
|
-
const n = (
|
|
703
|
+
var l, g;
|
|
704
|
+
const n = (g = (l = e == null ? void 0 : e.response) == null ? void 0 : l.data) == null ? void 0 : g.error;
|
|
707
705
|
z.error(n ?? "Failed to delete", { duration: 1e4 });
|
|
708
706
|
}
|
|
709
707
|
}), { isAdmin: re } = at(), se = pe({
|
|
710
708
|
mutationFn: () => f.request(ve(`/addendums/${r.id}/reject`)),
|
|
711
709
|
onSuccess: () => {
|
|
712
|
-
|
|
710
|
+
N(), z.success("Addendum rejected");
|
|
713
711
|
},
|
|
714
712
|
onError: () => z.error("Failed to reject")
|
|
715
713
|
}), ne = pe({
|
|
716
714
|
mutationFn: () => f.request(ve(`/addendums/${r.id}/submit`)),
|
|
717
715
|
onSuccess: () => {
|
|
718
|
-
|
|
716
|
+
N(), z.success("Submitted for review");
|
|
719
717
|
},
|
|
720
718
|
onError: () => z.error("Failed to submit")
|
|
721
|
-
}), ie =
|
|
722
|
-
const n =
|
|
723
|
-
(l) => l.one_collection ===
|
|
719
|
+
}), ie = c.filter((e) => S[e.field] !== void 0), Z = (e) => e.computed_type === "rollup" ? Je(e.computed_formula) : [], Q = (e) => {
|
|
720
|
+
const n = k.find(
|
|
721
|
+
(l) => l.one_collection === u && l.many_collection === e.related_collection && l.many_field === e.fk_field && !l.junction_field
|
|
724
722
|
);
|
|
725
723
|
return n ? n.one_field ?? n.many_collection : null;
|
|
726
|
-
},
|
|
724
|
+
}, R = oe(
|
|
727
725
|
() => Object.values(_).filter((e) => {
|
|
728
726
|
const n = Z(e);
|
|
729
727
|
return n.length > 0 && !n.some((l) => l.recursive) && n.every((l) => {
|
|
730
|
-
const
|
|
731
|
-
return !!
|
|
728
|
+
const g = Q(l);
|
|
729
|
+
return !!g && Array.isArray(S[g]);
|
|
732
730
|
});
|
|
733
731
|
}),
|
|
734
732
|
// biome-ignore lint/correctness/useExhaustiveDependencies: helpers close over relations/parentCollection
|
|
735
|
-
[_,
|
|
736
|
-
),
|
|
733
|
+
[_, S, k, u]
|
|
734
|
+
), p = oe(
|
|
737
735
|
() => [
|
|
738
736
|
...new Set(
|
|
739
|
-
|
|
737
|
+
R.flatMap((e) => Z(e).map((n) => n.related_collection))
|
|
740
738
|
)
|
|
741
739
|
],
|
|
742
|
-
[
|
|
743
|
-
), a =
|
|
744
|
-
queries:
|
|
740
|
+
[R]
|
|
741
|
+
), a = Te({
|
|
742
|
+
queries: p.map((e) => ({
|
|
745
743
|
queryKey: ["field-config", e, null],
|
|
746
|
-
queryFn: () => f.request(
|
|
744
|
+
queryFn: () => f.request(U(`/field-config/${e}`)).then((n) => n.data ?? []),
|
|
747
745
|
staleTime: 6e4
|
|
748
746
|
}))
|
|
749
747
|
}), s = a.map((e) => e.dataUpdatedAt).join(","), d = ie.filter((e) => {
|
|
750
|
-
const n =
|
|
751
|
-
return n != null && typeof n == "object" || n == null ? !1 : !
|
|
752
|
-
(l) => l.one_collection ===
|
|
748
|
+
const n = S[e.field];
|
|
749
|
+
return n != null && typeof n == "object" || n == null ? !1 : !k.some(
|
|
750
|
+
(l) => l.one_collection === u && (l.one_field === e.field || l.many_collection === e.field)
|
|
753
751
|
);
|
|
754
752
|
}), { data: o } = V({
|
|
755
753
|
queryKey: [
|
|
756
754
|
"addendum-current",
|
|
757
|
-
|
|
758
|
-
|
|
755
|
+
u,
|
|
756
|
+
x,
|
|
759
757
|
d.map((e) => e.field).join(","),
|
|
760
|
-
|
|
758
|
+
R.map((e) => e.field).join(",")
|
|
761
759
|
],
|
|
762
760
|
queryFn: () => f.request(
|
|
763
|
-
|
|
761
|
+
U(`/items/${u}/${x}`, {
|
|
764
762
|
fields: [
|
|
765
763
|
.../* @__PURE__ */ new Set([
|
|
766
764
|
"id",
|
|
767
765
|
...d.map((e) => e.field),
|
|
768
766
|
// The rollups themselves (current figure) plus any parent_filter
|
|
769
767
|
// columns that decide whether the rollup applies to this record.
|
|
770
|
-
...
|
|
768
|
+
...R.flatMap((e) => [
|
|
771
769
|
e.field,
|
|
772
770
|
...Object.keys(Le(e.computed_formula) ?? {})
|
|
773
771
|
])
|
|
@@ -775,52 +773,52 @@ function jt({
|
|
|
775
773
|
].join(",")
|
|
776
774
|
})
|
|
777
775
|
).then((e) => e.data ?? null).catch(() => null),
|
|
778
|
-
enabled: !!
|
|
776
|
+
enabled: !!u && !!x && (d.length > 0 || R.length > 0),
|
|
779
777
|
staleTime: 15e3
|
|
780
|
-
}),
|
|
778
|
+
}), b = oe(() => {
|
|
781
779
|
const e = /* @__PURE__ */ new Map(), n = new Map(
|
|
782
|
-
|
|
783
|
-
var
|
|
780
|
+
p.map((l, g) => {
|
|
781
|
+
var F;
|
|
784
782
|
return [
|
|
785
783
|
l,
|
|
786
|
-
(
|
|
784
|
+
(F = a[g]) == null ? void 0 : F.data
|
|
787
785
|
];
|
|
788
786
|
})
|
|
789
787
|
);
|
|
790
|
-
for (const l of
|
|
791
|
-
const
|
|
792
|
-
if (
|
|
793
|
-
const
|
|
788
|
+
for (const l of R) {
|
|
789
|
+
const g = Le(l.computed_formula);
|
|
790
|
+
if (g && o && !mt(o, g)) continue;
|
|
791
|
+
const F = /* @__PURE__ */ new Map();
|
|
794
792
|
let H = !0;
|
|
795
793
|
for (const B of Z(l)) {
|
|
796
|
-
const ge =
|
|
794
|
+
const ge = Q(B), ue = n.get(B.related_collection);
|
|
797
795
|
if (!ge || !ue) {
|
|
798
796
|
H = !1;
|
|
799
797
|
break;
|
|
800
798
|
}
|
|
801
|
-
const Ge = ue.filter((we) => we.computed_type === "write" && !!we.computed_formula), Xe =
|
|
802
|
-
const
|
|
799
|
+
const Ge = ue.filter((we) => we.computed_type === "write" && !!we.computed_formula), Xe = S[ge].map((we) => {
|
|
800
|
+
const Fe = { ...we };
|
|
803
801
|
for (const Oe of Ge) {
|
|
804
|
-
const
|
|
805
|
-
|
|
802
|
+
const De = ct(String(Oe.computed_formula), Fe);
|
|
803
|
+
De !== null && (Fe[Oe.field] = De);
|
|
806
804
|
}
|
|
807
|
-
return
|
|
805
|
+
return Fe;
|
|
808
806
|
});
|
|
809
|
-
|
|
807
|
+
F.set(`${B.related_collection}.${B.fk_field}`, Xe);
|
|
810
808
|
}
|
|
811
809
|
if (!H) continue;
|
|
812
|
-
const K = Ie(Z(l),
|
|
810
|
+
const K = Ie(Z(l), F);
|
|
813
811
|
K !== null && e.set(l.field, Math.round(K * 100) / 100);
|
|
814
812
|
}
|
|
815
813
|
return e;
|
|
816
|
-
}, [
|
|
817
|
-
const
|
|
818
|
-
return
|
|
819
|
-
(
|
|
814
|
+
}, [R, p, s, S, o]), y = (e, n) => n ? e.filter((l) => {
|
|
815
|
+
const g = n.find((F) => String(F.id) === String(l.id));
|
|
816
|
+
return g ? Object.keys(l).some(
|
|
817
|
+
(F) => F !== "id" && String(l[F] ?? "") !== String(g[F] ?? "")
|
|
820
818
|
) : !0;
|
|
821
819
|
}).length : e.length, q = [
|
|
822
820
|
...ie.filter((e) => {
|
|
823
|
-
const n =
|
|
821
|
+
const n = S[e.field];
|
|
824
822
|
if (n == null || n === "") return !1;
|
|
825
823
|
if (Array.isArray(n))
|
|
826
824
|
return y(n, A[e.field]) > 0;
|
|
@@ -829,50 +827,50 @@ function jt({
|
|
|
829
827
|
}).map((e) => ({
|
|
830
828
|
field: e.field,
|
|
831
829
|
label_override: e.label_override ?? null,
|
|
832
|
-
value:
|
|
830
|
+
value: S[e.field]
|
|
833
831
|
})),
|
|
834
|
-
...
|
|
835
|
-
(e) =>
|
|
832
|
+
...R.flatMap(
|
|
833
|
+
(e) => b.has(e.field) && !(o && o[e.field] != null && Number(o[e.field]) === b.get(e.field)) ? [
|
|
836
834
|
{
|
|
837
835
|
field: e.field,
|
|
838
836
|
label_override: e.label ?? null,
|
|
839
|
-
value:
|
|
837
|
+
value: b.get(e.field)
|
|
840
838
|
}
|
|
841
839
|
] : []
|
|
842
840
|
)
|
|
843
841
|
], ae = q.length, He = (e, n) => {
|
|
844
|
-
var
|
|
845
|
-
const l = (
|
|
842
|
+
var g;
|
|
843
|
+
const l = (g = _[e]) == null ? void 0 : g.type;
|
|
846
844
|
return l && ["integer", "bigInteger", "decimal", "float", "number"].includes(l) ? !0 : n != null && n !== "" && !Array.isArray(n) && !Number.isNaN(Number(n));
|
|
847
845
|
}, Se = (e) => {
|
|
848
846
|
var l;
|
|
849
847
|
const n = (l = _[e]) == null ? void 0 : l.options;
|
|
850
848
|
return n && typeof n == "object" && n.format === "currency" ? !0 : /amount|cost|price|total|budget|spend/i.test(e);
|
|
851
|
-
},
|
|
849
|
+
}, $e = (e, n) => Se(e) ? ye.format(Number(n)) : new Intl.NumberFormat("en-US").format(Number(n)), Ve = oe(() => {
|
|
852
850
|
if (r.cost_impact != null && Number(r.cost_impact) !== 0 || !o) return null;
|
|
853
851
|
for (const e of d) {
|
|
854
852
|
if (!Se(e.field)) continue;
|
|
855
|
-
const n = Number(
|
|
853
|
+
const n = Number(S[e.field]), l = Number(o[e.field]);
|
|
856
854
|
if (!Number.isNaN(n) && !Number.isNaN(l) && n !== l) return n - l;
|
|
857
855
|
}
|
|
858
856
|
return null;
|
|
859
|
-
}, [r.cost_impact, o, d,
|
|
857
|
+
}, [r.cost_impact, o, d, S]), ke = oe(() => {
|
|
860
858
|
if (!o) return null;
|
|
861
859
|
const e = [
|
|
862
|
-
...d.map((n) => [n.field, Number(
|
|
863
|
-
...
|
|
860
|
+
...d.map((n) => [n.field, Number(S[n.field])]),
|
|
861
|
+
...b.entries()
|
|
864
862
|
].flatMap(([n, l]) => {
|
|
865
|
-
const
|
|
866
|
-
return !Se(n) ||
|
|
863
|
+
const g = o[n];
|
|
864
|
+
return !Se(n) || g == null || g === "" ? [] : Number.isNaN(Number(g)) || Number.isNaN(l) ? [] : [{ field: n, previous: Number(g), next: l }];
|
|
867
865
|
});
|
|
868
866
|
return e.find((n) => n.previous !== n.next) ?? e[0] ?? null;
|
|
869
|
-
}, [o, d,
|
|
867
|
+
}, [o, d, S, b]), _e = kt(r, ke), qe = _e.previous != null || _e.next != null || _e.change != null, be = qe ? (ke == null ? void 0 : ke.field) ?? null : null, Ye = be ? ((je = q.find((e) => e.field === be)) == null ? void 0 : je.label_override) ?? ((Re = _[be]) == null ? void 0 : Re.label) ?? fe(be) : "Amount";
|
|
870
868
|
return /* @__PURE__ */ i(
|
|
871
869
|
"div",
|
|
872
870
|
{
|
|
873
|
-
className:
|
|
871
|
+
className: T(
|
|
874
872
|
"overflow-hidden rounded-lg border bg-white transition-shadow hover:shadow-sm dark:bg-card",
|
|
875
|
-
|
|
873
|
+
h ? "border-amber-300 dark:border-amber-500/40" : "border-slate-200 dark:border-border"
|
|
876
874
|
),
|
|
877
875
|
children: [
|
|
878
876
|
/* @__PURE__ */ i(
|
|
@@ -880,20 +878,20 @@ function jt({
|
|
|
880
878
|
{
|
|
881
879
|
type: "button",
|
|
882
880
|
className: "flex w-full items-start gap-3 px-4 py-3 text-left",
|
|
883
|
-
onClick: () =>
|
|
881
|
+
onClick: () => m((e) => !e),
|
|
884
882
|
children: [
|
|
885
|
-
/* @__PURE__ */ t("span", { className:
|
|
883
|
+
/* @__PURE__ */ t("span", { className: T("mt-0.5 h-2 w-2 shrink-0 rounded-full", w.dot) }),
|
|
886
884
|
/* @__PURE__ */ i("div", { className: "flex-1 min-w-0", children: [
|
|
887
885
|
/* @__PURE__ */ i("div", { className: "flex items-center gap-2 flex-wrap", children: [
|
|
888
886
|
/* @__PURE__ */ t("span", { className: "text-[13px] font-semibold text-slate-800 dark:text-slate-100 truncate", children: r.title }),
|
|
889
887
|
/* @__PURE__ */ t(
|
|
890
888
|
"span",
|
|
891
889
|
{
|
|
892
|
-
className:
|
|
890
|
+
className: T(
|
|
893
891
|
"inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-medium",
|
|
894
|
-
|
|
892
|
+
w.badge
|
|
895
893
|
),
|
|
896
|
-
children:
|
|
894
|
+
children: v
|
|
897
895
|
}
|
|
898
896
|
),
|
|
899
897
|
ae > 0 && /* @__PURE__ */ i("span", { className: "text-[11px] text-slate-400 dark:text-slate-500", children: [
|
|
@@ -904,14 +902,14 @@ function jt({
|
|
|
904
902
|
] }),
|
|
905
903
|
ze(r.cost_impact) ?? ze(Ve)
|
|
906
904
|
] }),
|
|
907
|
-
r.description &&
|
|
905
|
+
r.description && !$ && /* @__PURE__ */ t("p", { className: "mt-0.5 text-[12px] text-slate-500 dark:text-slate-400 line-clamp-1", children: _t(r.description) })
|
|
908
906
|
] }),
|
|
909
907
|
/* @__PURE__ */ t(
|
|
910
908
|
"span",
|
|
911
909
|
{
|
|
912
|
-
className:
|
|
910
|
+
className: T(
|
|
913
911
|
"shrink-0 text-[10px] text-slate-400 transition-transform",
|
|
914
|
-
|
|
912
|
+
$ && "rotate-180"
|
|
915
913
|
),
|
|
916
914
|
children: "▾"
|
|
917
915
|
}
|
|
@@ -919,7 +917,7 @@ function jt({
|
|
|
919
917
|
]
|
|
920
918
|
}
|
|
921
919
|
),
|
|
922
|
-
|
|
920
|
+
$ && /* @__PURE__ */ i("div", { className: "border-t border-slate-100 dark:border-border", children: [
|
|
923
921
|
/* @__PURE__ */ t(Mt, { addendum: r }),
|
|
924
922
|
(ae > 0 || qe) && /* @__PURE__ */ i("section", { className: "border-t border-slate-100 px-4 py-3.5 dark:border-border", children: [
|
|
925
923
|
/* @__PURE__ */ t("h4", { className: "mb-3 text-[12.5px] font-semibold text-slate-800 dark:text-slate-100", children: J ? "Changes" : "Proposed changes" }),
|
|
@@ -929,7 +927,7 @@ function jt({
|
|
|
929
927
|
/* @__PURE__ */ t("dd", { className: ce, children: /* @__PURE__ */ t(wt, { amounts: _e }) })
|
|
930
928
|
] }),
|
|
931
929
|
q.map((e) => {
|
|
932
|
-
var
|
|
930
|
+
var g;
|
|
933
931
|
const n = e.value;
|
|
934
932
|
if (e.field === be || Array.isArray(n) && A[e.field]) return null;
|
|
935
933
|
let l;
|
|
@@ -940,23 +938,23 @@ function jt({
|
|
|
940
938
|
else if (typeof n == "object")
|
|
941
939
|
l = JSON.stringify(n).slice(0, 60);
|
|
942
940
|
else if (He(e.field, n)) {
|
|
943
|
-
const
|
|
941
|
+
const F = Number(n), H = o == null ? void 0 : o[e.field], K = H != null && H !== "" && !Number.isNaN(Number(H)) ? Number(H) : null, B = K != null ? F - K : 0;
|
|
944
942
|
l = /* @__PURE__ */ i("span", { className: "inline-flex flex-wrap items-baseline gap-x-1.5 tabular-nums", children: [
|
|
945
|
-
K != null && K !==
|
|
943
|
+
K != null && K !== F && /* @__PURE__ */ t("span", { className: "text-slate-400 line-through decoration-slate-300 dark:text-slate-500 dark:decoration-slate-600", children: $e(e.field, K) }),
|
|
946
944
|
/* @__PURE__ */ i("span", { className: "font-medium text-foreground", children: [
|
|
947
|
-
K != null && K !==
|
|
948
|
-
|
|
945
|
+
K != null && K !== F && /* @__PURE__ */ t("span", { className: "mr-1 font-normal text-slate-400", "aria-hidden": "true", children: "→" }),
|
|
946
|
+
$e(e.field, F)
|
|
949
947
|
] }),
|
|
950
948
|
B !== 0 && /* @__PURE__ */ i(
|
|
951
949
|
"span",
|
|
952
950
|
{
|
|
953
|
-
className:
|
|
951
|
+
className: T(
|
|
954
952
|
"rounded-full px-1.5 py-px text-[10px] font-medium",
|
|
955
953
|
B > 0 ? "bg-emerald-50 text-emerald-700 dark:bg-emerald-500/10 dark:text-emerald-400" : "bg-red-50 text-red-600 dark:bg-red-500/10 dark:text-red-400"
|
|
956
954
|
),
|
|
957
955
|
children: [
|
|
958
956
|
B > 0 ? "+" : "−",
|
|
959
|
-
|
|
957
|
+
$e(e.field, Math.abs(B))
|
|
960
958
|
]
|
|
961
959
|
}
|
|
962
960
|
)
|
|
@@ -964,12 +962,12 @@ function jt({
|
|
|
964
962
|
} else
|
|
965
963
|
l = String(n);
|
|
966
964
|
return /* @__PURE__ */ i(Ce, { children: [
|
|
967
|
-
/* @__PURE__ */ t("dt", { className: de, children: e.label_override ?? ((
|
|
968
|
-
/* @__PURE__ */ t("dd", { className:
|
|
965
|
+
/* @__PURE__ */ t("dt", { className: de, children: e.label_override ?? ((g = _[e.field]) == null ? void 0 : g.label) ?? fe(e.field) }),
|
|
966
|
+
/* @__PURE__ */ t("dd", { className: T(ce, "break-words"), children: l })
|
|
969
967
|
] }, e.field);
|
|
970
968
|
}),
|
|
971
969
|
J && Object.entries(ee ?? {}).map(([e, n]) => {
|
|
972
|
-
var l,
|
|
970
|
+
var l, g;
|
|
973
971
|
return /* @__PURE__ */ i(Ce, { children: [
|
|
974
972
|
/* @__PURE__ */ t("dt", { className: de, children: ((l = _[e]) == null ? void 0 : l.label) ?? fe(e) }),
|
|
975
973
|
/* @__PURE__ */ t("dd", { className: ce, children: /* @__PURE__ */ t(
|
|
@@ -981,17 +979,17 @@ function jt({
|
|
|
981
979
|
proposed: n.after,
|
|
982
980
|
original: n.before,
|
|
983
981
|
ignoreMissing: !0,
|
|
984
|
-
label: ((
|
|
982
|
+
label: ((g = _[e]) == null ? void 0 : g.label) ?? fe(e)
|
|
985
983
|
}
|
|
986
984
|
) })
|
|
987
985
|
] }, `applied-${e}`);
|
|
988
986
|
}),
|
|
989
|
-
|
|
987
|
+
j.map(({ field: e, rel: n }) => {
|
|
990
988
|
var B, ge;
|
|
991
|
-
const l =
|
|
992
|
-
if (J || !Array.isArray(l) ||
|
|
989
|
+
const l = S[e], g = j.findIndex((ue) => ue.field === e), F = A[e] ?? ((B = P[g]) != null && B.isLoading ? null : []);
|
|
990
|
+
if (J || !Array.isArray(l) || !F || !(n != null && n.many_collection) || !n.many_field)
|
|
993
991
|
return null;
|
|
994
|
-
const H =
|
|
992
|
+
const H = c.find((ue) => ue.field === e), K = (H == null ? void 0 : H.label_override) ?? ((ge = _[e]) == null ? void 0 : ge.label) ?? fe(e);
|
|
995
993
|
return /* @__PURE__ */ i(Ce, { children: [
|
|
996
994
|
/* @__PURE__ */ t("dt", { className: de, children: K }),
|
|
997
995
|
/* @__PURE__ */ t("dd", { className: ce, children: /* @__PURE__ */ t(
|
|
@@ -1001,7 +999,7 @@ function jt({
|
|
|
1001
999
|
childCollection: n.many_collection,
|
|
1002
1000
|
fkField: n.many_field,
|
|
1003
1001
|
proposed: l,
|
|
1004
|
-
original:
|
|
1002
|
+
original: F,
|
|
1005
1003
|
label: K
|
|
1006
1004
|
}
|
|
1007
1005
|
) })
|
|
@@ -1011,7 +1009,7 @@ function jt({
|
|
|
1011
1009
|
] }),
|
|
1012
1010
|
r.workflow_template_id && /* @__PURE__ */ i("div", { className: "border-t border-slate-100 dark:border-border px-4 py-3.5", children: [
|
|
1013
1011
|
/* @__PURE__ */ t("h4", { className: "mb-3 text-[12.5px] font-semibold text-slate-800 dark:text-slate-100", children: "Workflow" }),
|
|
1014
|
-
/* @__PURE__ */ t(
|
|
1012
|
+
/* @__PURE__ */ t(Ft, { addendumId: r.id }),
|
|
1015
1013
|
re && /* @__PURE__ */ t("div", { className: "mt-2 flex items-center justify-end gap-2", children: r.status === "approved" ? r.legacy_id != null ? null : te ? /* @__PURE__ */ i("span", { className: "flex items-center gap-1.5", children: [
|
|
1016
1014
|
/* @__PURE__ */ t("span", { className: "text-[11px] text-amber-600 dark:text-amber-400", children: "Roll every applied change back?" }),
|
|
1017
1015
|
/* @__PURE__ */ t(
|
|
@@ -1159,62 +1157,62 @@ function jt({
|
|
|
1159
1157
|
}
|
|
1160
1158
|
function ar({
|
|
1161
1159
|
collection: r,
|
|
1162
|
-
item:
|
|
1163
|
-
addendumLayoutId:
|
|
1164
|
-
canCreate:
|
|
1165
|
-
onActiveCountChange:
|
|
1166
|
-
onApplied:
|
|
1167
|
-
onCreated:
|
|
1160
|
+
item: c,
|
|
1161
|
+
addendumLayoutId: N,
|
|
1162
|
+
canCreate: h = !0,
|
|
1163
|
+
onActiveCountChange: k,
|
|
1164
|
+
onApplied: u,
|
|
1165
|
+
onCreated: x,
|
|
1168
1166
|
defaultExpanded: _ = !0
|
|
1169
1167
|
}) {
|
|
1170
|
-
const f = xe(),
|
|
1168
|
+
const f = xe(), $ = Ue(), [m, v] = O(!1), [w, S] = O(!_), [D, j] = O(!1), {
|
|
1171
1169
|
data: P = [],
|
|
1172
1170
|
isLoading: J,
|
|
1173
1171
|
refetch: ee
|
|
1174
1172
|
} = V({
|
|
1175
|
-
queryKey: ["addendums", r,
|
|
1176
|
-
queryFn: () => f.request(
|
|
1173
|
+
queryKey: ["addendums", r, c],
|
|
1174
|
+
queryFn: () => f.request(U(`/addendums/${r}/${c}`)).then((p) => p.data ?? []),
|
|
1177
1175
|
// The form reads this key first (staleTime 30 s); with none here the panel,
|
|
1178
1176
|
// mounting just after, counted that answer stale and fetched it again.
|
|
1179
1177
|
// Live sync and the panel's own writes invalidate it.
|
|
1180
1178
|
staleTime: 3e4
|
|
1181
1179
|
}), { data: A, isLoading: G } = V({
|
|
1182
|
-
queryKey: ["addendum-layout", r,
|
|
1180
|
+
queryKey: ["addendum-layout", r, N ?? "default"],
|
|
1183
1181
|
queryFn: async () => {
|
|
1184
|
-
const
|
|
1185
|
-
return
|
|
1182
|
+
const p = await f.request(U("/collection-layouts", { collection: r })).then((a) => (a.data ?? []).filter((s) => s.layout_type === "addendum"));
|
|
1183
|
+
return N != null ? p.find((a) => a.id === N) ?? null : p[0] ?? null;
|
|
1186
1184
|
},
|
|
1187
1185
|
staleTime: 300 * 1e3
|
|
1188
|
-
}), M =
|
|
1186
|
+
}), M = N ?? (A == null ? void 0 : A.id) ?? null, te = !!M && (m || P.length > 0), { data: E = [], isPending: me } = V({
|
|
1189
1187
|
queryKey: ["addendum-layout-assignments", M],
|
|
1190
1188
|
queryFn: () => M ? f.request(
|
|
1191
|
-
|
|
1192
|
-
).then((
|
|
1189
|
+
U(`/collection-layouts/${M}/assignments`)
|
|
1190
|
+
).then((p) => p.data ?? []) : Promise.resolve([]),
|
|
1193
1191
|
enabled: te,
|
|
1194
1192
|
staleTime: 300 * 1e3
|
|
1195
1193
|
}), { data: X = [], isPending: W } = V({
|
|
1196
1194
|
queryKey: ["collection-fields", r, M],
|
|
1197
1195
|
queryFn: () => f.request(
|
|
1198
|
-
|
|
1196
|
+
U(
|
|
1199
1197
|
`/field-config/${r}`,
|
|
1200
1198
|
M ? { layout_id: String(M) } : void 0
|
|
1201
1199
|
)
|
|
1202
|
-
).then((
|
|
1200
|
+
).then((p) => p.data ?? []),
|
|
1203
1201
|
enabled: te,
|
|
1204
1202
|
staleTime: 300 * 1e3
|
|
1205
|
-
}), Y =
|
|
1203
|
+
}), Y = m && M != null && (me || W), { data: L = [] } = V({
|
|
1206
1204
|
queryKey: ["relations", r],
|
|
1207
|
-
queryFn: () => f.request(
|
|
1205
|
+
queryFn: () => f.request(U(`/data-model/relations/for/${r}`)).then((p) => p.data ?? []),
|
|
1208
1206
|
staleTime: 300 * 1e3
|
|
1209
1207
|
}), { data: re, isLoading: se } = V({
|
|
1210
|
-
queryKey: ["item", r,
|
|
1211
|
-
queryFn: () => f.request(
|
|
1212
|
-
enabled:
|
|
1208
|
+
queryKey: ["item", r, c],
|
|
1209
|
+
queryFn: () => f.request(U(`/items/${r}/${c}`)).then((p) => p.data ?? {}),
|
|
1210
|
+
enabled: m,
|
|
1213
1211
|
staleTime: 0
|
|
1214
1212
|
}), ne = () => {
|
|
1215
|
-
|
|
1216
|
-
}, ie = (
|
|
1217
|
-
|
|
1213
|
+
$.invalidateQueries({ queryKey: ["addendums", r, c] }), ee(), u == null || u();
|
|
1214
|
+
}, ie = (p) => {
|
|
1215
|
+
$.invalidateQueries({ queryKey: ["addendums", r, c] }), ee();
|
|
1218
1216
|
const a = E.find((d) => String(d.field) === "__pdf__");
|
|
1219
1217
|
let s = null;
|
|
1220
1218
|
if (a != null && a.overrides)
|
|
@@ -1223,67 +1221,67 @@ function ar({
|
|
|
1223
1221
|
} catch {
|
|
1224
1222
|
s = null;
|
|
1225
1223
|
}
|
|
1226
|
-
|
|
1224
|
+
x == null || x({ id: p, pdfSlot: s });
|
|
1227
1225
|
}, Z = E.filter(
|
|
1228
|
-
(
|
|
1229
|
-
),
|
|
1230
|
-
(
|
|
1231
|
-
).length,
|
|
1232
|
-
return
|
|
1233
|
-
var
|
|
1234
|
-
(
|
|
1235
|
-
}, [
|
|
1226
|
+
(p) => !String(p.field).startsWith("__") && (p.is_visible || p.is_visible === 1)
|
|
1227
|
+
), Q = P.filter(
|
|
1228
|
+
(p) => !["approved", "rejected", "reverted"].includes(p.status)
|
|
1229
|
+
).length, R = Me(k);
|
|
1230
|
+
return R.current = k, Be(() => {
|
|
1231
|
+
var p;
|
|
1232
|
+
(p = R.current) == null || p.call(R, Q);
|
|
1233
|
+
}, [Q]), !h && (J || P.length === 0) ? null : /* @__PURE__ */ i(Ne, { children: [
|
|
1236
1234
|
/* @__PURE__ */ i(
|
|
1237
1235
|
"div",
|
|
1238
1236
|
{
|
|
1239
|
-
className:
|
|
1237
|
+
className: T(
|
|
1240
1238
|
"overflow-hidden rounded-xl border bg-white dark:bg-card",
|
|
1241
|
-
|
|
1239
|
+
Q > 0 ? "border-amber-300 dark:border-amber-500/40" : "border-slate-200 dark:border-border"
|
|
1242
1240
|
),
|
|
1243
1241
|
children: [
|
|
1244
1242
|
/* @__PURE__ */ i(
|
|
1245
1243
|
"div",
|
|
1246
1244
|
{
|
|
1247
|
-
className:
|
|
1245
|
+
className: T(
|
|
1248
1246
|
"flex items-center justify-between px-4 py-3 cursor-pointer select-none",
|
|
1249
|
-
!
|
|
1247
|
+
!w && (Q > 0 ? "border-b border-amber-200 dark:border-amber-500/30" : "border-b border-slate-200 dark:border-border")
|
|
1250
1248
|
),
|
|
1251
|
-
onClick: () =>
|
|
1249
|
+
onClick: () => S((p) => !p),
|
|
1252
1250
|
children: [
|
|
1253
1251
|
/* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
|
|
1254
1252
|
/* @__PURE__ */ t(Ze, { className: "h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500" }),
|
|
1255
1253
|
/* @__PURE__ */ t("h3", { className: "text-[13px] font-medium text-slate-800 dark:text-slate-200", children: "Addendums" }),
|
|
1256
|
-
|
|
1254
|
+
Q > 0 && /* @__PURE__ */ i("span", { className: "inline-flex items-center gap-1 rounded-full bg-amber-50 px-2 py-0.5 text-[11px] font-medium text-amber-700 border border-amber-200 dark:bg-amber-500/10 dark:text-amber-400 dark:border-amber-500/20", children: [
|
|
1257
1255
|
/* @__PURE__ */ t("span", { className: "h-1.5 w-1.5 rounded-full bg-amber-400 animate-pulse" }),
|
|
1258
|
-
|
|
1256
|
+
Q,
|
|
1259
1257
|
" in review"
|
|
1260
1258
|
] }),
|
|
1261
|
-
P.length >= 2 && !
|
|
1259
|
+
P.length >= 2 && !w && /* @__PURE__ */ t(
|
|
1262
1260
|
"button",
|
|
1263
1261
|
{
|
|
1264
1262
|
type: "button",
|
|
1265
|
-
onClick: (
|
|
1266
|
-
|
|
1263
|
+
onClick: (p) => {
|
|
1264
|
+
p.stopPropagation(), j((a) => !a);
|
|
1267
1265
|
},
|
|
1268
|
-
className:
|
|
1266
|
+
className: T(
|
|
1269
1267
|
"ml-1 rounded-md border px-2 py-0.5 text-[11px] font-medium transition-colors",
|
|
1270
|
-
|
|
1268
|
+
D ? "border-nvr-cyan bg-nvr-cyan/10 text-[#0b7ea6] dark:text-nvr-cyan" : "border-slate-200 text-slate-500 hover:border-slate-400 hover:text-slate-700 dark:border-border dark:text-slate-400"
|
|
1271
1269
|
),
|
|
1272
1270
|
"data-tip": "Every addendum side by side — amount moved, fields touched, lines changed, running total",
|
|
1273
|
-
"aria-pressed":
|
|
1274
|
-
children:
|
|
1271
|
+
"aria-pressed": D,
|
|
1272
|
+
children: D ? "Cards" : "Compare"
|
|
1275
1273
|
}
|
|
1276
1274
|
)
|
|
1277
1275
|
] }),
|
|
1278
1276
|
/* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
|
|
1279
|
-
|
|
1277
|
+
h && (!(A != null && A.single_active_addendum) || Q === 0) && /* @__PURE__ */ t(
|
|
1280
1278
|
I,
|
|
1281
1279
|
{
|
|
1282
1280
|
size: "sm",
|
|
1283
1281
|
variant: "outline",
|
|
1284
1282
|
className: "h-7 text-[12px]",
|
|
1285
|
-
onClick: (
|
|
1286
|
-
|
|
1283
|
+
onClick: (p) => {
|
|
1284
|
+
p.stopPropagation(), v(!0);
|
|
1287
1285
|
},
|
|
1288
1286
|
children: "+ New Addendum"
|
|
1289
1287
|
}
|
|
@@ -1291,9 +1289,9 @@ function ar({
|
|
|
1291
1289
|
/* @__PURE__ */ t(
|
|
1292
1290
|
et,
|
|
1293
1291
|
{
|
|
1294
|
-
className:
|
|
1292
|
+
className: T(
|
|
1295
1293
|
"h-3.5 w-3.5 shrink-0 text-slate-400 transition-transform duration-150",
|
|
1296
|
-
|
|
1294
|
+
w && "-rotate-90"
|
|
1297
1295
|
)
|
|
1298
1296
|
}
|
|
1299
1297
|
)
|
|
@@ -1301,61 +1299,61 @@ function ar({
|
|
|
1301
1299
|
]
|
|
1302
1300
|
}
|
|
1303
1301
|
),
|
|
1304
|
-
!
|
|
1302
|
+
!w && !A && !G && /* @__PURE__ */ i("div", { className: "px-4 py-4 text-center", children: [
|
|
1305
1303
|
/* @__PURE__ */ t("p", { className: "text-[12px] text-slate-400", children: "No addendum form configured." }),
|
|
1306
1304
|
/* @__PURE__ */ t("p", { className: "text-[11px] text-slate-300 dark:text-slate-600", children: 'Create an "Addendum Form" layout in Data Model → Layouts to enable addendum creation.' })
|
|
1307
1305
|
] }),
|
|
1308
|
-
!
|
|
1306
|
+
!w && (A || G) && (J ? /* @__PURE__ */ i("div", { className: "p-4 space-y-2", children: [
|
|
1309
1307
|
/* @__PURE__ */ t(le, { className: "h-12 w-full" }),
|
|
1310
1308
|
/* @__PURE__ */ t(le, { className: "h-12 w-full" })
|
|
1311
1309
|
] }) : P.length === 0 ? /* @__PURE__ */ i("div", { className: "px-4 py-8 text-center", children: [
|
|
1312
1310
|
/* @__PURE__ */ t("p", { className: "text-[12px] text-slate-400 dark:text-slate-500", children: "No addendum attached to this record" }),
|
|
1313
1311
|
/* @__PURE__ */ t("p", { className: "mt-0.5 text-[11px] text-slate-300 dark:text-slate-600", children: "Addendums propose changes that go through a review process before being applied." })
|
|
1314
|
-
] }) :
|
|
1312
|
+
] }) : D && P.length >= 2 ? /* @__PURE__ */ t("div", { className: "p-3", children: /* @__PURE__ */ t(
|
|
1315
1313
|
Nt,
|
|
1316
1314
|
{
|
|
1317
1315
|
client: f,
|
|
1318
1316
|
addendums: P,
|
|
1319
1317
|
parentCollection: r,
|
|
1320
|
-
parentId:
|
|
1318
|
+
parentId: c,
|
|
1321
1319
|
relations: L,
|
|
1322
|
-
fieldMap: Object.fromEntries(X.map((
|
|
1320
|
+
fieldMap: Object.fromEntries(X.map((p) => [p.field, p]))
|
|
1323
1321
|
}
|
|
1324
|
-
) }) : /* @__PURE__ */ t("div", { className: "p-3 space-y-2", children: P.map((
|
|
1322
|
+
) }) : /* @__PURE__ */ t("div", { className: "p-3 space-y-2", children: P.map((p) => /* @__PURE__ */ t(
|
|
1325
1323
|
jt,
|
|
1326
1324
|
{
|
|
1327
|
-
addendum:
|
|
1325
|
+
addendum: p,
|
|
1328
1326
|
configuredFields: Z,
|
|
1329
1327
|
onRefresh: ne,
|
|
1330
|
-
isActive: !["approved", "rejected", "reverted"].includes(
|
|
1328
|
+
isActive: !["approved", "rejected", "reverted"].includes(p.status),
|
|
1331
1329
|
relations: L,
|
|
1332
1330
|
parentCollection: r,
|
|
1333
|
-
parentId:
|
|
1331
|
+
parentId: c,
|
|
1334
1332
|
fieldMap: Object.fromEntries(X.map((a) => [a.field, a]))
|
|
1335
1333
|
},
|
|
1336
|
-
|
|
1334
|
+
p.id
|
|
1337
1335
|
)) }))
|
|
1338
1336
|
]
|
|
1339
1337
|
}
|
|
1340
1338
|
),
|
|
1341
|
-
/* @__PURE__ */ t(xt, { open:
|
|
1339
|
+
/* @__PURE__ */ t(xt, { open: m, onOpenChange: v, children: /* @__PURE__ */ t(bt, { side: "right", className: "w-[80vw] sm:max-w-[80vw] p-0 flex flex-col", children: m && (se || Y) ? /* @__PURE__ */ i("div", { className: "flex flex-col gap-3 p-6", children: [
|
|
1342
1340
|
/* @__PURE__ */ t(le, { className: "h-6 w-48" }),
|
|
1343
1341
|
/* @__PURE__ */ t(le, { className: "h-9 w-full" }),
|
|
1344
1342
|
/* @__PURE__ */ t(le, { className: "h-9 w-full" }),
|
|
1345
1343
|
/* @__PURE__ */ t(le, { className: "h-9 w-full" }),
|
|
1346
1344
|
/* @__PURE__ */ t(le, { className: "h-9 w-3/4" })
|
|
1347
|
-
] }) :
|
|
1345
|
+
] }) : m && re ? /* @__PURE__ */ t(
|
|
1348
1346
|
At,
|
|
1349
1347
|
{
|
|
1350
1348
|
collection: r,
|
|
1351
|
-
itemId:
|
|
1349
|
+
itemId: c,
|
|
1352
1350
|
assignments: E,
|
|
1353
1351
|
workflowTemplateId: (A == null ? void 0 : A.workflow_template_id) ?? null,
|
|
1354
1352
|
resolvedLayoutId: M,
|
|
1355
1353
|
fields: X,
|
|
1356
1354
|
relations: L,
|
|
1357
1355
|
parentData: re,
|
|
1358
|
-
onClose: () =>
|
|
1356
|
+
onClose: () => v(!1),
|
|
1359
1357
|
onCreated: ie
|
|
1360
1358
|
}
|
|
1361
1359
|
) : null }) })
|