@burdenoff/microfe-assethandler 2026.1103.3 → 2026.1107.2
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/assethandler/components/FieldWorkOrderItem.d.ts +27 -0
- package/dist/assethandler/components/FieldWorkOrderItem.d.ts.map +1 -0
- package/dist/assethandler/components/FieldWorkOrderItem.js +168 -0
- package/dist/assethandler/components/FieldWorkOrderItem.js.map +1 -0
- package/dist/assethandler/hooks/useFieldQueue.d.ts +3 -0
- package/dist/assethandler/hooks/useFieldQueue.d.ts.map +1 -1
- package/dist/assethandler/hooks/useFieldQueue.js +113 -47
- package/dist/assethandler/hooks/useFieldQueue.js.map +1 -1
- package/dist/assethandler/pages/FieldModePage.d.ts +8 -0
- package/dist/assethandler/pages/FieldModePage.d.ts.map +1 -1
- package/dist/assethandler/pages/FieldModePage.js +301 -199
- package/dist/assethandler/pages/FieldModePage.js.map +1 -1
- package/dist/assethandler/utils/fieldQueue.d.ts +37 -3
- package/dist/assethandler/utils/fieldQueue.d.ts.map +1 -1
- package/dist/assethandler/utils/fieldQueue.js +75 -42
- package/dist/assethandler/utils/fieldQueue.js.map +1 -1
- package/dist/assethandler/utils/fieldWorkOrders.d.ts +80 -0
- package/dist/assethandler/utils/fieldWorkOrders.d.ts.map +1 -0
- package/dist/assethandler/utils/fieldWorkOrders.js +109 -0
- package/dist/assethandler/utils/fieldWorkOrders.js.map +1 -0
- package/package.json +1 -1
|
@@ -6,17 +6,20 @@ import { SectionHeader as i } from "../components/SectionHeader.js";
|
|
|
6
6
|
import "../components/index.js";
|
|
7
7
|
import { useTr as a } from "../hooks/useTr.js";
|
|
8
8
|
import { CameraTagScanner as ee } from "../components/CameraTagScanner.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
9
|
+
import { fieldWorkOrderCacheKey as te, loadFieldWorkOrders as ne, saveFieldWorkOrders as re, technicianIdentities as ie, toFieldWorkOrder as ae, workOrdersForAsset as oe } from "../utils/fieldWorkOrders.js";
|
|
10
|
+
import { FieldWorkOrderItem as se } from "../components/FieldWorkOrderItem.js";
|
|
11
|
+
import { FieldQueueFullError as ce, projectedCustody as le, projectedHolder as ue, projectedWorkOrderStatus as de } from "../utils/fieldQueue.js";
|
|
12
|
+
import { browserStorage as o, useFieldQueue as fe } from "../hooks/useFieldQueue.js";
|
|
13
|
+
import { fieldAssetCacheKey as pe, filterFieldAssets as me, findFieldAsset as he, loadFieldAssets as ge, normalizeScannedTag as _e, saveFieldAssets as ve, toFieldAsset as s } from "../utils/fieldAssetCache.js";
|
|
14
|
+
import { useCallback as c, useEffect as l, useMemo as u, useRef as d, useState as f } from "react";
|
|
15
|
+
import { ArrowDownToLine as ye, ArrowUpFromLine as be, Camera as xe, CloudOff as Se, RefreshCw as Ce, ScanLine as we, Smartphone as Te, Trash2 as Ee, Wifi as De, Wrench as Oe } from "lucide-react";
|
|
16
|
+
import { useSearchParams as ke } from "react-router";
|
|
17
|
+
import { gql as p } from "@apollo/client";
|
|
18
|
+
import { useApolloClient as Ae } from "@apollo/client/react";
|
|
19
|
+
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
20
|
+
import { Button as g, GlassCard as _, Input as v, Label as y, PagePurpose as je } from "@burdenoff/fe-libs/ui";
|
|
18
21
|
//#region src/assethandler/pages/FieldModePage.tsx
|
|
19
|
-
var
|
|
22
|
+
var Me = p`
|
|
20
23
|
query AssetHandlerFieldAssets {
|
|
21
24
|
assets {
|
|
22
25
|
id
|
|
@@ -29,7 +32,7 @@ var Ce = f`
|
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
34
|
`;
|
|
32
|
-
function
|
|
35
|
+
function b(e) {
|
|
33
36
|
return s({
|
|
34
37
|
id: e.id,
|
|
35
38
|
name: e.name,
|
|
@@ -40,7 +43,19 @@ function y(e) {
|
|
|
40
43
|
status: e.status
|
|
41
44
|
});
|
|
42
45
|
}
|
|
43
|
-
var
|
|
46
|
+
var Ne = p`
|
|
47
|
+
query AssetHandlerFieldWorkOrders($filter: WorkOrderFilterInput, $limit: Int) {
|
|
48
|
+
workOrders(filter: $filter, pagination: { limit: $limit }) {
|
|
49
|
+
id
|
|
50
|
+
title
|
|
51
|
+
status
|
|
52
|
+
priority
|
|
53
|
+
assetId
|
|
54
|
+
assignedTo
|
|
55
|
+
checklist
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
`, Pe = p`
|
|
44
59
|
query AssetHandlerFieldAssetByTag($tagId: String!) {
|
|
45
60
|
assetByTag(tagId: $tagId) {
|
|
46
61
|
id
|
|
@@ -52,7 +67,7 @@ var we = f`
|
|
|
52
67
|
assignedTo
|
|
53
68
|
}
|
|
54
69
|
}
|
|
55
|
-
`,
|
|
70
|
+
`, Fe = p`
|
|
56
71
|
query AssetHandlerFieldLatestAssignment($assetId: ID!) {
|
|
57
72
|
assetAssignments(assetId: $assetId, pagination: { limit: 1 }) {
|
|
58
73
|
id
|
|
@@ -60,360 +75,447 @@ var we = f`
|
|
|
60
75
|
assignedTo
|
|
61
76
|
}
|
|
62
77
|
}
|
|
63
|
-
`,
|
|
64
|
-
function
|
|
78
|
+
`, x = "assethandler.field.lastAssignee", Ie = 50;
|
|
79
|
+
function Le() {
|
|
65
80
|
try {
|
|
66
|
-
return o()?.getItem(
|
|
81
|
+
return o()?.getItem(x) ?? "";
|
|
67
82
|
} catch {
|
|
68
83
|
return "";
|
|
69
84
|
}
|
|
70
85
|
}
|
|
71
|
-
function
|
|
86
|
+
function Re(e) {
|
|
72
87
|
try {
|
|
73
|
-
o()?.setItem(
|
|
88
|
+
o()?.setItem(x, e);
|
|
74
89
|
} catch {}
|
|
75
90
|
}
|
|
76
|
-
function
|
|
91
|
+
function S() {
|
|
77
92
|
let { workspaceId: e } = t();
|
|
78
|
-
return /* @__PURE__ */
|
|
93
|
+
return /* @__PURE__ */ m(C, { workspaceId: e }, e || "default");
|
|
79
94
|
}
|
|
80
|
-
function
|
|
81
|
-
let
|
|
95
|
+
function C({ workspaceId: s }) {
|
|
96
|
+
let p = a(), x = Ae(), { currentUser: S } = t(), C = e((e) => e.refetchBootstrap), w = pe(s), [ze] = f(() => ge(o(), w).assets), T = te(s), [E, Be] = f(() => ne(o(), T).workOrders), D = u(() => ie(S), [S]), O = D.join("\0"), [Ve, k] = f(!1), [He, A] = f(""), [j, Ue] = f(""), [M, We] = f(null), [N, Ge] = f(null), [Ke, qe] = f(Le), [P, F] = f(""), [Je, I] = f(!1), Ye = d(null), Xe = d(null), L = d(0), [Ze, Qe] = f(null), R = d(!1), z = d(0), B = d(0);
|
|
82
97
|
l(() => (R.current = !0, () => {
|
|
83
|
-
R.current = !1, z.current += 1;
|
|
98
|
+
R.current = !1, z.current += 1, B.current += 1;
|
|
84
99
|
}), []);
|
|
85
|
-
let
|
|
100
|
+
let V = c(() => {
|
|
101
|
+
if (!R.current) return;
|
|
102
|
+
let e = O ? O.split("\0") : [];
|
|
103
|
+
if (e.length === 0) return;
|
|
104
|
+
B.current += 1;
|
|
105
|
+
let t = B.current;
|
|
106
|
+
x.query({
|
|
107
|
+
query: Ne,
|
|
108
|
+
variables: {
|
|
109
|
+
filter: {
|
|
110
|
+
openOnly: !0,
|
|
111
|
+
assignedToIn: e
|
|
112
|
+
},
|
|
113
|
+
limit: 100
|
|
114
|
+
},
|
|
115
|
+
fetchPolicy: "network-only"
|
|
116
|
+
}).then((e) => {
|
|
117
|
+
if (!R.current || B.current !== t || !e.data?.workOrders) return;
|
|
118
|
+
let n = e.data.workOrders.map(ae);
|
|
119
|
+
Be(n), re(o(), T, n);
|
|
120
|
+
}, () => {});
|
|
121
|
+
}, [
|
|
122
|
+
x,
|
|
123
|
+
O,
|
|
124
|
+
T
|
|
125
|
+
]), H = c(() => {
|
|
86
126
|
if (!R.current) return;
|
|
87
127
|
z.current += 1;
|
|
88
128
|
let e = z.current;
|
|
89
|
-
|
|
90
|
-
query:
|
|
129
|
+
x.query({
|
|
130
|
+
query: Me,
|
|
91
131
|
fetchPolicy: "network-only"
|
|
92
132
|
}).then((t) => {
|
|
93
133
|
if (!R.current || z.current !== e || !t.data?.assets) return;
|
|
94
|
-
let n = t.data.assets.map(
|
|
95
|
-
|
|
134
|
+
let n = t.data.assets.map(b);
|
|
135
|
+
Qe(n), ve(o(), w, n);
|
|
96
136
|
}, () => {});
|
|
97
|
-
}, [
|
|
137
|
+
}, [x, w]), U = c(async (e, t) => {
|
|
98
138
|
let n = {
|
|
99
139
|
checkedOut: e.assignedTo !== "",
|
|
100
140
|
holder: e.assignedTo,
|
|
101
141
|
confirmed: !1
|
|
102
142
|
};
|
|
103
|
-
if (
|
|
104
|
-
let t = await
|
|
105
|
-
query:
|
|
143
|
+
if (Xe.current = e.id, Ge(n), t) try {
|
|
144
|
+
let t = await x.query({
|
|
145
|
+
query: Fe,
|
|
106
146
|
variables: { assetId: e.id },
|
|
107
147
|
fetchPolicy: "network-only"
|
|
108
148
|
});
|
|
109
|
-
if (
|
|
149
|
+
if (Xe.current !== e.id) return;
|
|
110
150
|
let n = t.data?.assetAssignments?.[0];
|
|
111
|
-
|
|
151
|
+
Ge({
|
|
112
152
|
checkedOut: !!n && n.status !== "RETURNED",
|
|
113
153
|
holder: n && n.status !== "RETURNED" ? n.assignedTo : "",
|
|
114
154
|
confirmed: !0
|
|
115
155
|
});
|
|
116
156
|
} catch {}
|
|
117
|
-
}, [
|
|
157
|
+
}, [x]), { queue: W, pending: $e, online: G, syncing: et, sendingId: tt, persisted: nt, enqueue: rt, syncNow: it, remove: at, retry: ot } = fe({
|
|
118
158
|
workspaceId: s,
|
|
119
|
-
client:
|
|
159
|
+
client: x,
|
|
120
160
|
onFlushed: (e) => {
|
|
121
|
-
e.synced.length > 0 && (r.success(
|
|
122
|
-
for (let t of e.rejected) r.error(
|
|
123
|
-
|
|
161
|
+
e.synced.length > 0 && (r.success(p("assethandler.field.synced", "{{count}} field action(s) synced", { count: e.synced.length })), C(), H(), V());
|
|
162
|
+
for (let t of e.rejected) r.error(p("assethandler.field.rejected", "Could not apply action for {{asset}}", { asset: t.assetName }), t.lastError);
|
|
163
|
+
M && U(M, !0);
|
|
124
164
|
}
|
|
125
165
|
});
|
|
126
166
|
l(() => {
|
|
127
|
-
|
|
128
|
-
}, [
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
167
|
+
G && H();
|
|
168
|
+
}, [G, H]), l(() => {
|
|
169
|
+
G && V();
|
|
170
|
+
}, [G, V]);
|
|
171
|
+
let K = Ze ?? ze, q = c((e) => {
|
|
172
|
+
L.current += 1, I(!1), We(e), F(""), U(e, G);
|
|
173
|
+
}, [U, G]), J = c(async (e) => {
|
|
174
|
+
let t = _e(e);
|
|
133
175
|
if (!t) {
|
|
134
|
-
r.warning(
|
|
176
|
+
r.warning(p("assethandler.field.enterTag", "Enter a tag"), p("assethandler.field.enterTagHint", "Scan or type the asset tag to continue."));
|
|
135
177
|
return;
|
|
136
178
|
}
|
|
137
|
-
let n =
|
|
179
|
+
let n = he(K, t);
|
|
138
180
|
if (n) {
|
|
139
|
-
|
|
181
|
+
q(n), A("");
|
|
140
182
|
return;
|
|
141
183
|
}
|
|
142
|
-
if (!
|
|
143
|
-
r.warning(
|
|
184
|
+
if (!G) {
|
|
185
|
+
r.warning(p("assethandler.field.unknownOffline", "Tag not in the offline registry"), p("assethandler.field.unknownOfflineHint", "Reconnect once so this device can refresh its copy of the registry."));
|
|
144
186
|
return;
|
|
145
187
|
}
|
|
146
188
|
L.current += 1;
|
|
147
189
|
let i = L.current, a = () => L.current === i;
|
|
148
|
-
|
|
190
|
+
I(!0);
|
|
149
191
|
try {
|
|
150
|
-
let e = await
|
|
151
|
-
query:
|
|
192
|
+
let e = await x.query({
|
|
193
|
+
query: Pe,
|
|
152
194
|
variables: { tagId: t },
|
|
153
195
|
fetchPolicy: "network-only"
|
|
154
196
|
});
|
|
155
197
|
if (!a()) return;
|
|
156
198
|
let n = e.data?.assetByTag;
|
|
157
199
|
if (!n) {
|
|
158
|
-
r.error(
|
|
200
|
+
r.error(p("assethandler.field.notFound", "No asset found"), p("assethandler.field.notFoundHint", "No asset matches tag \"{{tag}}\".", { tag: t }));
|
|
159
201
|
return;
|
|
160
202
|
}
|
|
161
|
-
|
|
203
|
+
q(b(n)), A("");
|
|
162
204
|
} catch (e) {
|
|
163
205
|
if (!a()) return;
|
|
164
|
-
r.error(
|
|
206
|
+
r.error(p("assethandler.field.lookupFailed", "Tag lookup failed"), e instanceof Error ? e.message : void 0);
|
|
165
207
|
} finally {
|
|
166
|
-
a() &&
|
|
208
|
+
a() && I(!1);
|
|
167
209
|
}
|
|
168
210
|
}, [
|
|
169
|
-
|
|
211
|
+
x,
|
|
212
|
+
K,
|
|
213
|
+
G,
|
|
170
214
|
q,
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
if (e === "CHECK_OUT" && !t) {
|
|
180
|
-
r.warning(f("assethandler.field.assigneeRequired", "Recipient required"), f("assethandler.field.assigneeRequiredHint", "Enter who is receiving the asset."));
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
215
|
+
p
|
|
216
|
+
]), [st] = ke(), Y = st.get("tag")?.trim() ?? "", ct = d("");
|
|
217
|
+
l(() => {
|
|
218
|
+
!Y || ct.current === Y || (ct.current = Y, J(Y));
|
|
219
|
+
}, [Y, J]);
|
|
220
|
+
let lt = c((e) => {
|
|
221
|
+
k(!1), J(e);
|
|
222
|
+
}, [J]), X = M ? le(W, M.tagId, N?.checkedOut ?? !1) : !1, ut = M ? ue(W, M.tagId, N?.holder ?? "") : "", Z = (e) => {
|
|
183
223
|
try {
|
|
184
|
-
|
|
185
|
-
kind: e,
|
|
186
|
-
tagId: O.tagId,
|
|
187
|
-
assetName: O.name,
|
|
188
|
-
...e === "CHECK_OUT" ? { assignedTo: t } : {},
|
|
189
|
-
...M.trim() ? { notes: M.trim() } : {}
|
|
190
|
-
});
|
|
224
|
+
rt(e);
|
|
191
225
|
} catch (e) {
|
|
192
|
-
if (e instanceof
|
|
193
|
-
r.error(f("assethandler.field.queueFull", "Offline queue is full"), f("assethandler.field.queueFullHint", "Reconnect to sync the queued actions before recording more."));
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
226
|
+
if (e instanceof ce) return r.error(p("assethandler.field.queueFull", "Offline queue is full"), p("assethandler.field.queueFullHint", "Reconnect to sync the queued actions before recording more.")), !1;
|
|
196
227
|
throw e;
|
|
197
228
|
}
|
|
198
|
-
|
|
199
|
-
},
|
|
200
|
-
|
|
229
|
+
return G || r.info(p("assethandler.field.savedOffline", "Saved on this device"), p("assethandler.field.savedOfflineHint", "It will sync automatically when you are back online.")), !0;
|
|
230
|
+
}, dt = (e) => {
|
|
231
|
+
if (!M) return;
|
|
232
|
+
let t = Ke.trim();
|
|
233
|
+
if (e === "CHECK_OUT" && !t) {
|
|
234
|
+
r.warning(p("assethandler.field.assigneeRequired", "Recipient required"), p("assethandler.field.assigneeRequiredHint", "Enter who is receiving the asset."));
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
Z({
|
|
238
|
+
kind: e,
|
|
239
|
+
tagId: M.tagId,
|
|
240
|
+
assetName: M.name,
|
|
241
|
+
...e === "CHECK_OUT" ? { assignedTo: t } : {},
|
|
242
|
+
...P.trim() ? { notes: P.trim() } : {}
|
|
243
|
+
}) && (e === "CHECK_OUT" && Re(t), F(""), Ye.current?.focus());
|
|
244
|
+
}, ft = u(() => new Map(K.map((e) => [e.id, e])), [K]), pt = (e) => ({
|
|
245
|
+
tagId: ft.get(e.assetId)?.tagId ?? "",
|
|
246
|
+
assetName: e.title,
|
|
247
|
+
workOrderId: e.id
|
|
248
|
+
}), mt = (e) => {
|
|
249
|
+
Z({
|
|
250
|
+
kind: "WO_START",
|
|
251
|
+
...pt(e)
|
|
252
|
+
});
|
|
253
|
+
}, ht = (e, t) => Z({
|
|
254
|
+
kind: "WO_COMPLETE",
|
|
255
|
+
...pt(e),
|
|
256
|
+
...t.notes ? { notes: t.notes } : {},
|
|
257
|
+
...t.actualCost === void 0 ? {} : { actualCost: t.actualCost },
|
|
258
|
+
checklist: t.checklist
|
|
259
|
+
}), gt = (e, t) => /* @__PURE__ */ m(se, {
|
|
260
|
+
workOrder: e,
|
|
261
|
+
projectedStatus: de(W, e.id, e.status),
|
|
262
|
+
queued: W.some((t) => t.workOrderId === e.id && t.state === "pending"),
|
|
263
|
+
assetName: t ? ft.get(e.assetId)?.name : void 0,
|
|
264
|
+
onStart: mt,
|
|
265
|
+
onComplete: ht
|
|
266
|
+
}, e.id), _t = M ? oe(E, M.id) : [], Q = u(() => me(K, j).slice(0, Ie), [K, j]), $ = (e) => {
|
|
267
|
+
switch (e) {
|
|
268
|
+
case "CHECK_OUT": return p("assethandler.field.kind.checkOut", "Check out");
|
|
269
|
+
case "CHECK_IN": return p("assethandler.field.kind.checkIn", "Check in");
|
|
270
|
+
case "WO_START": return p("assethandler.field.kind.woStart", "Start work");
|
|
271
|
+
case "WO_COMPLETE": return p("assethandler.field.kind.woComplete", "Complete work order");
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
return /* @__PURE__ */ h("div", {
|
|
201
275
|
className: "mx-auto max-w-2xl space-y-4 p-3 sm:p-6",
|
|
202
276
|
children: [
|
|
203
|
-
/* @__PURE__ */
|
|
277
|
+
/* @__PURE__ */ m(i, {
|
|
204
278
|
hero: !0,
|
|
205
|
-
icon:
|
|
206
|
-
title:
|
|
207
|
-
description:
|
|
279
|
+
icon: Te,
|
|
280
|
+
title: p("assethandler.field.title", "Field Mode"),
|
|
281
|
+
description: p("assethandler.field.description", "Scan, check out and check in assets on site, with or without signal")
|
|
208
282
|
}),
|
|
209
|
-
/* @__PURE__ */
|
|
210
|
-
/* @__PURE__ */
|
|
283
|
+
/* @__PURE__ */ m(je, { children: p("assethandler.field.purpose", "Built for the phone in your hand. Scan a tag to open the asset, then check it out or in with one tap. Actions are saved on this device first and sync automatically, so a dead spot never loses a record.") }),
|
|
284
|
+
/* @__PURE__ */ h("div", {
|
|
211
285
|
role: "status",
|
|
212
286
|
"data-testid": "field-connectivity",
|
|
213
|
-
className: n("flex flex-wrap items-center justify-between gap-2 rounded-xl px-3 py-2 text-sm",
|
|
214
|
-
children: [/* @__PURE__ */
|
|
287
|
+
className: n("flex flex-wrap items-center justify-between gap-2 rounded-xl px-3 py-2 text-sm", G ? "bg-status-success-subtle text-status-success-text" : "bg-status-warning-subtle text-status-warning-text"),
|
|
288
|
+
children: [/* @__PURE__ */ h("span", {
|
|
215
289
|
className: "flex items-center gap-2 font-medium",
|
|
216
|
-
children: [
|
|
290
|
+
children: [m(G ? De : Se, {
|
|
217
291
|
className: "h-4 w-4",
|
|
218
292
|
"aria-hidden": "true"
|
|
219
|
-
}),
|
|
220
|
-
}), /* @__PURE__ */
|
|
293
|
+
}), G ? p("assethandler.field.online", "Online") : p("assethandler.field.offline", "Offline — actions are saved on this device")]
|
|
294
|
+
}), /* @__PURE__ */ h("span", {
|
|
221
295
|
className: "flex items-center gap-2",
|
|
222
|
-
children: [/* @__PURE__ */
|
|
296
|
+
children: [/* @__PURE__ */ m("span", {
|
|
223
297
|
"data-testid": "field-pending-count",
|
|
224
|
-
children:
|
|
225
|
-
}),
|
|
298
|
+
children: p("assethandler.field.pending", "{{count}} waiting to sync", { count: $e })
|
|
299
|
+
}), $e > 0 && G ? /* @__PURE__ */ h(g, {
|
|
226
300
|
type: "button",
|
|
227
301
|
size: "sm",
|
|
228
302
|
variant: "outline",
|
|
229
|
-
onClick: () => void
|
|
230
|
-
disabled:
|
|
231
|
-
children: [/* @__PURE__ */
|
|
232
|
-
className: n("h-4 w-4",
|
|
303
|
+
onClick: () => void it(),
|
|
304
|
+
disabled: et,
|
|
305
|
+
children: [/* @__PURE__ */ m(Ce, {
|
|
306
|
+
className: n("h-4 w-4", et && "animate-spin"),
|
|
233
307
|
"aria-hidden": "true"
|
|
234
|
-
}),
|
|
308
|
+
}), p("assethandler.field.syncNow", "Sync now")]
|
|
235
309
|
}) : null]
|
|
236
310
|
})]
|
|
237
311
|
}),
|
|
238
|
-
|
|
312
|
+
nt ? null : /* @__PURE__ */ m("p", {
|
|
239
313
|
role: "alert",
|
|
240
314
|
className: "text-sm text-status-error-text",
|
|
241
|
-
children:
|
|
315
|
+
children: p("assethandler.field.notPersisted", "This browser is not letting the app save data, so queued actions will be lost if you close the page. Stay on this page until they sync.")
|
|
242
316
|
}),
|
|
243
|
-
/* @__PURE__ */
|
|
317
|
+
/* @__PURE__ */ h(_, {
|
|
244
318
|
className: "space-y-3 p-4",
|
|
245
319
|
children: [
|
|
246
|
-
/* @__PURE__ */
|
|
320
|
+
/* @__PURE__ */ h("div", {
|
|
247
321
|
className: "flex items-center gap-2 text-sm font-semibold text-text-primary",
|
|
248
|
-
children: [/* @__PURE__ */
|
|
322
|
+
children: [/* @__PURE__ */ m(we, {
|
|
249
323
|
className: "h-4 w-4",
|
|
250
324
|
"aria-hidden": "true"
|
|
251
|
-
}),
|
|
325
|
+
}), p("assethandler.field.scanTitle", "Scan a tag")]
|
|
252
326
|
}),
|
|
253
|
-
|
|
254
|
-
onDetected:
|
|
255
|
-
onClose: () =>
|
|
256
|
-
}) : /* @__PURE__ */
|
|
327
|
+
Ve ? /* @__PURE__ */ m(ee, {
|
|
328
|
+
onDetected: lt,
|
|
329
|
+
onClose: () => k(!1)
|
|
330
|
+
}) : /* @__PURE__ */ h(g, {
|
|
257
331
|
type: "button",
|
|
258
332
|
className: "h-14 w-full text-base",
|
|
259
|
-
onClick: () =>
|
|
260
|
-
children: [/* @__PURE__ */
|
|
333
|
+
onClick: () => k(!0),
|
|
334
|
+
children: [/* @__PURE__ */ m(xe, {
|
|
261
335
|
className: "h-5 w-5",
|
|
262
336
|
"aria-hidden": "true"
|
|
263
|
-
}),
|
|
337
|
+
}), p("assethandler.field.openCamera", "Scan with camera")]
|
|
264
338
|
}),
|
|
265
|
-
/* @__PURE__ */
|
|
339
|
+
/* @__PURE__ */ h("form", {
|
|
266
340
|
className: "flex gap-2",
|
|
267
341
|
onSubmit: (e) => {
|
|
268
|
-
e.preventDefault(),
|
|
342
|
+
e.preventDefault(), J(He);
|
|
269
343
|
},
|
|
270
344
|
children: [
|
|
271
|
-
/* @__PURE__ */
|
|
345
|
+
/* @__PURE__ */ m(y, {
|
|
272
346
|
htmlFor: "field-tag-input",
|
|
273
347
|
className: "sr-only",
|
|
274
|
-
children:
|
|
348
|
+
children: p("assethandler.field.tagLabel", "Asset tag")
|
|
275
349
|
}),
|
|
276
|
-
/* @__PURE__ */
|
|
350
|
+
/* @__PURE__ */ m(v, {
|
|
277
351
|
id: "field-tag-input",
|
|
278
|
-
ref:
|
|
279
|
-
value:
|
|
280
|
-
onChange: (e) =>
|
|
281
|
-
placeholder:
|
|
352
|
+
ref: Ye,
|
|
353
|
+
value: He,
|
|
354
|
+
onChange: (e) => A(e.target.value),
|
|
355
|
+
placeholder: p("assethandler.field.tagPlaceholder", "Type or scan a tag"),
|
|
282
356
|
autoComplete: "off",
|
|
283
357
|
autoCapitalize: "off",
|
|
284
358
|
enterKeyHint: "search",
|
|
285
359
|
className: "h-12 flex-1"
|
|
286
360
|
}),
|
|
287
|
-
/* @__PURE__ */
|
|
361
|
+
/* @__PURE__ */ m(g, {
|
|
288
362
|
type: "submit",
|
|
289
363
|
variant: "outline",
|
|
290
364
|
className: "h-12",
|
|
291
|
-
disabled:
|
|
292
|
-
children:
|
|
365
|
+
disabled: Je,
|
|
366
|
+
children: p("assethandler.field.find", "Find")
|
|
293
367
|
})
|
|
294
368
|
]
|
|
295
369
|
})
|
|
296
370
|
]
|
|
297
371
|
}),
|
|
298
|
-
|
|
372
|
+
M ? /* @__PURE__ */ h(_, {
|
|
299
373
|
className: "space-y-4 p-4",
|
|
300
374
|
"data-testid": "field-selected-asset",
|
|
301
375
|
children: [
|
|
302
|
-
/* @__PURE__ */
|
|
376
|
+
/* @__PURE__ */ h("div", {
|
|
303
377
|
className: "flex items-start justify-between gap-3",
|
|
304
|
-
children: [/* @__PURE__ */
|
|
378
|
+
children: [/* @__PURE__ */ h("div", {
|
|
305
379
|
className: "min-w-0",
|
|
306
|
-
children: [/* @__PURE__ */
|
|
380
|
+
children: [/* @__PURE__ */ m("h2", {
|
|
307
381
|
className: "truncate text-lg font-semibold text-text-primary",
|
|
308
|
-
children:
|
|
309
|
-
}), /* @__PURE__ */
|
|
382
|
+
children: M.name
|
|
383
|
+
}), /* @__PURE__ */ h("p", {
|
|
310
384
|
className: "truncate text-xs text-text-secondary",
|
|
311
|
-
children: [
|
|
385
|
+
children: [p("assethandler.field.tagValue", "Tag {{tag}}", { tag: M.tagId }), M.location ? ` · ${M.location}` : ""]
|
|
312
386
|
})]
|
|
313
|
-
}), /* @__PURE__ */
|
|
387
|
+
}), /* @__PURE__ */ m("span", {
|
|
314
388
|
"data-testid": "field-custody",
|
|
315
389
|
className: n("shrink-0 rounded-full px-2.5 py-0.5 text-xs font-medium", X ? "bg-status-warning-subtle text-status-warning-text" : "bg-status-success-subtle text-status-success-text"),
|
|
316
|
-
children: X ?
|
|
390
|
+
children: X ? p("assethandler.field.checkedOut", "Checked out") : p("assethandler.field.available", "Available")
|
|
317
391
|
})]
|
|
318
392
|
}),
|
|
319
|
-
|
|
393
|
+
ut && X ? /* @__PURE__ */ m("p", {
|
|
320
394
|
className: "text-sm text-text-secondary",
|
|
321
|
-
children:
|
|
395
|
+
children: p("assethandler.field.heldBy", "Held by {{holder}}", { holder: ut })
|
|
322
396
|
}) : null,
|
|
323
|
-
|
|
397
|
+
N && !N.confirmed ? /* @__PURE__ */ m("p", {
|
|
324
398
|
className: "text-xs text-text-secondary",
|
|
325
|
-
children:
|
|
399
|
+
children: p("assethandler.field.unconfirmed", "Custody shown from this device’s last sync; the server confirms it when the action syncs.")
|
|
326
400
|
}) : null,
|
|
327
|
-
X ? null : /* @__PURE__ */
|
|
401
|
+
X ? null : /* @__PURE__ */ h("div", {
|
|
328
402
|
className: "space-y-1",
|
|
329
|
-
children: [/* @__PURE__ */
|
|
403
|
+
children: [/* @__PURE__ */ m(y, {
|
|
330
404
|
htmlFor: "field-assignee",
|
|
331
|
-
children:
|
|
332
|
-
}), /* @__PURE__ */
|
|
405
|
+
children: p("assethandler.field.assignee", "Checking out to")
|
|
406
|
+
}), /* @__PURE__ */ m(v, {
|
|
333
407
|
id: "field-assignee",
|
|
334
|
-
value:
|
|
335
|
-
onChange: (e) =>
|
|
336
|
-
placeholder:
|
|
408
|
+
value: Ke,
|
|
409
|
+
onChange: (e) => qe(e.target.value),
|
|
410
|
+
placeholder: S?.email ?? "name@company.com",
|
|
337
411
|
autoComplete: "email",
|
|
338
412
|
className: "h-12"
|
|
339
413
|
})]
|
|
340
414
|
}),
|
|
341
|
-
/* @__PURE__ */
|
|
415
|
+
/* @__PURE__ */ h("div", {
|
|
342
416
|
className: "space-y-1",
|
|
343
|
-
children: [/* @__PURE__ */
|
|
417
|
+
children: [/* @__PURE__ */ m(y, {
|
|
344
418
|
htmlFor: "field-notes",
|
|
345
|
-
children:
|
|
346
|
-
}), /* @__PURE__ */
|
|
419
|
+
children: p("assethandler.field.notes", "Notes (optional)")
|
|
420
|
+
}), /* @__PURE__ */ m(v, {
|
|
347
421
|
id: "field-notes",
|
|
348
|
-
value:
|
|
349
|
-
onChange: (e) =>
|
|
350
|
-
placeholder:
|
|
422
|
+
value: P,
|
|
423
|
+
onChange: (e) => F(e.target.value),
|
|
424
|
+
placeholder: p("assethandler.field.notesPlaceholder", "Condition, location, job…"),
|
|
351
425
|
className: "h-12"
|
|
352
426
|
})]
|
|
353
427
|
}),
|
|
354
|
-
/* @__PURE__ */
|
|
428
|
+
/* @__PURE__ */ h("div", {
|
|
355
429
|
className: "grid grid-cols-2 gap-3",
|
|
356
|
-
children: [/* @__PURE__ */
|
|
430
|
+
children: [/* @__PURE__ */ h(g, {
|
|
357
431
|
type: "button",
|
|
358
432
|
className: "h-14 text-base",
|
|
359
433
|
variant: X ? "outline" : "default",
|
|
360
|
-
onClick: () =>
|
|
361
|
-
children: [/* @__PURE__ */
|
|
434
|
+
onClick: () => dt("CHECK_OUT"),
|
|
435
|
+
children: [/* @__PURE__ */ m(be, {
|
|
362
436
|
className: "h-5 w-5",
|
|
363
437
|
"aria-hidden": "true"
|
|
364
438
|
}), $("CHECK_OUT")]
|
|
365
|
-
}), /* @__PURE__ */
|
|
439
|
+
}), /* @__PURE__ */ h(g, {
|
|
366
440
|
type: "button",
|
|
367
441
|
className: "h-14 text-base",
|
|
368
442
|
variant: X ? "default" : "outline",
|
|
369
|
-
onClick: () =>
|
|
370
|
-
children: [/* @__PURE__ */
|
|
443
|
+
onClick: () => dt("CHECK_IN"),
|
|
444
|
+
children: [/* @__PURE__ */ m(ye, {
|
|
371
445
|
className: "h-5 w-5",
|
|
372
446
|
"aria-hidden": "true"
|
|
373
447
|
}), $("CHECK_IN")]
|
|
374
448
|
})]
|
|
375
|
-
})
|
|
449
|
+
}),
|
|
450
|
+
_t.length > 0 ? /* @__PURE__ */ h("div", {
|
|
451
|
+
className: "space-y-2",
|
|
452
|
+
"data-testid": "field-asset-work-orders",
|
|
453
|
+
children: [/* @__PURE__ */ m("h3", {
|
|
454
|
+
className: "text-sm font-semibold text-text-primary",
|
|
455
|
+
children: p("assethandler.field.wo.forAsset", "Your work orders on this asset")
|
|
456
|
+
}), /* @__PURE__ */ m("ul", {
|
|
457
|
+
className: "space-y-2",
|
|
458
|
+
children: _t.map((e) => gt(e, !1))
|
|
459
|
+
})]
|
|
460
|
+
}) : null
|
|
376
461
|
]
|
|
377
462
|
}) : null,
|
|
378
|
-
|
|
463
|
+
/* @__PURE__ */ h(_, {
|
|
464
|
+
className: "space-y-3 p-4",
|
|
465
|
+
"data-testid": "field-work-orders",
|
|
466
|
+
children: [/* @__PURE__ */ h("h2", {
|
|
467
|
+
className: "flex items-center gap-2 text-sm font-semibold text-text-primary",
|
|
468
|
+
children: [/* @__PURE__ */ m(Oe, {
|
|
469
|
+
className: "h-4 w-4",
|
|
470
|
+
"aria-hidden": "true"
|
|
471
|
+
}), p("assethandler.field.wo.title", "My open work orders")]
|
|
472
|
+
}), E.length === 0 ? /* @__PURE__ */ m("p", {
|
|
473
|
+
className: "py-2 text-center text-sm text-text-secondary",
|
|
474
|
+
children: D.length === 0 ? p("assethandler.field.wo.noIdentity", "Sign in to see the work orders assigned to you.") : p("assethandler.field.wo.empty", "No open work orders are assigned to you. Open this page while online to refresh them.")
|
|
475
|
+
}) : /* @__PURE__ */ m("ul", {
|
|
476
|
+
className: "space-y-2",
|
|
477
|
+
children: E.map((e) => gt(e, !0))
|
|
478
|
+
})]
|
|
479
|
+
}),
|
|
480
|
+
W.length > 0 ? /* @__PURE__ */ h(_, {
|
|
379
481
|
className: "space-y-2 p-4",
|
|
380
482
|
"data-testid": "field-queue",
|
|
381
|
-
children: [/* @__PURE__ */
|
|
483
|
+
children: [/* @__PURE__ */ m("h2", {
|
|
382
484
|
className: "text-sm font-semibold text-text-primary",
|
|
383
|
-
children:
|
|
384
|
-
}), /* @__PURE__ */
|
|
485
|
+
children: p("assethandler.field.queueTitle", "On this device")
|
|
486
|
+
}), /* @__PURE__ */ m("ul", {
|
|
385
487
|
className: "divide-y divide-border-seam",
|
|
386
|
-
children:
|
|
488
|
+
children: W.map((e) => /* @__PURE__ */ h("li", {
|
|
387
489
|
className: "flex items-center justify-between gap-3 py-2",
|
|
388
|
-
children: [/* @__PURE__ */
|
|
490
|
+
children: [/* @__PURE__ */ h("div", {
|
|
389
491
|
className: "min-w-0",
|
|
390
|
-
children: [/* @__PURE__ */
|
|
492
|
+
children: [/* @__PURE__ */ h("p", {
|
|
391
493
|
className: "truncate text-sm text-text-primary",
|
|
392
494
|
children: [
|
|
393
495
|
$(e.kind),
|
|
394
496
|
" · ",
|
|
395
497
|
e.assetName
|
|
396
498
|
]
|
|
397
|
-
}), /* @__PURE__ */
|
|
499
|
+
}), /* @__PURE__ */ m("p", {
|
|
398
500
|
className: n("truncate text-xs", e.state === "rejected" ? "text-status-error-text" : "text-text-secondary"),
|
|
399
|
-
children: e.state === "rejected" ? e.lastError ??
|
|
501
|
+
children: e.state === "rejected" ? e.lastError ?? p("assethandler.field.refused", "Refused by the server") : e.id === tt ? p("assethandler.field.sending", "Sending…") : new Date(e.scannedAt).toLocaleString()
|
|
400
502
|
})]
|
|
401
|
-
}), /* @__PURE__ */
|
|
503
|
+
}), /* @__PURE__ */ h("div", {
|
|
402
504
|
className: "flex shrink-0 gap-1",
|
|
403
|
-
children: [e.state === "rejected" ? /* @__PURE__ */
|
|
505
|
+
children: [e.state === "rejected" ? /* @__PURE__ */ m(g, {
|
|
404
506
|
type: "button",
|
|
405
507
|
size: "sm",
|
|
406
508
|
variant: "outline",
|
|
407
|
-
onClick: () =>
|
|
408
|
-
children:
|
|
409
|
-
}) : null, /* @__PURE__ */
|
|
509
|
+
onClick: () => ot(e.id),
|
|
510
|
+
children: p("assethandler.field.retry", "Retry")
|
|
511
|
+
}) : null, /* @__PURE__ */ m(g, {
|
|
410
512
|
type: "button",
|
|
411
513
|
size: "icon",
|
|
412
514
|
variant: "ghost",
|
|
413
|
-
onClick: () =>
|
|
414
|
-
disabled: e.id ===
|
|
415
|
-
"aria-label":
|
|
416
|
-
children: /* @__PURE__ */
|
|
515
|
+
onClick: () => at(e.id),
|
|
516
|
+
disabled: e.id === tt,
|
|
517
|
+
"aria-label": p("assethandler.field.discard", "Discard queued action"),
|
|
518
|
+
children: /* @__PURE__ */ m(Ee, {
|
|
417
519
|
className: "h-4 w-4",
|
|
418
520
|
"aria-hidden": "true"
|
|
419
521
|
})
|
|
@@ -422,41 +524,41 @@ function S({ workspaceId: s }) {
|
|
|
422
524
|
}, e.id))
|
|
423
525
|
})]
|
|
424
526
|
}) : null,
|
|
425
|
-
/* @__PURE__ */
|
|
527
|
+
/* @__PURE__ */ h(_, {
|
|
426
528
|
className: "space-y-3 p-4",
|
|
427
529
|
children: [
|
|
428
|
-
/* @__PURE__ */
|
|
530
|
+
/* @__PURE__ */ m(y, {
|
|
429
531
|
htmlFor: "field-search",
|
|
430
532
|
className: "text-sm font-semibold",
|
|
431
|
-
children:
|
|
533
|
+
children: p("assethandler.field.browse", "Browse assets")
|
|
432
534
|
}),
|
|
433
|
-
/* @__PURE__ */
|
|
535
|
+
/* @__PURE__ */ m(v, {
|
|
434
536
|
id: "field-search",
|
|
435
|
-
value:
|
|
436
|
-
onChange: (e) =>
|
|
437
|
-
placeholder:
|
|
537
|
+
value: j,
|
|
538
|
+
onChange: (e) => Ue(e.target.value),
|
|
539
|
+
placeholder: p("assethandler.field.searchPlaceholder", "Name, tag, location or holder"),
|
|
438
540
|
className: "h-12"
|
|
439
541
|
}),
|
|
440
|
-
Q.length === 0 ? /* @__PURE__ */
|
|
542
|
+
Q.length === 0 ? /* @__PURE__ */ m("p", {
|
|
441
543
|
className: "py-4 text-center text-sm text-text-secondary",
|
|
442
|
-
children:
|
|
443
|
-
}) : /* @__PURE__ */
|
|
544
|
+
children: K.length === 0 ? p("assethandler.field.noAssets", "No assets on this device yet. Open this page once while online to load the registry.") : p("assethandler.field.noMatches", "No assets match your search.")
|
|
545
|
+
}) : /* @__PURE__ */ m("ul", {
|
|
444
546
|
className: "space-y-2",
|
|
445
547
|
"data-testid": "field-asset-list",
|
|
446
|
-
children: Q.map((e) => /* @__PURE__ */
|
|
548
|
+
children: Q.map((e) => /* @__PURE__ */ m("li", { children: /* @__PURE__ */ h("button", {
|
|
447
549
|
type: "button",
|
|
448
|
-
onClick: () =>
|
|
449
|
-
className: n("flex min-h-14 w-full items-center justify-between gap-3 rounded-xl border border-border-seam px-3 py-2 text-left transition-colors hover:bg-bg-sunken",
|
|
450
|
-
children: [/* @__PURE__ */
|
|
550
|
+
onClick: () => q(e),
|
|
551
|
+
className: n("flex min-h-14 w-full items-center justify-between gap-3 rounded-xl border border-border-seam px-3 py-2 text-left transition-colors hover:bg-bg-sunken", M?.id === e.id && "border-action-primary-bg"),
|
|
552
|
+
children: [/* @__PURE__ */ h("span", {
|
|
451
553
|
className: "min-w-0",
|
|
452
|
-
children: [/* @__PURE__ */
|
|
554
|
+
children: [/* @__PURE__ */ m("span", {
|
|
453
555
|
className: "block truncate text-sm font-medium text-text-primary",
|
|
454
556
|
children: e.name
|
|
455
|
-
}), /* @__PURE__ */
|
|
557
|
+
}), /* @__PURE__ */ h("span", {
|
|
456
558
|
className: "block truncate text-xs text-text-secondary",
|
|
457
559
|
children: [e.assetTag || e.tagId, e.location ? ` · ${e.location}` : ""]
|
|
458
560
|
})]
|
|
459
|
-
}), e.assignedTo ? /* @__PURE__ */
|
|
561
|
+
}), e.assignedTo ? /* @__PURE__ */ m("span", {
|
|
460
562
|
className: "max-w-[40%] shrink-0 truncate rounded-full bg-status-warning-subtle px-2 py-0.5 text-[11px] text-status-warning-text",
|
|
461
563
|
children: e.assignedTo
|
|
462
564
|
}) : null]
|
|
@@ -468,6 +570,6 @@ function S({ workspaceId: s }) {
|
|
|
468
570
|
});
|
|
469
571
|
}
|
|
470
572
|
//#endregion
|
|
471
|
-
export {
|
|
573
|
+
export { S as FieldModePage };
|
|
472
574
|
|
|
473
575
|
//# sourceMappingURL=FieldModePage.js.map
|