@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.
@@ -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 { FieldQueueFullError as te, projectedCustody as ne, projectedHolder as re } from "../utils/fieldQueue.js";
10
- import { browserStorage as o, useFieldQueue as ie } from "../hooks/useFieldQueue.js";
11
- import { fieldAssetCacheKey as ae, filterFieldAssets as oe, findFieldAsset as se, loadFieldAssets as ce, normalizeScannedTag as le, saveFieldAssets as ue, toFieldAsset as s } from "../utils/fieldAssetCache.js";
12
- import { useCallback as c, useEffect as l, useMemo as de, useRef as u, useState as d } from "react";
13
- import { ArrowDownToLine as fe, ArrowUpFromLine as pe, Camera as me, CloudOff as he, RefreshCw as ge, ScanLine as _e, Smartphone as ve, Trash2 as ye, Wifi as be } from "lucide-react";
14
- import { gql as f } from "@apollo/client";
15
- import { useApolloClient as xe } from "@apollo/client/react";
16
- import { jsx as p, jsxs as m } from "react/jsx-runtime";
17
- import { Button as h, GlassCard as g, Input as _, Label as v, PagePurpose as Se } from "@burdenoff/fe-libs/ui";
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 Ce = f`
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 y(e) {
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 we = f`
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
- `, Te = f`
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
- `, b = "assethandler.field.lastAssignee", Ee = 50;
64
- function De() {
78
+ `, x = "assethandler.field.lastAssignee", Ie = 50;
79
+ function Le() {
65
80
  try {
66
- return o()?.getItem(b) ?? "";
81
+ return o()?.getItem(x) ?? "";
67
82
  } catch {
68
83
  return "";
69
84
  }
70
85
  }
