@burdenoff/microfe-healthybowl 2026.710.19 → 2026.710.21

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.
Files changed (58) hide show
  1. package/dist/generated/wspace-operations.js +476 -318
  2. package/dist/generated/wspace-operations.js.map +1 -1
  3. package/dist/generated/wspace-types.js.map +1 -1
  4. package/dist/healthybowl/HealthyBowlRoot.js +99 -82
  5. package/dist/healthybowl/HealthyBowlRoot.js.map +1 -1
  6. package/dist/healthybowl/HealthyBowlRoutes.js +103 -79
  7. package/dist/healthybowl/HealthyBowlRoutes.js.map +1 -1
  8. package/dist/healthybowl/hooks/useHealthyBowlData.js +2 -0
  9. package/dist/healthybowl/hooks/useHealthyBowlData.js.map +1 -1
  10. package/dist/healthybowl/hooks/useTracePortal.js +138 -0
  11. package/dist/healthybowl/hooks/useTracePortal.js.map +1 -0
  12. package/dist/healthybowl/index.js +1 -0
  13. package/dist/healthybowl/offline/OfflineStatusPill.js +30 -0
  14. package/dist/healthybowl/offline/OfflineStatusPill.js.map +1 -0
  15. package/dist/healthybowl/offline/OfflineSyncProvider.js +235 -0
  16. package/dist/healthybowl/offline/OfflineSyncProvider.js.map +1 -0
  17. package/dist/healthybowl/offline/geolocation.js +31 -0
  18. package/dist/healthybowl/offline/geolocation.js.map +1 -0
  19. package/dist/healthybowl/offline/graphql.js +89 -0
  20. package/dist/healthybowl/offline/graphql.js.map +1 -0
  21. package/dist/healthybowl/offline/network.js +43 -0
  22. package/dist/healthybowl/offline/network.js.map +1 -0
  23. package/dist/healthybowl/offline/observationMeta.js +107 -0
  24. package/dist/healthybowl/offline/observationMeta.js.map +1 -0
  25. package/dist/healthybowl/offline/store.js +120 -0
  26. package/dist/healthybowl/offline/store.js.map +1 -0
  27. package/dist/healthybowl/offline/syncEngine.js +141 -0
  28. package/dist/healthybowl/offline/syncEngine.js.map +1 -0
  29. package/dist/healthybowl/offline/types.js +15 -0
  30. package/dist/healthybowl/offline/types.js.map +1 -0
  31. package/dist/healthybowl/pages/field-capture/CaptureObservationForm.js +272 -0
  32. package/dist/healthybowl/pages/field-capture/CaptureObservationForm.js.map +1 -0
  33. package/dist/healthybowl/pages/field-capture/ConflictReviewPage.js +200 -0
  34. package/dist/healthybowl/pages/field-capture/ConflictReviewPage.js.map +1 -0
  35. package/dist/healthybowl/pages/field-capture/FieldCapturePage.js +60 -0
  36. package/dist/healthybowl/pages/field-capture/FieldCapturePage.js.map +1 -0
  37. package/dist/healthybowl/pages/field-capture/OfflineSettingsPage.js +217 -0
  38. package/dist/healthybowl/pages/field-capture/OfflineSettingsPage.js.map +1 -0
  39. package/dist/healthybowl/pages/field-capture/PendingSyncPage.js +80 -0
  40. package/dist/healthybowl/pages/field-capture/PendingSyncPage.js.map +1 -0
  41. package/dist/healthybowl/pages/field-capture/SyncHistoryPage.js +130 -0
  42. package/dist/healthybowl/pages/field-capture/SyncHistoryPage.js.map +1 -0
  43. package/dist/healthybowl/pages/field-capture/SyncQueuePanel.js +112 -0
  44. package/dist/healthybowl/pages/field-capture/SyncQueuePanel.js.map +1 -0
  45. package/dist/healthybowl/pages/traceability/PrintLabelDialog.js +296 -0
  46. package/dist/healthybowl/pages/traceability/PrintLabelDialog.js.map +1 -0
  47. package/dist/healthybowl/pages/traceability/QRCodesPage.js +450 -103
  48. package/dist/healthybowl/pages/traceability/QRCodesPage.js.map +1 -1
  49. package/dist/healthybowl/pages/traceability/TracePortalSettingsPage.js +249 -0
  50. package/dist/healthybowl/pages/traceability/TracePortalSettingsPage.js.map +1 -0
  51. package/dist/healthybowl/public/PublicTraceJourney.js +192 -0
  52. package/dist/healthybowl/public/PublicTraceJourney.js.map +1 -0
  53. package/dist/healthybowl/public/PublicTraceNotFound.js +55 -0
  54. package/dist/healthybowl/public/PublicTraceNotFound.js.map +1 -0
  55. package/dist/healthybowl/public/PublicTracePage.js +46 -0
  56. package/dist/healthybowl/public/PublicTracePage.js.map +1 -0
  57. package/dist/index.js +4 -3
  58. package/package.json +1 -1
@@ -3,144 +3,491 @@ import { useBasePath as t } from "../../hooks/useBasePath.js";
3
3
  import { PageLayout as n } from "../../components/PageLayout.js";
