@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.
- package/dist/generated/wspace-operations.js +476 -318
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.js.map +1 -1
- package/dist/healthybowl/HealthyBowlRoot.js +99 -82
- package/dist/healthybowl/HealthyBowlRoot.js.map +1 -1
- package/dist/healthybowl/HealthyBowlRoutes.js +103 -79
- package/dist/healthybowl/HealthyBowlRoutes.js.map +1 -1
- package/dist/healthybowl/hooks/useHealthyBowlData.js +2 -0
- package/dist/healthybowl/hooks/useHealthyBowlData.js.map +1 -1
- package/dist/healthybowl/hooks/useTracePortal.js +138 -0
- package/dist/healthybowl/hooks/useTracePortal.js.map +1 -0
- package/dist/healthybowl/index.js +1 -0
- package/dist/healthybowl/offline/OfflineStatusPill.js +30 -0
- package/dist/healthybowl/offline/OfflineStatusPill.js.map +1 -0
- package/dist/healthybowl/offline/OfflineSyncProvider.js +235 -0
- package/dist/healthybowl/offline/OfflineSyncProvider.js.map +1 -0
- package/dist/healthybowl/offline/geolocation.js +31 -0
- package/dist/healthybowl/offline/geolocation.js.map +1 -0
- package/dist/healthybowl/offline/graphql.js +89 -0
- package/dist/healthybowl/offline/graphql.js.map +1 -0
- package/dist/healthybowl/offline/network.js +43 -0
- package/dist/healthybowl/offline/network.js.map +1 -0
- package/dist/healthybowl/offline/observationMeta.js +107 -0
- package/dist/healthybowl/offline/observationMeta.js.map +1 -0
- package/dist/healthybowl/offline/store.js +120 -0
- package/dist/healthybowl/offline/store.js.map +1 -0
- package/dist/healthybowl/offline/syncEngine.js +141 -0
- package/dist/healthybowl/offline/syncEngine.js.map +1 -0
- package/dist/healthybowl/offline/types.js +15 -0
- package/dist/healthybowl/offline/types.js.map +1 -0
- package/dist/healthybowl/pages/field-capture/CaptureObservationForm.js +272 -0
- package/dist/healthybowl/pages/field-capture/CaptureObservationForm.js.map +1 -0
- package/dist/healthybowl/pages/field-capture/ConflictReviewPage.js +200 -0
- package/dist/healthybowl/pages/field-capture/ConflictReviewPage.js.map +1 -0
- package/dist/healthybowl/pages/field-capture/FieldCapturePage.js +60 -0
- package/dist/healthybowl/pages/field-capture/FieldCapturePage.js.map +1 -0
- package/dist/healthybowl/pages/field-capture/OfflineSettingsPage.js +217 -0
- package/dist/healthybowl/pages/field-capture/OfflineSettingsPage.js.map +1 -0
- package/dist/healthybowl/pages/field-capture/PendingSyncPage.js +80 -0
- package/dist/healthybowl/pages/field-capture/PendingSyncPage.js.map +1 -0
- package/dist/healthybowl/pages/field-capture/SyncHistoryPage.js +130 -0
- package/dist/healthybowl/pages/field-capture/SyncHistoryPage.js.map +1 -0
- package/dist/healthybowl/pages/field-capture/SyncQueuePanel.js +112 -0
- package/dist/healthybowl/pages/field-capture/SyncQueuePanel.js.map +1 -0
- package/dist/healthybowl/pages/traceability/PrintLabelDialog.js +296 -0
- package/dist/healthybowl/pages/traceability/PrintLabelDialog.js.map +1 -0
- package/dist/healthybowl/pages/traceability/QRCodesPage.js +450 -103
- package/dist/healthybowl/pages/traceability/QRCodesPage.js.map +1 -1
- package/dist/healthybowl/pages/traceability/TracePortalSettingsPage.js +249 -0
- package/dist/healthybowl/pages/traceability/TracePortalSettingsPage.js.map +1 -0
- package/dist/healthybowl/public/PublicTraceJourney.js +192 -0
- package/dist/healthybowl/public/PublicTraceJourney.js.map +1 -0
- package/dist/healthybowl/public/PublicTraceNotFound.js +55 -0
- package/dist/healthybowl/public/PublicTraceNotFound.js.map +1 -0
- package/dist/healthybowl/public/PublicTracePage.js +46 -0
- package/dist/healthybowl/public/PublicTracePage.js.map +1 -0
- package/dist/index.js +4 -3
- 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
|
|
7
|
-
import { ToastContainer as
|
|
8
|
-
import { LoadingSkeleton as
|
|
9
|
-
import { useToast as
|
|
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
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
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
|
|
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
|
-
},
|
|
27
|
-
let { t:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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:
|
|
106
|
+
count: 4
|
|
42
107
|
})
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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:
|
|
49
|
-
description:
|
|
114
|
+
title: T("healthybowl.traceability.qRCodes.error.title", "Unable to load traceability data"),
|
|
115
|
+
description: D.message
|
|
50
116
|
})
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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:
|
|
57
|
-
description:
|
|
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
|
-
})
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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__ */
|
|
65
|
-
className: "
|
|
66
|
-
children: x("
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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:
|
|
81
|
-
})] }), /* @__PURE__ */
|
|
82
|
-
label:
|
|
83
|
-
variant:
|
|
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__ */
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
className: "
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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__ */
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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__ */
|
|
107
|
-
|
|
108
|
-
|
|
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__ */
|
|
112
|
-
className: "mt-
|
|
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__ */
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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__ */
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
-
},
|
|
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__ */
|
|
137
|
-
|
|
138
|
-
|
|
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 {
|
|
491
|
+
export { T as QRCodesPage };
|
|
145
492
|
|
|
146
493
|
//# sourceMappingURL=QRCodesPage.js.map
|