71
- function Oe(e) {
86
+ function Re(e) {
72
87
  try {
73
- o()?.setItem(b, e);
88
+ o()?.setItem(x, e);
74
89
  } catch {}
75
90
  }
76
- function x() {
91
+ function S() {
77
92
  let { workspaceId: e } = t();
78
- return /* @__PURE__ */ p(S, { workspaceId: e }, e || "default");
93
+ return /* @__PURE__ */ m(C, { workspaceId: e }, e || "default");
79
94
  }
80
- function S({ workspaceId: s }) {
81
- let f = a(), b = xe(), { currentUser: x } = t(), S = e((e) => e.refetchBootstrap), C = ae(s), [ke] = d(() => ce(o(), C).assets), [Ae, w] = d(!1), [T, E] = d(""), [D, je] = d(""), [O, Me] = d(null), [k, A] = d(null), [j, Ne] = d(De), [M, N] = d(""), [Pe, P] = d(!1), F = u(null), I = u(null), L = u(0), [Fe, Ie] = d(null), R = u(!1), z = u(0);
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 B = c(() => {
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
- b.query({
90
- query: Ce,
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(y);
95
- Ie(n), ue(o(), C, n);
134
+ let n = t.data.assets.map(b);
135
+ Qe(n), ve(o(), w, n);
96
136
  }, () => {});
97
- }, [b, C]), V = c(async (e, t) => {
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 (I.current = e.id, A(n), t) try {
104
- let t = await b.query({
105
- query: Te,
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 (I.current !== e.id) return;
149
+ if (Xe.current !== e.id) return;
110
150
  let n = t.data?.assetAssignments?.[0];
111
- A({
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
- }, [b]), { queue: H, pending: U, online: W, syncing: G, sendingId: K, persisted: Le, enqueue: Re, syncNow: ze, remove: Be, retry: Ve } = ie({
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: b,
159
+ client: x,
120
160
  onFlushed: (e) => {
121
- e.synced.length > 0 && (r.success(f("assethandler.field.synced", "{{count}} field action(s) synced", { count: e.synced.length })), S(), B());
122
- for (let t of e.rejected) r.error(f("assethandler.field.rejected", "Could not apply action for {{asset}}", { asset: t.assetName }), t.lastError);
123
- O && V(O, !0);
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
- W && B();
128
- }, [W, B]);
129
- let q = Fe ?? ke, J = c((e) => {
130
- L.current += 1, P(!1), Me(e), N(""), V(e, W);
131
- }, [V, W]), Y = c(async (e) => {
132
- let t = le(e);
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(f("assethandler.field.enterTag", "Enter a tag"), f("assethandler.field.enterTagHint", "Scan or type the asset tag to continue."));
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 = se(q, t);
179
+ let n = he(K, t);
138
180
  if (n) {
139
- J(n), E("");
181
+ q(n), A("");
140
182
  return;
141
183
  }
142
- if (!W) {
143
- r.warning(f("assethandler.field.unknownOffline", "Tag not in the offline registry"), f("assethandler.field.unknownOfflineHint", "Reconnect once so this device can refresh its copy of the registry."));
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
- P(!0);
190
+ I(!0);
149
191
  try {
150
- let e = await b.query({
151
- query: we,
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(f("assethandler.field.notFound", "No asset found"), f("assethandler.field.notFoundHint", "No asset matches tag \"{{tag}}\".", { tag: t }));
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
- J(y(n)), E("");
203
+ q(b(n)), A("");
162
204
  } catch (e) {
163
205
  if (!a()) return;
164
- r.error(f("assethandler.field.lookupFailed", "Tag lookup failed"), e instanceof Error ? e.message : void 0);
206
+ r.error(p("assethandler.field.lookupFailed", "Tag lookup failed"), e instanceof Error ? e.message : void 0);
165
207
  } finally {
166
- a() && P(!1);
208
+ a() && I(!1);
167
209
  }
168
210
  }, [
169
- b,
211
+ x,
212
+ K,
213
+ G,
170
214
  q,
171
- W,
172
- J,
173
- f
174
- ]), He = c((e) => {
175
- w(!1), Y(e);
176
- }, [Y]), X = O ? ne(H, O.tagId, k?.checkedOut ?? !1) : !1, Z = O ? re(H, O.tagId, k?.holder ?? "") : "", Ue = (e) => {
177
- if (!O) return;
178
- let t = j.trim();
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
- Re({
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 te) {
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
- e === "CHECK_OUT" && Oe(t), N(""), W || r.info(f("assethandler.field.savedOffline", "Saved on this device"), f("assethandler.field.savedOfflineHint", "It will sync automatically when you are back online.")), F.current?.focus();
199
- }, Q = de(() => oe(q, D).slice(0, Ee), [q, D]), $ = (e) => e === "CHECK_OUT" ? f("assethandler.field.kind.checkOut", "Check out") : f("assethandler.field.kind.checkIn", "Check in");
200
- return /* @__PURE__ */ m("div", {
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__ */ p(i, {
277
+ /* @__PURE__ */ m(i, {
204
278
  hero: !0,
205
- icon: ve,
206
- title: f("assethandler.field.title", "Field Mode"),
207
- description: f("assethandler.field.description", "Scan, check out and check in assets on site, with or without signal")
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__ */ p(Se, { children: f("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.") }),
210
- /* @__PURE__ */ m("div", {
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", W ? "bg-status-success-subtle text-status-success-text" : "bg-status-warning-subtle text-status-warning-text"),
214
- children: [/* @__PURE__ */ m("span", {
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: [p(W ? be : he, {
290
+ children: [m(G ? De : Se, {
217
291
  className: "h-4 w-4",
218
292
  "aria-hidden": "true"
219
- }), W ? f("assethandler.field.online", "Online") : f("assethandler.field.offline", "Offline — actions are saved on this device")]
220
- }), /* @__PURE__ */ m("span", {
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__ */ p("span", {
296
+ children: [/* @__PURE__ */ m("span", {
223
297
  "data-testid": "field-pending-count",
224
- children: f("assethandler.field.pending", "{{count}} waiting to sync", { count: U })
225
- }), U > 0 && W ? /* @__PURE__ */ m(h, {
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 ze(),
230
- disabled: G,
231
- children: [/* @__PURE__ */ p(ge, {
232
- className: n("h-4 w-4", G && "animate-spin"),
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
- }), f("assethandler.field.syncNow", "Sync now")]
308
+ }), p("assethandler.field.syncNow", "Sync now")]
235
309
  }) : null]
236
310
  })]
237
311
  }),
238
- Le ? null : /* @__PURE__ */ p("p", {
312
+ nt ? null : /* @__PURE__ */ m("p", {
239
313
  role: "alert",
240
314
  className: "text-sm text-status-error-text",
241
- children: f("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.")
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__ */ m(g, {
317
+ /* @__PURE__ */ h(_, {
244
318
  className: "space-y-3 p-4",
245
319
  children: [
246
- /* @__PURE__ */ m("div", {
320
+ /* @__PURE__ */ h("div", {
247
321
  className: "flex items-center gap-2 text-sm font-semibold text-text-primary",
248
- children: [/* @__PURE__ */ p(_e, {
322
+ children: [/* @__PURE__ */ m(we, {
249
323
  className: "h-4 w-4",
250
324
  "aria-hidden": "true"
251
- }), f("assethandler.field.scanTitle", "Scan a tag")]
325
+ }), p("assethandler.field.scanTitle", "Scan a tag")]
252
326
  }),
253
- Ae ? /* @__PURE__ */ p(ee, {
254
- onDetected: He,
255
- onClose: () => w(!1)
256
- }) : /* @__PURE__ */ m(h, {
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: () => w(!0),
260
- children: [/* @__PURE__ */ p(me, {
333
+ onClick: () => k(!0),
334
+ children: [/* @__PURE__ */ m(xe, {
261
335
  className: "h-5 w-5",
262
336
  "aria-hidden": "true"
263
- }), f("assethandler.field.openCamera", "Scan with camera")]
337
+ }), p("assethandler.field.openCamera", "Scan with camera")]
264
338
  }),
265
- /* @__PURE__ */ m("form", {
339
+ /* @__PURE__ */ h("form", {
266
340
  className: "flex gap-2",
267
341
  onSubmit: (e) => {
268
- e.preventDefault(), Y(T);
342
+ e.preventDefault(), J(He);
269
343
  },
270
344
  children: [
271
- /* @__PURE__ */ p(v, {
345
+ /* @__PURE__ */ m(y, {
272
346
  htmlFor: "field-tag-input",
273
347
  className: "sr-only",
274
- children: f("assethandler.field.tagLabel", "Asset tag")
348
+ children: p("assethandler.field.tagLabel", "Asset tag")
275
349
  }),
276
- /* @__PURE__ */ p(_, {
350
+ /* @__PURE__ */ m(v, {
277
351
  id: "field-tag-input",
278
- ref: F,
279
- value: T,
280
- onChange: (e) => E(e.target.value),
281
- placeholder: f("assethandler.field.tagPlaceholder", "Type or scan a tag"),
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__ */ p(h, {
361
+ /* @__PURE__ */ m(g, {
288
362
  type: "submit",
289
363
  variant: "outline",
290
364
  className: "h-12",
291
- disabled: Pe,
292
- children: f("assethandler.field.find", "Find")
365
+ disabled: Je,
366
+ children: p("assethandler.field.find", "Find")
293
367
  })
294
368
  ]
295
369
  })
296
370
  ]
297
371
  }),
298
- O ? /* @__PURE__ */ m(g, {
372
+ M ? /* @__PURE__ */ h(_, {
299
373
  className: "space-y-4 p-4",
300
374
  "data-testid": "field-selected-asset",
301
375
  children: [
302
- /* @__PURE__ */ m("div", {
376
+ /* @__PURE__ */ h("div", {
303
377
  className: "flex items-start justify-between gap-3",
304
- children: [/* @__PURE__ */ m("div", {
378
+ children: [/* @__PURE__ */ h("div", {
305
379
  className: "min-w-0",
306
- children: [/* @__PURE__ */ p("h2", {
380
+ children: [/* @__PURE__ */ m("h2", {
307
381
  className: "truncate text-lg font-semibold text-text-primary",
308
- children: O.name
309
- }), /* @__PURE__ */ m("p", {
382
+ children: M.name
383
+ }), /* @__PURE__ */ h("p", {
310
384
  className: "truncate text-xs text-text-secondary",
311
- children: [f("assethandler.field.tagValue", "Tag {{tag}}", { tag: O.tagId }), O.location ? ` · ${O.location}` : ""]
385
+ children: [p("assethandler.field.tagValue", "Tag {{tag}}", { tag: M.tagId }), M.location ? ` · ${M.location}` : ""]
312
386
  })]
313
- }), /* @__PURE__ */ p("span", {
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 ? f("assethandler.field.checkedOut", "Checked out") : f("assethandler.field.available", "Available")
390
+ children: X ? p("assethandler.field.checkedOut", "Checked out") : p("assethandler.field.available", "Available")
317
391
  })]
318
392
  }),
319
- Z && X ? /* @__PURE__ */ p("p", {
393
+ ut && X ? /* @__PURE__ */ m("p", {
320
394
  className: "text-sm text-text-secondary",
321
- children: f("assethandler.field.heldBy", "Held by {{holder}}", { holder: Z })
395
+ children: p("assethandler.field.heldBy", "Held by {{holder}}", { holder: ut })
322
396
  }) : null,
323
- k && !k.confirmed ? /* @__PURE__ */ p("p", {
397
+ N && !N.confirmed ? /* @__PURE__ */ m("p", {
324
398
  className: "text-xs text-text-secondary",
325
- children: f("assethandler.field.unconfirmed", "Custody shown from this device’s last sync; the server confirms it when the action syncs.")
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__ */ m("div", {
401
+ X ? null : /* @__PURE__ */ h("div", {
328
402
  className: "space-y-1",
329
- children: [/* @__PURE__ */ p(v, {
403
+ children: [/* @__PURE__ */ m(y, {
330
404
  htmlFor: "field-assignee",
331
- children: f("assethandler.field.assignee", "Checking out to")
332
- }), /* @__PURE__ */ p(_, {
405
+ children: p("assethandler.field.assignee", "Checking out to")
406
+ }), /* @__PURE__ */ m(v, {
333
407
  id: "field-assignee",
334
- value: j,
335
- onChange: (e) => Ne(e.target.value),
336
- placeholder: x?.email ?? "name@company.com",
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__ */ m("div", {
415
+ /* @__PURE__ */ h("div", {
342
416
  className: "space-y-1",
343
- children: [/* @__PURE__ */ p(v, {
417
+ children: [/* @__PURE__ */ m(y, {
344
418
  htmlFor: "field-notes",
345
- children: f("assethandler.field.notes", "Notes (optional)")
346
- }), /* @__PURE__ */ p(_, {
419
+ children: p("assethandler.field.notes", "Notes (optional)")
420
+ }), /* @__PURE__ */ m(v, {
347
421
  id: "field-notes",
348
- value: M,
349
- onChange: (e) => N(e.target.value),
350
- placeholder: f("assethandler.field.notesPlaceholder", "Condition, location, job…"),
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__ */ m("div", {
428
+ /* @__PURE__ */ h("div", {
355
429
  className: "grid grid-cols-2 gap-3",
356
- children: [/* @__PURE__ */ m(h, {
430
+ children: [/* @__PURE__ */ h(g, {
357
431
  type: "button",
358
432
  className: "h-14 text-base",
359
433
  variant: X ? "outline" : "default",
360
- onClick: () => Ue("CHECK_OUT"),
361
- children: [/* @__PURE__ */ p(pe, {
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__ */ m(h, {
439
+ }), /* @__PURE__ */ h(g, {
366
440
  type: "button",
367
441
  className: "h-14 text-base",
368
442
  variant: X ? "default" : "outline",
369
- onClick: () => Ue("CHECK_IN"),
370
- children: [/* @__PURE__ */ p(fe, {
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
- H.length > 0 ? /* @__PURE__ */ m(g, {
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__ */ p("h2", {
483
+ children: [/* @__PURE__ */ m("h2", {
382
484
  className: "text-sm font-semibold text-text-primary",
383
- children: f("assethandler.field.queueTitle", "On this device")
384
- }), /* @__PURE__ */ p("ul", {
485
+ children: p("assethandler.field.queueTitle", "On this device")
486
+ }), /* @__PURE__ */ m("ul", {
385
487
  className: "divide-y divide-border-seam",
386
- children: H.map((e) => /* @__PURE__ */ m("li", {
488
+ children: W.map((e) => /* @__PURE__ */ h("li", {
387
489
  className: "flex items-center justify-between gap-3 py-2",
388
- children: [/* @__PURE__ */ m("div", {
490
+ children: [/* @__PURE__ */ h("div", {
389
491
  className: "min-w-0",
390
- children: [/* @__PURE__ */ m("p", {
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__ */ p("p", {
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 ?? f("assethandler.field.refused", "Refused by the server") : e.id === K ? f("assethandler.field.sending", "Sending…") : new Date(e.scannedAt).toLocaleString()
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__ */ m("div", {
503
+ }), /* @__PURE__ */ h("div", {
402
504
  className: "flex shrink-0 gap-1",
403
- children: [e.state === "rejected" ? /* @__PURE__ */ p(h, {
505
+ children: [e.state === "rejected" ? /* @__PURE__ */ m(g, {
404
506
  type: "button",
405
507
  size: "sm",
406
508
  variant: "outline",
407
- onClick: () => Ve(e.id),
408
- children: f("assethandler.field.retry", "Retry")
409
- }) : null, /* @__PURE__ */ p(h, {
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: () => Be(e.id),
414
- disabled: e.id === K,
415
- "aria-label": f("assethandler.field.discard", "Discard queued action"),
416
- children: /* @__PURE__ */ p(ye, {
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__ */ m(g, {
527
+ /* @__PURE__ */ h(_, {
426
528
  className: "space-y-3 p-4",
427
529
  children: [
428
- /* @__PURE__ */ p(v, {
530
+ /* @__PURE__ */ m(y, {
429
531
  htmlFor: "field-search",
430
532
  className: "text-sm font-semibold",
431
- children: f("assethandler.field.browse", "Browse assets")
533
+ children: p("assethandler.field.browse", "Browse assets")
432
534
  }),
433
- /* @__PURE__ */ p(_, {
535
+ /* @__PURE__ */ m(v, {
434
536
  id: "field-search",
435
- value: D,
436
- onChange: (e) => je(e.target.value),
437
- placeholder: f("assethandler.field.searchPlaceholder", "Name, tag, location or holder"),
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__ */ p("p", {
542
+ Q.length === 0 ? /* @__PURE__ */ m("p", {
441
543
  className: "py-4 text-center text-sm text-text-secondary",
442
- children: q.length === 0 ? f("assethandler.field.noAssets", "No assets on this device yet. Open this page once while online to load the registry.") : f("assethandler.field.noMatches", "No assets match your search.")
443
- }) : /* @__PURE__ */ p("ul", {
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__ */ p("li", { children: /* @__PURE__ */ m("button", {
548
+ children: Q.map((e) => /* @__PURE__ */ m("li", { children: /* @__PURE__ */ h("button", {
447
549
  type: "button",
448
- onClick: () => J(e),
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", O?.id === e.id && "border-action-primary-bg"),
450
- children: [/* @__PURE__ */ m("span", {
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__ */ p("span", {
554
+ children: [/* @__PURE__ */ m("span", {
453
555
  className: "block truncate text-sm font-medium text-text-primary",
454
556
  children: e.name
455
- }), /* @__PURE__ */ m("span", {
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__ */ p("span", {
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 { x as FieldModePage };
573
+ export { S as FieldModePage };
472
574
 
473
575
  //# sourceMappingURL=FieldModePage.js.map