4
4
  import { StatusBadge as r } from "../../components/StatusBadge.js";
5
5
  import { EmptyState as i } from "../../components/EmptyState.js";
6
- import { ErrorState as a } from "../../components/ErrorState.js";
7
- import { ToastContainer as o } from "../../components/Toast.js";
8
- import { LoadingSkeleton as s } from "../../components/LoadingSkeleton.js";
9
- import { useToast as c } from "../../hooks/useToast.js";
6
+ import { ErrorState as ee } from "../../components/ErrorState.js";
7
+ import { ToastContainer as a } from "../../components/Toast.js";
8
+ import { LoadingSkeleton as o } from "../../components/LoadingSkeleton.js";
9
+ import { useToast as te } from "../../hooks/useToast.js";
10
10
  import "../../components/index.js";
11
- import { useHealthyBowlData as l } from "../../hooks/useHealthyBowlData.js";
12
- import { useState as u } from "react";
13
- import { useI18n as d } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
14
- import { Download as f, Loader2 as p, QrCode as m, ScanLine as h } from "lucide-react";
15
- import { useNavigate as g } from "react-router-dom";
16
- import { jsx as _, jsxs as v } from "react/jsx-runtime";
17
- import { Button as y } from "@burdenoff/fe-libs/ui";
11
+ import { useHealthyBowlData as ne } from "../../hooks/useHealthyBowlData.js";
12
+ import { publicTraceUrl as s, useTracePortal as c } from "../../hooks/useTracePortal.js";
13
+ import { PrintLabelDialog as l } from "./PrintLabelDialog.js";
14
+ import { useCallback as u, useEffect as d, useMemo as f, useState as p } from "react";
15
+ import { useI18n as re } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
16
+ import { Copy as ie, Download as ae, ExternalLink as m, Loader2 as h, Printer as g, QrCode as _, ScanLine as v, Search as oe, Settings as se } from "lucide-react";
17
+ import { Link as y } from "react-router-dom";
18
+ import { Fragment as b, jsx as x, jsxs as S } from "react/jsx-runtime";
19
+ import { Button as C } from "@burdenoff/fe-libs/ui";
18
20
  //#region src/healthybowl/pages/traceability/QRCodesPage.tsx
