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