19
- var b = (e) => {
21
+ var w = (e) => {
20
22
  switch (e) {
21
23
  case "delivered": return "success";
22
24
  case "in_transit": return "info";
23
25
  case "in_production": return "warning";
24
26
  default: return "default";
25
27
  }
26
- }, x = () => {
27
- let { t: x } = d(), { traceBatches: S, loading: C, error: w, errors: T } = l(), { toasts: E, toast: D, dismiss: O } = c(), k = g(), { buildPath: A } = t(), [j, M] = u(null), N = (e) => `${A("traceability/tracking")}?code=${encodeURIComponent(e)}`, P = (e) => k(N(e)), F = (e, t) => {
28
- M(e);
29
- let n = `Trace batch reference\nBatch: ${t}\nTracking: ${N(t)}\nExported: ${(/* @__PURE__ */ new Date()).toISOString()}`, r = new Blob([n], { type: "text/plain" }), i = URL.createObjectURL(r), a = document.createElement("a");
30
- a.href = i, a.download = `trace-batch-${t}.txt`, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i), D({
31
- title: x("healthybowl.traceability.qRCodes.toast.exported.title", "Batch reference exported"),
32
- description: x("healthybowl.traceability.qRCodes.toast.exported.description", "Plain-text reference for {{batchCode}} saved (preview only — not a scannable QR code).", { batchCode: t }),
33
- variant: "info"
34
- }), M(null);
35
- };
36
- return C && S.length === 0 ? /* @__PURE__ */ _(n, {
37
- title: x("healthybowl.traceability.qRCodes.title", "QR Codes"),
38
- description: x("healthybowl.traceability.qRCodes.description", "Preview QR labels for product traceability"),
39
- children: /* @__PURE__ */ _(s, {
28
+ }, T = () => {
29
+ let { t: T } = re(), { traceBatches: E, loading: ce, error: D, errors: O, refetchTraceabilityData: k } = ne(), { toasts: A, toast: j, dismiss: M } = te(), { buildPath: N } = t(), P = c(k), [F, I] = p(""), [L, R] = p("all"), [z, B] = p(null), [V, H] = p(null), [U, W] = p(!1), [le, G] = p(null), K = u((e) => j({
30
+ title: T("healthybowl.traceability.qRCodes.toast.error.title", "Something went wrong"),
31
+ description: e,
32
+ variant: "error"
33
+ }), [j, T]), q = f(() => {
34
+ let e = F.trim().toLowerCase();
35
+ return E.filter((t) => L === "published" && !t.published || L === "draft" && t.published ? !1 : e ? t.batchCode.toLowerCase().includes(e) || (t.product ?? "").toLowerCase().includes(e) || (t.origin ?? "").toLowerCase().includes(e) : !0);
36
+ }, [
37
+ E,
38
+ F,
39
+ L
40
+ ]), ue = f(() => E.filter((e) => e.published).length, [E]);
41
+ d(() => {
42
+ if (z || E.length === 0) return;
43
+ let e = E.find((e) => e.published);
44
+ e && B(e.id);
45
+ }, [E, z]);
46
+ let J = f(() => E.find((e) => e.id === z) ?? null, [E, z]);
47
+ d(() => {
48
+ if (!J?.published) {
49
+ H(null), W(!1);
50
+ return;
51
+ }
52
+ let e = !1;
53
+ return W(!0), P.loadQrDataUrl(J.id).then((t) => {
54
+ e || H(t);
55
+ }).catch((t) => {
56
+ e || K(t instanceof Error ? t.message : String(t));
57
+ }).finally(() => {
58
+ e || W(!1);
59
+ }), () => {
60
+ e = !0;
61
+ };
62
+ }, [J?.id, J?.published]);
63
+ let Y = async (e, t) => {
64
+ try {
65
+ await P.setPublished(e, t), j({
66
+ title: t ? T("healthybowl.traceability.qRCodes.toast.published.title", "Batch published") : T("healthybowl.traceability.qRCodes.toast.unpublished.title", "Batch unpublished"),
67
+ description: t ? T("healthybowl.traceability.qRCodes.toast.published.description", "Anyone scanning its QR can now see the farm-to-fork journey.") : T("healthybowl.traceability.qRCodes.toast.unpublished.description", "Its public page now shows \"not available\". The link is kept, so republishing revives printed labels."),
68
+ variant: "success"
69
+ });
70
+ } catch (e) {
71
+ K(e instanceof Error ? e.message : String(e));
72
+ }
73
+ }, de = async (e) => {
74
+ try {
75
+ await P.downloadQrPng(e), j({
76
+ title: T("healthybowl.traceability.qRCodes.toast.png.title", "QR code downloaded"),
77
+ description: T("healthybowl.traceability.qRCodes.toast.png.description", "Point a phone camera at it — it opens the public trace page."),
78
+ variant: "success"
79
+ });
80
+ } catch (e) {
81
+ K(e instanceof Error ? e.message : String(e));
82
+ }
83
+ }, fe = async (e) => {
84
+ try {
85
+ await navigator.clipboard.writeText(e), j({
86
+ title: T("healthybowl.traceability.qRCodes.toast.copied.title", "Public link copied"),
87
+ variant: "success"
88
+ });
89
+ } catch {
90
+ K(T("healthybowl.traceability.qRCodes.toast.copyFailed", "Could not copy the link."));
91
+ }
92
+ }, X = T("healthybowl.traceability.qRCodes.title", "QR Codes & Public Trace Portal"), Z = T("healthybowl.traceability.qRCodes.description", "Manage QR codes and public farm-to-fork trace pages"), Q = /* @__PURE__ */ x(C, {
93
+ variant: "outline",
94
+ asChild: !0,
95
+ children: /* @__PURE__ */ S(y, {
96
+ to: N("traceability/portal-settings"),
97
+ "data-testid": "trace-portal-settings-link",
98
+ children: [/* @__PURE__ */ x(se, { className: "h-4 w-4" }), T("healthybowl.traceability.qRCodes.portalSettings", "Portal Settings")]
99
+ })
100
+ });
101
+ if (ce && E.length === 0) return /* @__PURE__ */ x(n, {
102
+ title: X,
103
+ description: Z,
104
+ children: /* @__PURE__ */ x(o, {
40
105
  variant: "card",
41
- count: 6
106
+ count: 4
42
107
  })
43
- }) : w ? /* @__PURE__ */ _(n, {
44
- title: x("healthybowl.traceability.qRCodes.title", "QR Codes"),
45
- description: x("healthybowl.traceability.qRCodes.description", "Preview QR labels for product traceability"),
46
- children: /* @__PURE__ */ _(i, {
108
+ });
109
+ if (D) return /* @__PURE__ */ x(n, {
110
+ title: X,
111
+ description: Z,
112
+ children: /* @__PURE__ */ x(i, {
47
113
  illustration: "empty-files",
48
- title: x("healthybowl.traceability.qRCodes.error.title", "Unable to load traceability data"),
49
- description: w.message
114
+ title: T("healthybowl.traceability.qRCodes.error.title", "Unable to load traceability data"),
115
+ description: D.message
50
116
  })
51
- }) : S.length === 0 ? /* @__PURE__ */ _(n, {
52
- title: x("healthybowl.traceability.qRCodes.title", "QR Codes"),
53
- description: x("healthybowl.traceability.qRCodes.description", "Preview QR labels for product traceability"),
54
- children: T.traceability ? /* @__PURE__ */ _(a, {}) : /* @__PURE__ */ _(i, {
117
+ });
118
+ if (E.length === 0) return /* @__PURE__ */ x(n, {
119
+ title: X,
120
+ description: Z,
121
+ actions: Q,
122
+ children: O.traceability ? /* @__PURE__ */ x(ee, {}) : /* @__PURE__ */ x(i, {
55
123
  illustration: "empty-search",
56
- title: x("healthybowl.traceability.qRCodes.emptyState.title", "No trace batches yet"),
57
- description: x("healthybowl.traceability.qRCodes.emptyState.description", "Create a trace batch to preview its traceability label.")
124
+ title: T("healthybowl.traceability.qRCodes.emptyState.title", "No trace batches yet"),
125
+ description: T("healthybowl.traceability.qRCodes.emptyState.description", "Create a trace batch to generate its scannable QR code.")
58
126
  })
59
- }) : /* @__PURE__ */ v(n, {
60
- title: x("healthybowl.traceability.qRCodes.title", "QR Codes"),
61
- description: x("healthybowl.traceability.qRCodes.description", "Preview QR labels for product traceability"),
62
- purpose: "Preview the QR labels that link a product back to its full farm-to-table story. Put these on your packaging so a customer can scan and instantly see where, when and how the produce was grown.",
127
+ });
128
+ let $ = E.find((e) => e.id === le) ?? null;
129
+ return /* @__PURE__ */ S(n, {
130
+ title: X,
131
+ description: Z,
132
+ actions: Q,
133
+ purpose: "Print a scannable QR on your cartons. A shopper points their camera at it and sees where this produce was grown, when it was harvested, and which organic certificates back it — no app, no login.",
63
134
  children: [
64
- /* @__PURE__ */ _("div", {
65
- className: "rounded-lg border border-border-subtle bg-bg-sunken/40 px-4 py-3 text-xs text-text-secondary",
66
- children: x("healthybowl.traceability.qRCodes.previewBanner", "These labels are a preview — not yet consumer-ready scannable images. Select a label to open its in-app farm-to-table tracking page; a public, scannable QR is still on the roadmap.")
67
- }),
68
- /* @__PURE__ */ _("div", {
69
- className: "grid gap-4 sm:grid-cols-2 lg:grid-cols-3",
70
- children: S.map((t) => /* @__PURE__ */ v("div", {
71
- className: "rounded-lg border border-border-subtle bg-bg-surface p-4",
72
- children: [
73
- /* @__PURE__ */ v("div", {
74
- className: "flex items-start justify-between",
75
- children: [/* @__PURE__ */ v("div", { children: [/* @__PURE__ */ _("h3", {
76
- className: "text-sm font-medium text-text-primary",
77
- children: t.product
78
- }), /* @__PURE__ */ _("p", {
135
+ /* @__PURE__ */ S("div", {
136
+ className: "grid gap-4 lg:grid-cols-2",
137
+ children: [/* @__PURE__ */ x("div", {
138
+ className: "rounded-xl border border-border-subtle bg-bg-surface p-6",
139
+ children: J ? /* @__PURE__ */ S(b, { children: [
140
+ /* @__PURE__ */ S("div", {
141
+ className: "flex items-start justify-between gap-3",
142
+ children: [/* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("h3", {
143
+ className: "text-base font-semibold text-text-primary",
144
+ children: T("healthybowl.traceability.qRCodes.card.heading", "Trace Batch — {{batchCode}}", { batchCode: J.batchCode })
145
+ }), /* @__PURE__ */ x("p", {
79
146
  className: "mt-0.5 text-xs text-text-secondary",
80
- children: t.batchCode
81
- })] }), /* @__PURE__ */ _(r, {
82
- label: (t.status ?? "unknown").replace(/_/g, " "),
83
- variant: b(t.status ?? "unknown")
147
+ children: J.product
148
+ })] }), /* @__PURE__ */ x(r, {
149
+ label: J.published ? T("healthybowl.traceability.qRCodes.published", "Published") : T("healthybowl.traceability.qRCodes.draft", "Draft"),
150
+ variant: J.published ? "success" : "default"
84
151
  })]
85
152
  }),
86
- /* @__PURE__ */ _("button", {
87
- type: "button",
88
- onClick: () => P(t.batchCode),
89
- title: x("healthybowl.traceability.qRCodes.card.openTrackingTitle", "Open tracking page"),
90
- className: "mx-auto my-4 flex h-32 w-32 items-center justify-center rounded-lg border-2 border-dashed border-border-subtle bg-bg-sunken transition-colors hover:border-primary hover:bg-bg-sunken/70",
91
- children: /* @__PURE__ */ v("div", {
92
- className: "text-center",
93
- children: [/* @__PURE__ */ _(m, { className: "mx-auto h-10 w-10 text-text-secondary" }), /* @__PURE__ */ _("p", {
94
- className: "mt-1 font-mono text-[10px] text-text-secondary",
95
- children: t.batchCode
153
+ /* @__PURE__ */ x("div", {
154
+ className: "mx-auto my-6 flex h-56 w-56 items-center justify-center rounded-xl border border-border-subtle bg-bg-canvas p-3",
155
+ "data-testid": "trace-qr-panel",
156
+ children: U ? /* @__PURE__ */ x(h, { className: "h-8 w-8 animate-spin text-text-secondary" }) : V ? /* @__PURE__ */ x("img", {
157
+ src: V.dataUrl,
158
+ alt: T("healthybowl.traceability.qRCodes.qrAlt", "Scannable QR code for batch {{batchCode}}", { batchCode: J.batchCode }),
159
+ className: "h-full w-full object-contain",
160
+ "data-testid": "trace-qr-image"
161
+ }) : /* @__PURE__ */ S("div", {
162
+ className: "px-4 text-center",
163
+ children: [/* @__PURE__ */ x(_, { className: "mx-auto h-10 w-10 text-text-secondary" }), /* @__PURE__ */ x("p", {
164
+ className: "mt-2 text-xs text-text-secondary",
165
+ children: T("healthybowl.traceability.qRCodes.publishToGenerate", "Publish this batch to generate its scannable QR code.")
96
166
  })]
97
167
  })
98
168
  }),
99
- /* @__PURE__ */ v(y, {
100
- type: "button",
101
- variant: "ghost",
102
- size: "sm",
103
- onClick: () => P(t.batchCode),
104
- className: "mx-auto flex text-[10px] font-medium uppercase tracking-wide text-primary",
169
+ V ? /* @__PURE__ */ S(b, { children: [/* @__PURE__ */ x("p", {
170
+ className: "text-center text-sm text-text-secondary",
171
+ children: T("healthybowl.traceability.qRCodes.scanCta", "Scan to view farm-to-fork journey")
172
+ }), /* @__PURE__ */ S("div", {
173
+ className: "mx-auto mt-2 flex max-w-full items-center justify-center gap-2 rounded-full bg-bg-sunken px-3 py-1.5",
174
+ children: [/* @__PURE__ */ x("span", {
175
+ className: "truncate font-mono text-xs text-text-secondary",
176
+ "data-testid": "trace-public-url",
177
+ title: V.publicUrl,
178
+ children: V.publicUrl
179
+ }), /* @__PURE__ */ x("button", {
180
+ type: "button",
181
+ onClick: () => fe(V.publicUrl),
182
+ "aria-label": T("healthybowl.traceability.qRCodes.copyLink", "Copy public link"),
183
+ className: "shrink-0 text-text-secondary hover:text-text-primary",
184
+ children: /* @__PURE__ */ x(ie, { className: "h-3.5 w-3.5" })
185
+ })]
186
+ })] }) : null,
187
+ /* @__PURE__ */ S("div", {
188
+ className: "mt-6 flex flex-wrap items-center justify-center gap-2",
105
189
  children: [
106
- /* @__PURE__ */ _(h, { className: "h-3 w-3" }),
107
- " ",
108
- x("healthybowl.traceability.qRCodes.card.openTracking", "Open tracking")
190
+ /* @__PURE__ */ S(C, {
191
+ variant: "outline",
192
+ onClick: () => de(J.id),
193
+ disabled: !J.published || P.busyBatchId === J.id,
194
+ "data-testid": "trace-download-png",
195
+ children: [P.busyBatchId === J.id ? /* @__PURE__ */ x(h, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ x(ae, { className: "h-4 w-4" }), T("healthybowl.traceability.qRCodes.downloadPng", "Download PNG")]
196
+ }),
197
+ /* @__PURE__ */ S(C, {
198
+ variant: "outline",
199
+ onClick: () => G(J.id),
200
+ disabled: !J.published,
201
+ "data-testid": "trace-print-label",
202
+ children: [/* @__PURE__ */ x(g, { className: "h-4 w-4" }), T("healthybowl.traceability.qRCodes.printLabel", "Print Label")]
203
+ }),
204
+ V ? /* @__PURE__ */ x(C, {
205
+ variant: "ghost",
206
+ asChild: !0,
207
+ children: /* @__PURE__ */ S("a", {
208
+ href: V.publicUrl,
209
+ target: "_blank",
210
+ rel: "noopener noreferrer",
211
+ "data-testid": "trace-open-public",
212
+ children: [/* @__PURE__ */ x(m, { className: "h-4 w-4" }), T("healthybowl.traceability.qRCodes.openPublic", "Open public page")]
213
+ })
214
+ }) : null
109
215
  ]
110
216
  }),
111
- /* @__PURE__ */ v("div", {
112
- className: "mt-3 space-y-1 text-xs text-text-secondary",
217
+ /* @__PURE__ */ S("label", {
218
+ className: "mt-6 flex cursor-pointer items-center justify-center gap-3 border-t border-border-subtle pt-4",
219
+ children: [/* @__PURE__ */ x("button", {
220
+ type: "button",
221
+ role: "switch",
222
+ "aria-checked": J.published,
223
+ "aria-label": T("healthybowl.traceability.qRCodes.publishToggle", "Publish to public portal"),
224
+ "data-testid": "trace-publish-toggle",
225
+ disabled: P.busyBatchId === J.id,
226
+ onClick: () => Y(J.id, !J.published),
227
+ className: `relative h-6 w-11 shrink-0 rounded-full transition-colors disabled:opacity-50 ${J.published ? "bg-action-primary-bg" : "bg-bg-sunken border border-border-subtle"}`,
228
+ children: /* @__PURE__ */ x("span", { className: `absolute top-0.5 h-5 w-5 rounded-full bg-bg-surface shadow transition-transform ${J.published ? "translate-x-5" : "translate-x-0.5"}` })
229
+ }), /* @__PURE__ */ x("span", {
230
+ className: "text-sm text-text-primary",
231
+ children: T("healthybowl.traceability.qRCodes.publishToggle", "Publish to public portal")
232
+ })]
233
+ })
234
+ ] }) : /* @__PURE__ */ x(i, {
235
+ illustration: "empty-search",
236
+ title: T("healthybowl.traceability.qRCodes.selectBatch.title", "Select a batch"),
237
+ description: T("healthybowl.traceability.qRCodes.selectBatch.description", "Choose a trace batch below to see its QR code and public link.")
238
+ })
239
+ }), /* @__PURE__ */ S("div", {
240
+ className: "rounded-xl border border-border-subtle bg-bg-sunken/30 p-6",
241
+ children: [/* @__PURE__ */ x("h3", {
242
+ className: "text-sm font-semibold text-text-primary",
243
+ children: T("healthybowl.traceability.qRCodes.previewHeading", "What a shopper sees")
244
+ }), J?.published ? /* @__PURE__ */ S("div", {
245
+ className: "mt-4 rounded-xl border border-border-subtle bg-bg-surface p-5",
246
+ children: [
247
+ /* @__PURE__ */ x("p", {
248
+ className: "text-base font-semibold text-text-primary",
249
+ children: T("healthybowl.traceability.qRCodes.preview.journey", "Your food's journey — {{product}}", { product: J.product })
250
+ }),
251
+ /* @__PURE__ */ S("ol", {
252
+ className: "mt-4 space-y-3",
253
+ children: [
254
+ J.origin ? /* @__PURE__ */ S("li", {
255
+ className: "flex gap-3 text-sm",
256
+ children: [/* @__PURE__ */ x(v, { className: "mt-0.5 h-4 w-4 shrink-0 text-accent-teal" }), /* @__PURE__ */ S("span", {
257
+ className: "text-text-secondary",
258
+ children: [
259
+ /* @__PURE__ */ x("span", {
260
+ className: "font-medium text-text-primary",
261
+ children: T("healthybowl.traceability.qRCodes.preview.grown", "Grown")
262
+ }),
263
+ " ",
264
+ "— ",
265
+ J.origin
266
+ ]
267
+ })]
268
+ }) : null,
269
+ /* @__PURE__ */ S("li", {
270
+ className: "flex gap-3 text-sm",
271
+ children: [/* @__PURE__ */ x(v, { className: "mt-0.5 h-4 w-4 shrink-0 text-accent-teal" }), /* @__PURE__ */ S("span", {
272
+ className: "text-text-secondary",
273
+ children: [
274
+ /* @__PURE__ */ x("span", {
275
+ className: "font-medium text-text-primary",
276
+ children: T("healthybowl.traceability.qRCodes.preview.harvested", "Harvested")
277
+ }),
278
+ " ",
279
+ "— ",
280
+ e(J.harvestDate)
281
+ ]
282
+ })]
283
+ }),
284
+ (J.supplyChainSteps ?? []).slice(0, 3).map((e) => /* @__PURE__ */ S("li", {
285
+ className: "flex gap-3 text-sm",
286
+ children: [/* @__PURE__ */ x(v, { className: "mt-0.5 h-4 w-4 shrink-0 text-accent-teal" }), /* @__PURE__ */ S("span", {
287
+ className: "text-text-secondary",
288
+ children: [/* @__PURE__ */ x("span", {
289
+ className: "font-medium text-text-primary",
290
+ children: e.step
291
+ }), e.date ? ` — ${e.date}` : null]
292
+ })]
293
+ }, e.id))
294
+ ]
295
+ }),
296
+ (J.certifications ?? []).length > 0 ? /* @__PURE__ */ x("div", {
297
+ className: "mt-4 flex flex-wrap gap-2 border-t border-border-subtle pt-4",
298
+ children: (J.certifications ?? []).map((e) => /* @__PURE__ */ x("span", {
299
+ className: "rounded-full bg-bg-sunken px-2.5 py-1 text-xs font-medium text-text-primary",
300
+ children: e
301
+ }, e))
302
+ }) : null
303
+ ]
304
+ }) : /* @__PURE__ */ x("p", {
305
+ className: "mt-4 text-sm text-text-secondary",
306
+ children: T("healthybowl.traceability.qRCodes.preview.draftNotice", "Draft batches have no public page. Publish a batch to preview what a shopper will see when they scan it.")
307
+ })]
308
+ })]
309
+ }),
310
+ /* @__PURE__ */ S("div", {
311
+ className: "mt-6 rounded-xl border border-border-subtle bg-bg-surface",
312
+ children: [/* @__PURE__ */ S("div", {
313
+ className: "flex flex-wrap items-center gap-3 border-b border-border-subtle p-4",
314
+ children: [
315
+ /* @__PURE__ */ S("div", {
316
+ className: "relative min-w-[220px] flex-1",
317
+ children: [/* @__PURE__ */ x(oe, { className: "pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-text-secondary" }), /* @__PURE__ */ x("input", {
318
+ type: "search",
319
+ value: F,
320
+ onChange: (e) => I(e.target.value),
321
+ placeholder: T("healthybowl.traceability.qRCodes.searchPlaceholder", "Search by batch code or product"),
322
+ "aria-label": T("healthybowl.traceability.qRCodes.searchPlaceholder", "Search by batch code or product"),
323
+ "data-testid": "trace-search",
324
+ className: "w-full rounded-lg border border-border-subtle bg-bg-canvas py-2 pl-9 pr-3 text-sm text-text-primary placeholder:text-text-secondary"
325
+ })]
326
+ }),
327
+ /* @__PURE__ */ S("select", {
328
+ value: L,
329
+ onChange: (e) => R(e.target.value),
330
+ "aria-label": T("healthybowl.traceability.qRCodes.statusFilter", "Filter by publish status"),
331
+ "data-testid": "trace-status-filter",
332
+ className: "rounded-lg border border-border-subtle bg-bg-canvas px-3 py-2 text-sm text-text-primary",
113
333
  children: [
114
- /* @__PURE__ */ _("p", { children: x("healthybowl.traceability.qRCodes.card.origin", "Origin: {{origin}}", { origin: t.origin }) }),
115
- /* @__PURE__ */ _("p", { children: x("healthybowl.traceability.qRCodes.card.harvest", "Harvest: {{date}}", { date: e(t.harvestDate) }) }),
116
- /* @__PURE__ */ _("p", { children: x("healthybowl.traceability.qRCodes.card.expiry", "Expiry: {{date}}", { date: e(t.expiryDate) }) }),
117
- /* @__PURE__ */ _("div", {
118
- className: "flex flex-wrap gap-1 pt-1",
119
- children: (t.certifications ?? []).map((e) => /* @__PURE__ */ _("span", {
120
- className: "rounded-full bg-bg-sunken px-2 py-0.5 text-xs",
121
- children: e
122
- }, e))
334
+ /* @__PURE__ */ x("option", {
335
+ value: "all",
336
+ children: T("healthybowl.traceability.qRCodes.filter.all", "All statuses")
337
+ }),
338
+ /* @__PURE__ */ x("option", {
339
+ value: "published",
340
+ children: T("healthybowl.traceability.qRCodes.published", "Published")
341
+ }),
342
+ /* @__PURE__ */ x("option", {
343
+ value: "draft",
344
+ children: T("healthybowl.traceability.qRCodes.draft", "Draft")
123
345
  })
124
346
  ]
125
347
  }),
126
- /* @__PURE__ */ v(y, {
127
- variant: "outline",
128
- onClick: () => F(t.id, t.batchCode),
129
- disabled: j === t.id,
130
- className: "mt-4 w-full",
131
- children: [j === t.id ? /* @__PURE__ */ _(p, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ _(f, { className: "h-4 w-4" }), j === t.id ? x("healthybowl.traceability.qRCodes.card.exporting", "Exporting…") : x("healthybowl.traceability.qRCodes.card.export", "Export batch reference")]
348
+ /* @__PURE__ */ x("p", {
349
+ className: "text-xs text-text-secondary",
350
+ "data-testid": "trace-batch-stats",
351
+ children: T("healthybowl.traceability.qRCodes.stats", "{{total}} batches · {{published}} published", {
352
+ total: E.length,
353
+ published: ue
354
+ })
132
355
  })
133
356
  ]
134
- }, t.id))
357
+ }), /* @__PURE__ */ x("div", {
358
+ className: "overflow-x-auto",
359
+ children: /* @__PURE__ */ S("table", {
360
+ className: "w-full text-left text-sm",
361
+ children: [/* @__PURE__ */ x("thead", { children: /* @__PURE__ */ S("tr", {
362
+ className: "border-b border-border-subtle text-xs uppercase tracking-wide text-text-secondary",
363
+ children: [
364
+ /* @__PURE__ */ x("th", {
365
+ className: "px-4 py-3 font-medium",
366
+ children: T("healthybowl.traceability.qRCodes.table.batchCode", "Batch Code")
367
+ }),
368
+ /* @__PURE__ */ x("th", {
369
+ className: "px-4 py-3 font-medium",
370
+ children: T("healthybowl.traceability.qRCodes.table.product", "Product")
371
+ }),
372
+ /* @__PURE__ */ x("th", {
373
+ className: "hidden px-4 py-3 font-medium md:table-cell",
374
+ children: T("healthybowl.traceability.qRCodes.table.origin", "Origin Farm")
375
+ }),
376
+ /* @__PURE__ */ x("th", {
377
+ className: "hidden px-4 py-3 font-medium sm:table-cell",
378
+ children: T("healthybowl.traceability.qRCodes.table.harvest", "Harvest Date")
379
+ }),
380
+ /* @__PURE__ */ x("th", {
381
+ className: "px-4 py-3 font-medium",
382
+ children: T("healthybowl.traceability.qRCodes.table.status", "Status")
383
+ }),
384
+ /* @__PURE__ */ x("th", {
385
+ className: "px-4 py-3 text-right font-medium",
386
+ children: T("healthybowl.traceability.qRCodes.table.actions", "Actions")
387
+ })
388
+ ]
389
+ }) }), /* @__PURE__ */ S("tbody", {
390
+ "data-testid": "trace-batch-table",
391
+ children: [q.map((t) => {
392
+ let n = s(t.publicPath);
393
+ return /* @__PURE__ */ S("tr", {
394
+ className: `border-b border-border-subtle last:border-0 ${t.id === z ? "bg-bg-sunken/40" : ""}`,
395
+ "data-testid": `trace-batch-row-${t.batchCode}`,
396
+ children: [
397
+ /* @__PURE__ */ x("td", {
398
+ className: "px-4 py-3",
399
+ children: /* @__PURE__ */ x("button", {
400
+ type: "button",
401
+ onClick: () => B(t.id),
402
+ className: "font-mono text-text-primary hover:text-accent-teal",
403
+ children: t.batchCode
404
+ })
405
+ }),
406
+ /* @__PURE__ */ x("td", {
407
+ className: "px-4 py-3 text-text-primary",
408
+ children: t.product
409
+ }),
410
+ /* @__PURE__ */ x("td", {
411
+ className: "hidden px-4 py-3 text-text-secondary md:table-cell",
412
+ children: t.origin
413
+ }),
414
+ /* @__PURE__ */ x("td", {
415
+ className: "hidden px-4 py-3 text-text-secondary sm:table-cell",
416
+ children: e(t.harvestDate)
417
+ }),
418
+ /* @__PURE__ */ x("td", {
419
+ className: "px-4 py-3",
420
+ children: /* @__PURE__ */ S("div", {
421
+ className: "flex flex-wrap items-center gap-1.5",
422
+ children: [/* @__PURE__ */ x(r, {
423
+ label: t.published ? T("healthybowl.traceability.qRCodes.published", "Published") : T("healthybowl.traceability.qRCodes.draft", "Draft"),
424
+ variant: t.published ? "success" : "default"
425
+ }), /* @__PURE__ */ x(r, {
426
+ label: (t.status ?? "unknown").replace(/_/g, " "),
427
+ variant: w(t.status ?? "unknown")
428
+ })]
429
+ })
430
+ }),
431
+ /* @__PURE__ */ x("td", {
432
+ className: "px-4 py-3",
433
+ children: /* @__PURE__ */ S("div", {
434
+ className: "flex items-center justify-end gap-1",
435
+ children: [/* @__PURE__ */ x(C, {
436
+ variant: "ghost",
437
+ size: "sm",
438
+ onClick: () => Y(t.id, !t.published),
439
+ disabled: P.busyBatchId === t.id,
440
+ "data-testid": `trace-row-toggle-${t.batchCode}`,
441
+ children: P.busyBatchId === t.id ? /* @__PURE__ */ x(h, { className: "h-3.5 w-3.5 animate-spin" }) : t.published ? T("healthybowl.traceability.qRCodes.unpublish", "Unpublish") : T("healthybowl.traceability.qRCodes.publish", "Publish")
442
+ }), n ? /* @__PURE__ */ x(C, {
443
+ variant: "ghost",
444
+ size: "sm",
445
+ asChild: !0,
446
+ children: /* @__PURE__ */ x("a", {
447
+ href: n,
448
+ target: "_blank",
449
+ rel: "noopener noreferrer",
450
+ "aria-label": T("healthybowl.traceability.qRCodes.openPublic", "Open public page"),
451
+ children: /* @__PURE__ */ x(m, { className: "h-3.5 w-3.5" })
452
+ })
453
+ }) : null]
454
+ })
455
+ })
456
+ ]
457
+ }, t.id);
458
+ }), q.length === 0 ? /* @__PURE__ */ x("tr", { children: /* @__PURE__ */ x("td", {
459
+ colSpan: 6,
460
+ className: "px-4 py-10 text-center text-sm text-text-secondary",
461
+ children: T("healthybowl.traceability.qRCodes.noMatches", "No batches match your search.")
462
+ }) }) : null]
463
+ })]
464
+ })
465
+ })]
135
466
  }),
136
- /* @__PURE__ */ _(o, {
137
- toasts: E,
138
- onDismiss: O
467
+ $ ? /* @__PURE__ */ x(l, {
468
+ open: !0,
469
+ onClose: () => G(null),
470
+ batchId: $.id,
471
+ batchCode: $.batchCode,
472
+ productName: $.product,
473
+ loadQrDataUrl: P.loadQrDataUrl,
474
+ onDownloadPdf: (e, t) => P.downloadLabelPdf(e, t),
475
+ onSaveToFiles: (e, t) => P.saveLabelToFiles(e, t),
476
+ onError: K,
477
+ onSaved: (e) => j({
478
+ title: T("healthybowl.traceability.qRCodes.toast.saved.title", "Label saved to Files"),
479
+ description: e,
480
+ variant: "success"
481
+ })
482
+ }) : null,
483
+ /* @__PURE__ */ x(a, {
484
+ toasts: A,
485
+ onDismiss: M
139
486
  })
140
487
  ]
141
488
  });
142
489
  };
143
490
  //#endregion
144
- export { x as QRCodesPage };
491
+ export { T as QRCodesPage };
145
492
 
146
493
  //# sourceMappingURL=QRCodesPage.js.map