@burdenoff/microfe-healthybowl 2026.813.15 → 2026.813.16

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.
@@ -0,0 +1,73 @@
1
+ import { setHbFormatLocale as e } from "../utils/helpers.js";
2
+ import { useEffect as t, useRef as n } from "react";
3
+ import { useI18n as r } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
4
+ import { jsx as i } from "react/jsx-runtime";
5
+ import { LanguageSwitcher as a } from "@burdenoff/fe-libs/chrome";
6
+ //#region src/healthybowl/public/PortalLanguagePicker.tsx
7
+ var o = [
8
+ {
9
+ code: "en",
10
+ name: "English",
11
+ nativeName: "English"
12
+ },
13
+ {
14
+ code: "hi",
15
+ name: "Hindi",
16
+ nativeName: "हिन्दी"
17
+ },
18
+ {
19
+ code: "ta",
20
+ name: "Tamil",
21
+ nativeName: "தமிழ்"
22
+ },
23
+ {
24
+ code: "zh",
25
+ name: "Chinese",
26
+ nativeName: "中文"
27
+ },
28
+ {
29
+ code: "es",
30
+ name: "Spanish",
31
+ nativeName: "Español"
32
+ },
33
+ {
34
+ code: "ar",
35
+ name: "Arabic",
36
+ nativeName: "العربية"
37
+ }
38
+ ], s = new Set(o.map((e) => e.code)), c = new Set(["ar"]);
39
+ function l(e) {
40
+ if (!e) return null;
41
+ let t = e.trim().toLowerCase().split("-")[0];
42
+ return t && s.has(t) ? t : null;
43
+ }
44
+ var u = () => {
45
+ let { locale: s, setLocale: u } = r(), d = n(!1);
46
+ return t(() => {
47
+ if (d.current || (d.current = !0, typeof window > "u")) return;
48
+ let e = l(new URLSearchParams(window.location.search).get("lang")), t = l(window.navigator?.language), n = e ?? t;
49
+ n && n !== s && u(n);
50
+ }, [s, u]), t(() => {
51
+ e(s);
52
+ let t = document.documentElement, n = t.getAttribute("dir");
53
+ return t.setAttribute("dir", c.has(s) ? "rtl" : "ltr"), () => {
54
+ n === null ? t.removeAttribute("dir") : t.setAttribute("dir", n);
55
+ };
56
+ }, [s]), /* @__PURE__ */ i("span", {
57
+ "data-testid": "portal-language-picker",
58
+ "data-active-locale": s,
59
+ children: /* @__PURE__ */ i(a, {
60
+ languages: [...o],
61
+ currentLanguage: s,
62
+ onLanguageChange: (e) => {
63
+ let t = l(e.code);
64
+ t && u(t);
65
+ },
66
+ compact: !0
67
+ })
68
+ });
69
+ };
70
+ //#endregion
71
+ export { u as PortalLanguagePicker };
72
+
73
+ //# sourceMappingURL=PortalLanguagePicker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PortalLanguagePicker.js","names":[],"sources":["../../../src/healthybowl/public/PortalLanguagePicker.tsx"],"sourcesContent":["/**\n * Language control + locale bootstrap for the public farm-to-fork portal (BOFF-6104).\n *\n * ## Why the portal needs its own\n *\n * `/b/:slug` renders chrome-less (`healthybowl-app` `App.tsx` → `ConditionalShell`), so the shell\n * header — and with it the usual language switcher — is not on the page. A shopper who scans a\n * printed QR has no way to change language without this.\n *\n * ## Why keying strings alone would not have fixed the bug\n *\n * fe-libs `resolveInitialLocale()` reads `bf-p-<pid>-locale`, then `burdenoff-locale`, then falls\n * back to `defaultLocale` ('en'). Nothing reads `?lang=` and nothing reads `navigator.language`.\n * An anonymous shopper has no profile and an empty localStorage, so the locale is unconditionally\n * English — translating every string would still have shown an English page to everybody.\n *\n * Discovery order here is deliberate:\n * 1. `?lang=` — explicit, and the only thing a freshly generated QR can carry.\n * 2. `navigator.language` — the reach for QR codes ALREADY PRINTED, which have no lang param.\n * Without this those codes are permanently English no matter what we ship.\n * 3. leave whatever the provider resolved (English).\n *\n * `setLocale` persists to `burdenoff-locale` and sets `<html lang>`, so a refresh keeps the choice.\n */\nimport { useEffect, useRef } from 'react';\nimport { LanguageSwitcher } from '@burdenoff/fe-libs/chrome';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { setHbFormatLocale } from '../utils/helpers';\n\n/**\n * HealthyBowl's six shipped locales, hard-coded rather than fetched.\n *\n * `useLanguages({ autoFetch: true })` would put an anonymous gateway round-trip on the first paint\n * of a page a shopper reaches from a phone camera, to learn a list that has not changed since the\n * product shipped.\n */\nconst PORTAL_LANGUAGES = [\n { code: 'en', name: 'English', nativeName: 'English' },\n { code: 'hi', name: 'Hindi', nativeName: 'हिन्दी' },\n { code: 'ta', name: 'Tamil', nativeName: 'தமிழ்' },\n { code: 'zh', name: 'Chinese', nativeName: '中文' },\n { code: 'es', name: 'Spanish', nativeName: 'Español' },\n { code: 'ar', name: 'Arabic', nativeName: 'العربية' },\n] as const;\n\nconst SUPPORTED = new Set<string>(PORTAL_LANGUAGES.map((l) => l.code));\n\n/** Mirrors `RTL_LOCALES` in HealthyBowlRoot — see the effect below for why it is duplicated. */\nconst RTL_LOCALES = new Set<string>(['ar']);\n\ntype PortalLocale = (typeof PORTAL_LANGUAGES)[number]['code'];\n\n/** Narrow an arbitrary string to one of the six, or null. Accepts `ta-IN` for `ta`. */\nexport function resolvePortalLocale(raw: string | null | undefined): PortalLocale | null {\n if (!raw) return null;\n const base = raw.trim().toLowerCase().split('-')[0];\n return base && SUPPORTED.has(base) ? (base as PortalLocale) : null;\n}\n\nexport const PortalLanguagePicker = () => {\n const { locale, setLocale } = useI18n();\n // The bootstrap must run once. Without this guard, navigating back to a URL that still carries\n // ?lang= would re-apply it and silently undo a choice the shopper just made with the picker.\n const bootstrapped = useRef(false);\n\n useEffect(() => {\n if (bootstrapped.current) return;\n bootstrapped.current = true;\n if (typeof window === 'undefined') return;\n\n const fromQuery = resolvePortalLocale(new URLSearchParams(window.location.search).get('lang'));\n const fromBrowser = resolvePortalLocale(window.navigator?.language);\n const next = fromQuery ?? fromBrowser;\n\n // Only override when we actually resolved something, and only when it differs — calling\n // setLocale with the current value would write localStorage for no reason.\n if (next && next !== locale) setLocale(next as Parameters<typeof setLocale>[0]);\n }, [locale, setLocale]);\n\n /**\n * BOFF-6119 gave HealthyBowl real Arabic RTL, but it lives in `HealthyBowlRoot`, and this portal\n * is mounted directly by the app (`AppRoutes.tsx` → `HealthyBowlPublicTracePage`) rather than\n * through the Root. So the consumer-facing page — the one surface a non-customer actually sees —\n * was the single HB screen that would still render Arabic unmirrored. Same for\n * `setHbFormatLocale`, which the Root syncs for the shared `Intl` helpers.\n *\n * Duplicated here rather than imported from the Root because importing the Root would drag the\n * entire authenticated product graph into a public bundle.\n */\n useEffect(() => {\n setHbFormatLocale(locale);\n const el = document.documentElement;\n const previous = el.getAttribute('dir');\n el.setAttribute('dir', RTL_LOCALES.has(locale) ? 'rtl' : 'ltr');\n return () => {\n if (previous === null) el.removeAttribute('dir');\n else el.setAttribute('dir', previous);\n };\n }, [locale]);\n\n return (\n <span data-testid=\"portal-language-picker\" data-active-locale={locale}>\n <LanguageSwitcher\n languages={[...PORTAL_LANGUAGES]}\n currentLanguage={locale}\n onLanguageChange={(language) => {\n const next = resolvePortalLocale(language.code);\n if (next) setLocale(next as Parameters<typeof setLocale>[0]);\n }}\n compact\n />\n </span>\n );\n};\n"],"mappings":";;;;;;AAoCA,IAAM,IAAmB;CACvB;EAAE,MAAM;EAAM,MAAM;EAAW,YAAY;EAAW;CACtD;EAAE,MAAM;EAAM,MAAM;EAAS,YAAY;EAAU;CACnD;EAAE,MAAM;EAAM,MAAM;EAAS,YAAY;EAAS;CAClD;EAAE,MAAM;EAAM,MAAM;EAAW,YAAY;EAAM;CACjD;EAAE,MAAM;EAAM,MAAM;EAAW,YAAY;EAAW;CACtD;EAAE,MAAM;EAAM,MAAM;EAAU,YAAY;EAAW;CACtD,EAEK,IAAY,IAAI,IAAY,EAAiB,KAAK,MAAM,EAAE,KAAK,CAAC,EAGhE,IAAc,IAAI,IAAY,CAAC,KAAK,CAAC;AAK3C,SAAgB,EAAoB,GAAqD;AACvF,KAAI,CAAC,EAAK,QAAO;CACjB,IAAM,IAAO,EAAI,MAAM,CAAC,aAAa,CAAC,MAAM,IAAI,CAAC;AACjD,QAAO,KAAQ,EAAU,IAAI,EAAK,GAAI,IAAwB;;AAGhE,IAAa,UAA6B;CACxC,IAAM,EAAE,WAAQ,iBAAc,GAAS,EAGjC,IAAe,EAAO,GAAM;AAqClC,QAnCA,QAAgB;AAGd,MAFI,EAAa,YACjB,EAAa,UAAU,IACnB,OAAO,SAAW,KAAa;EAEnC,IAAM,IAAY,EAAoB,IAAI,gBAAgB,OAAO,SAAS,OAAO,CAAC,IAAI,OAAO,CAAC,EACxF,IAAc,EAAoB,OAAO,WAAW,SAAS,EAC7D,IAAO,KAAa;AAI1B,EAAI,KAAQ,MAAS,KAAQ,EAAU,EAAwC;IAC9E,CAAC,GAAQ,EAAU,CAAC,EAYvB,QAAgB;AACd,IAAkB,EAAO;EACzB,IAAM,IAAK,SAAS,iBACd,IAAW,EAAG,aAAa,MAAM;AAEvC,SADA,EAAG,aAAa,OAAO,EAAY,IAAI,EAAO,GAAG,QAAQ,MAAM,QAClD;AACX,GAAI,MAAa,OAAM,EAAG,gBAAgB,MAAM,GAC3C,EAAG,aAAa,OAAO,EAAS;;IAEtC,CAAC,EAAO,CAAC,EAGV,kBAAC,QAAD;EAAM,eAAY;EAAyB,sBAAoB;YAC7D,kBAAC,GAAD;GACE,WAAW,CAAC,GAAG,EAAiB;GAChC,iBAAiB;GACjB,mBAAmB,MAAa;IAC9B,IAAM,IAAO,EAAoB,EAAS,KAAK;AAC/C,IAAI,KAAM,EAAU,EAAwC;;GAE9D,SAAA;GACA,CAAA;EACG,CAAA"}
@@ -1,205 +1,235 @@
1
- import { AlertOctagon as e, BadgeCheck as t, Droplets as n, Leaf as r, MapPin as i, Package as a, Sprout as o, Truck as s } from "lucide-react";
2
- import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
1
+ import { PortalLanguagePicker as e } from "./PortalLanguagePicker.js";
2
+ import { useI18n as t } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
3
+ import { AlertOctagon as n, BadgeCheck as r, Droplets as i, Leaf as a, MapPin as o, Package as s, Sprout as c, Truck as l } from "lucide-react";
4
+ import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
3
5
  //#region src/healthybowl/public/PublicTraceJourney.tsx
4
- function d(e) {
6
+ function p(e, t = "en-GB") {
5
7
  if (!e) return null;
6
- let t = new Date(e);
7
- return Number.isNaN(t.getTime()) ? null : t.toLocaleDateString("en-GB", {
8
+ let n = new Date(e);
9
+ return Number.isNaN(n.getTime()) ? null : n.toLocaleDateString(t, {
8
10
  day: "2-digit",
9
11
  month: "short",
10
12
  year: "numeric",
11
13
  timeZone: "UTC"
12
14
  });
13
15
  }
14
- function f(e) {
16
+ function m(e) {
15
17
  let t = e.toLowerCase();
16
- return t.includes("harvest") ? /* @__PURE__ */ l(r, { className: "h-4 w-4" }) : t.includes("process") || t.includes("wash") ? /* @__PURE__ */ l(n, { className: "h-4 w-4" }) : t.includes("pack") ? /* @__PURE__ */ l(a, { className: "h-4 w-4" }) : t.includes("ship") || t.includes("transit") || t.includes("deliver") || t.includes("dispatch") ? /* @__PURE__ */ l(s, { className: "h-4 w-4" }) : /* @__PURE__ */ l(o, { className: "h-4 w-4" });
18
+ return t.includes("harvest") ? /* @__PURE__ */ d(a, { className: "h-4 w-4" }) : t.includes("process") || t.includes("wash") ? /* @__PURE__ */ d(i, { className: "h-4 w-4" }) : t.includes("pack") ? /* @__PURE__ */ d(s, { className: "h-4 w-4" }) : t.includes("ship") || t.includes("transit") || t.includes("deliver") || t.includes("dispatch") ? /* @__PURE__ */ d(l, { className: "h-4 w-4" }) : /* @__PURE__ */ d(c, { className: "h-4 w-4" });
17
19
  }
18
- function p(e) {
19
- let t = [];
20
- e.origin && t.push({
20
+ var h = {
21
+ grown: "Grown",
22
+ harvested: "Harvested",
23
+ packed: "Packed",
24
+ locale: "en-GB"
25
+ };
26
+ function g(e, t = h) {
27
+ let n = [];
28
+ e.origin && n.push({
21
29
  key: "grown",
22
- title: "Grown",
30
+ title: t.grown,
23
31
  detail: e.origin,
24
- icon: /* @__PURE__ */ l(o, { className: "h-4 w-4" })
32
+ icon: /* @__PURE__ */ d(c, { className: "h-4 w-4" })
25
33
  });
26
- let n = d(e.harvestDate);
27
- n && !e.supplyChainSteps.some((e) => e.step.toLowerCase().includes("harvest")) && t.push({
34
+ let r = p(e.harvestDate, t.locale);
35
+ r && !e.supplyChainSteps.some((e) => e.step.toLowerCase().includes("harvest")) && n.push({
28
36
  key: "harvested",
29
- title: "Harvested",
30
- detail: n,
31
- icon: /* @__PURE__ */ l(r, { className: "h-4 w-4" })
32
- }), e.supplyChainSteps.forEach((e, n) => {
33
- let r = [e.location, d(e.date) ?? e.date].filter(Boolean);
34
- t.push({
35
- key: `step-${n}-${e.step}`,
37
+ title: t.harvested,
38
+ detail: r,
39
+ icon: /* @__PURE__ */ d(a, { className: "h-4 w-4" })
40
+ }), e.supplyChainSteps.forEach((e, r) => {
41
+ let i = [e.location, p(e.date, t.locale) ?? e.date].filter(Boolean);
42
+ n.push({
43
+ key: `step-${r}-${e.step}`,
36
44
  title: e.step,
37
- detail: r.length ? r.join(" · ") : null,
38
- icon: f(e.step)
45
+ detail: i.length ? i.join(" · ") : null,
46
+ icon: m(e.step)
39
47
  });
40
48
  });
41
- let i = d(e.packagingDate);
42
- return i && !e.supplyChainSteps.some((e) => e.step.toLowerCase().includes("pack")) && t.push({
49
+ let i = p(e.packagingDate, t.locale);
50
+ return i && !e.supplyChainSteps.some((e) => e.step.toLowerCase().includes("pack")) && n.push({
43
51
  key: "packed",
44
- title: "Packed",
52
+ title: t.packed,
45
53
  detail: i,
46
- icon: /* @__PURE__ */ l(a, { className: "h-4 w-4" })
47
- }), t;
54
+ icon: /* @__PURE__ */ d(s, { className: "h-4 w-4" })
55
+ }), n;
48
56
  }
49
- var m = ({ batch: n }) => {
50
- let a = p(n), o = d(n.expiryDate);
51
- return /* @__PURE__ */ u("main", {
57
+ var _ = ({ batch: i }) => {
58
+ let { t: s, locale: c } = t(), l = g(i, {
59
+ grown: s("healthybowl.traceability.publicPortal.leg.grown", "Grown"),
60
+ harvested: s("healthybowl.traceability.publicPortal.leg.harvested", "Harvested"),
61
+ packed: s("healthybowl.traceability.publicPortal.leg.packed", "Packed"),
62
+ locale: c
63
+ }), m = p(i.expiryDate, c);
64
+ return /* @__PURE__ */ f("main", {
52
65
  className: "min-h-screen bg-bg-canvas pb-12",
53
66
  "data-testid": "public-trace-page",
54
- children: [/* @__PURE__ */ u("header", {
67
+ children: [/* @__PURE__ */ f("header", {
55
68
  className: "bg-accent-teal/10 px-4 pb-10 pt-8 text-center",
56
69
  children: [
57
- /* @__PURE__ */ u("div", {
58
- className: "mx-auto flex max-w-lg items-center justify-center gap-2",
59
- children: [/* @__PURE__ */ l(r, {
60
- className: "h-6 w-6 text-accent-teal",
61
- "aria-hidden": !0
62
- }), /* @__PURE__ */ l("span", {
63
- className: "text-lg font-semibold text-text-primary",
64
- children: "HealthyBowl"
65
- })]
70
+ /* @__PURE__ */ f("div", {
71
+ className: "mx-auto flex max-w-lg items-center justify-between gap-2",
72
+ children: [
73
+ /* @__PURE__ */ d("span", {
74
+ className: "w-24",
75
+ "aria-hidden": !0
76
+ }),
77
+ /* @__PURE__ */ f("span", {
78
+ className: "flex items-center gap-2",
79
+ children: [/* @__PURE__ */ d(a, {
80
+ className: "h-6 w-6 text-accent-teal",
81
+ "aria-hidden": !0
82
+ }), /* @__PURE__ */ d("span", {
83
+ className: "text-lg font-semibold text-text-primary",
84
+ children: "HealthyBowl"
85
+ })]
86
+ }),
87
+ /* @__PURE__ */ d(e, {})
88
+ ]
66
89
  }),
67
- /* @__PURE__ */ l("h1", {
90
+ /* @__PURE__ */ d("h1", {
68
91
  className: "mt-5 text-2xl font-bold text-text-primary sm:text-3xl",
69
- children: "Your food’s journey"
92
+ children: s("healthybowl.traceability.publicPortal.title", "Your food's journey")
70
93
  }),
71
- /* @__PURE__ */ u("p", {
94
+ /* @__PURE__ */ f("p", {
72
95
  className: "mt-1 text-sm text-text-secondary",
73
96
  "data-testid": "public-trace-subtitle",
74
97
  children: [
75
- n.product,
76
- " · Batch ",
77
- n.batchCode
98
+ i.product,
99
+ " · ",
100
+ s("healthybowl.traceability.publicPortal.batch", "Batch"),
101
+ " ",
102
+ i.batchCode
78
103
  ]
79
104
  }),
80
- n.portal.tagline ? /* @__PURE__ */ l("p", {
105
+ i.portal.tagline ? /* @__PURE__ */ d("p", {
81
106
  className: "mx-auto mt-3 max-w-md text-sm italic text-text-secondary",
82
- children: n.portal.tagline
107
+ children: i.portal.tagline
83
108
  }) : null
84
109
  ]
85
- }), /* @__PURE__ */ u("div", {
110
+ }), /* @__PURE__ */ f("div", {
86
111
  className: "mx-auto -mt-6 max-w-lg px-4",
87
112
  children: [
88
- n.recalled ? /* @__PURE__ */ l("section", {
113
+ i.recalled ? /* @__PURE__ */ d("section", {
89
114
  className: "mb-4 rounded-xl border border-status-error-border bg-status-error-bg p-4 shadow-sm",
90
115
  "data-testid": "public-trace-recall-notice",
91
116
  role: "alert",
92
- children: /* @__PURE__ */ u("div", {
117
+ children: /* @__PURE__ */ f("div", {
93
118
  className: "flex items-start gap-3",
94
- children: [/* @__PURE__ */ l(e, {
119
+ children: [/* @__PURE__ */ d(n, {
95
120
  className: "mt-0.5 h-6 w-6 shrink-0 text-status-error-text",
96
121
  "aria-hidden": !0
97
- }), /* @__PURE__ */ u("div", { children: [/* @__PURE__ */ l("p", {
122
+ }), /* @__PURE__ */ f("div", { children: [/* @__PURE__ */ d("p", {
98
123
  className: "text-base font-bold text-status-error-text",
99
- children: "This product has been recalled"
100
- }), /* @__PURE__ */ l("p", {
124
+ children: s("healthybowl.traceability.publicPortal.recall.heading", "This product has been recalled")
125
+ }), /* @__PURE__ */ d("p", {
101
126
  className: "mt-1 text-sm text-text-primary",
102
- children: n.recallNotice ? n.recallNotice : "The grower has recalled this batch. Do not consume it, and contact your point of purchase."
127
+ children: i.recallNotice ? i.recallNotice : s("healthybowl.traceability.publicPortal.recall.defaultNotice", "The grower has recalled this batch. Do not consume it, and contact your point of purchase.")
103
128
  })] })]
104
129
  })
105
130
  }) : null,
106
- n.recalled ? null : /* @__PURE__ */ u(c, { children: [
107
- n.origin ? /* @__PURE__ */ l("section", {
131
+ i.recalled ? null : /* @__PURE__ */ f(u, { children: [
132
+ i.origin ? /* @__PURE__ */ d("section", {
108
133
  className: "rounded-xl border border-border-subtle bg-bg-surface p-4 shadow-sm",
109
- children: /* @__PURE__ */ u("div", {
134
+ children: /* @__PURE__ */ f("div", {
110
135
  className: "flex items-start gap-3",
111
- children: [/* @__PURE__ */ l(i, {
136
+ children: [/* @__PURE__ */ d(o, {
112
137
  className: "mt-0.5 h-5 w-5 shrink-0 text-accent-teal",
113
138
  "aria-hidden": !0
114
- }), /* @__PURE__ */ u("div", { children: [/* @__PURE__ */ l("p", {
139
+ }), /* @__PURE__ */ f("div", { children: [/* @__PURE__ */ d("p", {
115
140
  className: "text-sm font-semibold text-text-primary",
116
141
  "data-testid": "public-trace-origin",
117
- children: n.origin
118
- }), /* @__PURE__ */ l("p", {
142
+ children: i.origin
143
+ }), /* @__PURE__ */ d("p", {
119
144
  className: "mt-0.5 text-xs text-text-secondary",
120
- children: "Farm origin recorded by the grower"
145
+ children: s("healthybowl.traceability.publicPortal.originCaption", "Farm origin recorded by the grower")
121
146
  })] })]
122
147
  })
123
148
  }) : null,
124
- n.portal.showVerifiedOrganicBanner ? /* @__PURE__ */ u("section", {
149
+ i.portal.showVerifiedOrganicBanner ? /* @__PURE__ */ f("section", {
125
150
  className: "mt-4 flex items-center gap-3 rounded-xl border border-accent-teal/30 bg-accent-teal/10 p-4",
126
151
  "data-testid": "public-trace-verified-banner",
127
- children: [/* @__PURE__ */ l(t, {
152
+ children: [/* @__PURE__ */ d(r, {
128
153
  className: "h-5 w-5 shrink-0 text-accent-teal",
129
154
  "aria-hidden": !0
130
- }), /* @__PURE__ */ l("p", {
155
+ }), /* @__PURE__ */ d("p", {
131
156
  className: "text-sm font-medium text-text-primary",
132
- children: "Verified Organic"
157
+ children: s("healthybowl.traceability.publicPortal.verifiedOrganic", "Verified Organic")
133
158
  })]
134
159
  }) : null,
135
- a.length > 0 ? /* @__PURE__ */ u("section", {
160
+ l.length > 0 ? /* @__PURE__ */ f("section", {
136
161
  className: "mt-6",
137
- children: [/* @__PURE__ */ l("h2", {
162
+ children: [/* @__PURE__ */ d("h2", {
138
163
  className: "text-sm font-semibold uppercase tracking-wide text-text-secondary",
139
- children: "Friendly journey"
140
- }), /* @__PURE__ */ l("ol", {
164
+ children: s("healthybowl.traceability.publicPortal.journeyHeading", "Friendly journey")
165
+ }), /* @__PURE__ */ d("ol", {
141
166
  className: "mt-3 space-y-1",
142
167
  "data-testid": "public-trace-journey",
143
- children: a.map((e, t) => /* @__PURE__ */ u("li", {
168
+ children: l.map((e, t) => /* @__PURE__ */ f("li", {
144
169
  className: "flex gap-3",
145
- children: [/* @__PURE__ */ u("div", {
170
+ children: [/* @__PURE__ */ f("div", {
146
171
  className: "flex flex-col items-center",
147
- children: [/* @__PURE__ */ l("span", {
172
+ children: [/* @__PURE__ */ d("span", {
148
173
  className: "flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-accent-teal/15 text-accent-teal",
149
174
  children: e.icon
150
- }), t < a.length - 1 ? /* @__PURE__ */ l("span", { className: "my-1 w-px flex-1 bg-accent-teal/30" }) : null]
151
- }), /* @__PURE__ */ u("div", {
175
+ }), t < l.length - 1 ? /* @__PURE__ */ d("span", { className: "my-1 w-px flex-1 bg-accent-teal/30" }) : null]
176
+ }), /* @__PURE__ */ f("div", {
152
177
  className: "pb-5 pt-1.5",
153
- children: [/* @__PURE__ */ l("p", {
178
+ children: [/* @__PURE__ */ d("p", {
154
179
  className: "text-sm font-semibold text-text-primary",
155
180
  children: e.title
156
- }), e.detail ? /* @__PURE__ */ l("p", {
181
+ }), e.detail ? /* @__PURE__ */ d("p", {
157
182
  className: "mt-0.5 text-sm text-text-secondary",
158
183
  children: e.detail
159
184
  }) : null]
160
185
  })]
161
186
  }, e.key))
162
187
  })]
163
- }) : /* @__PURE__ */ l("p", {
188
+ }) : /* @__PURE__ */ d("p", {
164
189
  className: "mt-6 text-sm text-text-secondary",
165
- children: "This batch has no journey steps recorded yet. Nothing here is invented — the grower simply hasn’t logged them."
190
+ children: s("healthybowl.traceability.publicPortal.noJourney", "This batch has no journey steps recorded yet. Nothing here is invented — the grower simply hasn't logged them.")
166
191
  }),
167
- n.certifications.length > 0 ? /* @__PURE__ */ u("section", {
192
+ i.certifications.length > 0 ? /* @__PURE__ */ f("section", {
168
193
  className: "mt-4",
169
- children: [/* @__PURE__ */ l("h2", {
194
+ children: [/* @__PURE__ */ d("h2", {
170
195
  className: "text-sm font-semibold uppercase tracking-wide text-text-secondary",
171
- children: "Certifications"
172
- }), /* @__PURE__ */ l("div", {
196
+ children: s("healthybowl.traceability.publicPortal.certifications", "Certifications")
197
+ }), /* @__PURE__ */ d("div", {
173
198
  className: "mt-3 grid gap-3 sm:grid-cols-2",
174
199
  "data-testid": "public-trace-certifications",
175
- children: n.certifications.map((e) => /* @__PURE__ */ u("div", {
200
+ children: i.certifications.map((e) => /* @__PURE__ */ f("div", {
176
201
  className: "flex items-center gap-2 rounded-xl bg-accent-teal/10 px-3 py-3 text-sm font-medium text-text-primary",
177
- children: [/* @__PURE__ */ l(t, {
202
+ children: [/* @__PURE__ */ d(r, {
178
203
  className: "h-4 w-4 shrink-0 text-accent-teal",
179
204
  "aria-hidden": !0
180
205
  }), e]
181
206
  }, e))
182
207
  })]
183
208
  }) : null,
184
- o ? /* @__PURE__ */ u("p", {
209
+ m ? /* @__PURE__ */ f("p", {
185
210
  className: "mt-6 text-center text-sm text-text-secondary",
186
211
  "data-testid": "public-trace-best-before",
187
- children: ["Best before: ", o]
212
+ children: [
213
+ s("healthybowl.traceability.publicPortal.bestBefore", "Best before:"),
214
+ " ",
215
+ m
216
+ ]
188
217
  }) : null
189
218
  ] }),
190
- /* @__PURE__ */ u("footer", {
219
+ /* @__PURE__ */ f("footer", {
191
220
  className: "mt-10 border-t border-border-subtle pt-5 text-center text-xs text-text-secondary",
192
- children: [/* @__PURE__ */ u("p", { children: [
193
- "Verified by HealthyBowl ·",
221
+ children: [/* @__PURE__ */ f("p", { children: [
222
+ s("healthybowl.traceability.publicPortal.verifiedBy", "Verified by HealthyBowl"),
223
+ " ·",
194
224
  " ",
195
- /* @__PURE__ */ l("a", {
225
+ /* @__PURE__ */ d("a", {
196
226
  href: "https://gethealthybowl.com",
197
227
  className: "underline hover:text-text-primary",
198
228
  children: "gethealthybowl.com"
199
229
  })
200
- ] }), /* @__PURE__ */ l("p", {
230
+ ] }), /* @__PURE__ */ d("p", {
201
231
  className: "mt-1",
202
- children: "Organic. Traceable. Trusted."
232
+ children: s("healthybowl.traceability.publicPortal.tagline", "Organic. Traceable. Trusted.")
203
233
  })]
204
234
  })
205
235
  ]
@@ -207,6 +237,6 @@ var m = ({ batch: n }) => {
207
237
  });
208
238
  };
209
239
  //#endregion
210
- export { m as PublicTraceJourney };
240
+ export { _ as PublicTraceJourney };
211
241
 
212
242
  //# sourceMappingURL=PublicTraceJourney.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PublicTraceJourney.js","names":[],"sources":["../../../src/healthybowl/public/PublicTraceJourney.tsx"],"sourcesContent":["/**\n * \"Your food's journey\" — the branded, read-only page a shopper sees after scanning (mockup 3).\n *\n * Renders only what the server chose to send. Every field is optional because the farmer can hide\n * any of them in Trace Portal settings, and a missing field is simply absent — never faked, never\n * back-filled with a placeholder date or a generic farm name.\n */\nimport { AlertOctagon, BadgeCheck, Leaf, MapPin, Package, Sprout, Truck, Droplets } from 'lucide-react';\nimport type { ReactNode } from 'react';\n\nexport interface PublicTraceStep {\n step: string;\n location: string | null;\n date: string | null;\n verified: boolean;\n}\n\nexport interface PublicTraceBatch {\n batchCode: string;\n product: string;\n origin: string | null;\n harvestDate: string | null;\n processingDate: string | null;\n packagingDate: string | null;\n expiryDate: string | null;\n certifications: string[];\n publishedAt: string;\n publicSlug: string;\n /** BOFF-6044: true when this batch has been recalled. Drives the recall notice below. */\n recalled: boolean;\n /** The grower's public-safe recall reason, when supplied. */\n recallNotice: string | null;\n supplyChainSteps: PublicTraceStep[];\n portal: { tagline: string | null; showVerifiedOrganicBanner: boolean };\n}\n\n/** `2026-06-12T00:00:00.000Z` → `12 Jun 2026`. Returns null for anything unparseable. */\nfunction formatDay(iso: string | null): string | null {\n if (!iso) return null;\n const date = new Date(iso);\n if (Number.isNaN(date.getTime())) return null;\n return date.toLocaleDateString('en-GB', { day: '2-digit', month: 'short', year: 'numeric', timeZone: 'UTC' });\n}\n\n/** Pick an icon from the step name, falling back to a neutral marker. Exported for unit testing. */\nexport function stepIcon(step: string): ReactNode {\n const name = step.toLowerCase();\n if (name.includes('harvest')) return <Leaf className=\"h-4 w-4\" />;\n if (name.includes('process') || name.includes('wash')) return <Droplets className=\"h-4 w-4\" />;\n if (name.includes('pack')) return <Package className=\"h-4 w-4\" />;\n if (name.includes('ship') || name.includes('transit') || name.includes('deliver') || name.includes('dispatch'))\n return <Truck className=\"h-4 w-4\" />;\n return <Sprout className=\"h-4 w-4\" />;\n}\n\ninterface JourneyEntry {\n key: string;\n title: string;\n detail: string | null;\n icon: ReactNode;\n}\n\n/**\n * Build the vertical timeline. The origin and harvest date are surfaced as their own legs (they\n * are the two things a shopper actually cares about), then the recorded supply-chain steps follow\n * in the order the farmer entered them.\n *\n * BOFF-6102: `supplyChainSteps` now carries the real appended ledger (BOFF-6155) once a batch has\n * events, so a HARVESTED event and a PACKED event can duplicate the synthetic harvest/pack legs\n * below — both are guarded to skip the synthetic leg when a matching step is already present.\n */\nexport function buildJourney(batch: PublicTraceBatch): JourneyEntry[] {\n const entries: JourneyEntry[] = [];\n\n if (batch.origin) {\n entries.push({ key: 'grown', title: 'Grown', detail: batch.origin, icon: <Sprout className=\"h-4 w-4\" /> });\n }\n // Only add the synthetic harvest leg when it isn't already told by a supply-chain step — a\n // real appended HARVESTED ledger event (BOFF-6155) would otherwise duplicate this leg.\n const harvested = formatDay(batch.harvestDate);\n if (harvested && !batch.supplyChainSteps.some((step) => step.step.toLowerCase().includes('harvest'))) {\n entries.push({ key: 'harvested', title: 'Harvested', detail: harvested, icon: <Leaf className=\"h-4 w-4\" /> });\n }\n\n batch.supplyChainSteps.forEach((step, index) => {\n const parts = [step.location, formatDay(step.date) ?? step.date].filter(Boolean) as string[];\n entries.push({\n key: `step-${index}-${step.step}`,\n title: step.step,\n detail: parts.length ? parts.join(' · ') : null,\n icon: stepIcon(step.step),\n });\n });\n\n // Only add a packaging leg when it isn't already told by a supply-chain step.\n const packaged = formatDay(batch.packagingDate);\n if (packaged && !batch.supplyChainSteps.some((step) => step.step.toLowerCase().includes('pack'))) {\n entries.push({ key: 'packed', title: 'Packed', detail: packaged, icon: <Package className=\"h-4 w-4\" /> });\n }\n\n return entries;\n}\n\nexport const PublicTraceJourney = ({ batch }: { batch: PublicTraceBatch }) => {\n const journey = buildJourney(batch);\n const bestBefore = formatDay(batch.expiryDate);\n\n return (\n <main className=\"min-h-screen bg-bg-canvas pb-12\" data-testid=\"public-trace-page\">\n <header className=\"bg-accent-teal/10 px-4 pb-10 pt-8 text-center\">\n <div className=\"mx-auto flex max-w-lg items-center justify-center gap-2\">\n <Leaf className=\"h-6 w-6 text-accent-teal\" aria-hidden />\n <span className=\"text-lg font-semibold text-text-primary\">HealthyBowl</span>\n </div>\n <h1 className=\"mt-5 text-2xl font-bold text-text-primary sm:text-3xl\">Your food&rsquo;s journey</h1>\n <p className=\"mt-1 text-sm text-text-secondary\" data-testid=\"public-trace-subtitle\">\n {batch.product} · Batch {batch.batchCode}\n </p>\n {batch.portal.tagline ? (\n <p className=\"mx-auto mt-3 max-w-md text-sm italic text-text-secondary\">{batch.portal.tagline}</p>\n ) : null}\n </header>\n\n <div className=\"mx-auto -mt-6 max-w-lg px-4\">\n {batch.recalled ? (\n <section\n className=\"mb-4 rounded-xl border border-status-error-border bg-status-error-bg p-4 shadow-sm\"\n data-testid=\"public-trace-recall-notice\"\n role=\"alert\"\n >\n <div className=\"flex items-start gap-3\">\n <AlertOctagon className=\"mt-0.5 h-6 w-6 shrink-0 text-status-error-text\" aria-hidden />\n <div>\n <p className=\"text-base font-bold text-status-error-text\">This product has been recalled</p>\n <p className=\"mt-1 text-sm text-text-primary\">\n {batch.recallNotice\n ? batch.recallNotice\n : 'The grower has recalled this batch. Do not consume it, and contact your point of purchase.'}\n </p>\n </div>\n </div>\n </section>\n ) : null}\n\n {/*\n When recalled, we deliberately show ONLY the recall notice above — never the clean\n farm-to-fork journey, origin card, certifications, best-before, or the \"Verified Organic\"\n banner. Rendering that reassuring content under a recall is exactly the mis-serving this\n feature exists to prevent (defence-in-depth: the server already suppresses it too).\n */}\n {!batch.recalled ? (\n <>\n {batch.origin ? (\n <section className=\"rounded-xl border border-border-subtle bg-bg-surface p-4 shadow-sm\">\n <div className=\"flex items-start gap-3\">\n <MapPin className=\"mt-0.5 h-5 w-5 shrink-0 text-accent-teal\" aria-hidden />\n <div>\n <p className=\"text-sm font-semibold text-text-primary\" data-testid=\"public-trace-origin\">\n {batch.origin}\n </p>\n <p className=\"mt-0.5 text-xs text-text-secondary\">Farm origin recorded by the grower</p>\n </div>\n </div>\n </section>\n ) : null}\n\n {batch.portal.showVerifiedOrganicBanner ? (\n <section\n className=\"mt-4 flex items-center gap-3 rounded-xl border border-accent-teal/30 bg-accent-teal/10 p-4\"\n data-testid=\"public-trace-verified-banner\"\n >\n <BadgeCheck className=\"h-5 w-5 shrink-0 text-accent-teal\" aria-hidden />\n <p className=\"text-sm font-medium text-text-primary\">Verified Organic</p>\n </section>\n ) : null}\n\n {journey.length > 0 ? (\n <section className=\"mt-6\">\n <h2 className=\"text-sm font-semibold uppercase tracking-wide text-text-secondary\">Friendly journey</h2>\n <ol className=\"mt-3 space-y-1\" data-testid=\"public-trace-journey\">\n {journey.map((entry, index) => (\n <li key={entry.key} className=\"flex gap-3\">\n <div className=\"flex flex-col items-center\">\n <span className=\"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-accent-teal/15 text-accent-teal\">\n {entry.icon}\n </span>\n {index < journey.length - 1 ? <span className=\"my-1 w-px flex-1 bg-accent-teal/30\" /> : null}\n </div>\n <div className=\"pb-5 pt-1.5\">\n <p className=\"text-sm font-semibold text-text-primary\">{entry.title}</p>\n {entry.detail ? <p className=\"mt-0.5 text-sm text-text-secondary\">{entry.detail}</p> : null}\n </div>\n </li>\n ))}\n </ol>\n </section>\n ) : (\n <p className=\"mt-6 text-sm text-text-secondary\">\n This batch has no journey steps recorded yet. Nothing here is invented — the grower simply hasn&rsquo;t\n logged them.\n </p>\n )}\n\n {batch.certifications.length > 0 ? (\n <section className=\"mt-4\">\n <h2 className=\"text-sm font-semibold uppercase tracking-wide text-text-secondary\">Certifications</h2>\n <div className=\"mt-3 grid gap-3 sm:grid-cols-2\" data-testid=\"public-trace-certifications\">\n {batch.certifications.map((certification) => (\n <div\n key={certification}\n className=\"flex items-center gap-2 rounded-xl bg-accent-teal/10 px-3 py-3 text-sm font-medium text-text-primary\"\n >\n <BadgeCheck className=\"h-4 w-4 shrink-0 text-accent-teal\" aria-hidden />\n {certification}\n </div>\n ))}\n </div>\n </section>\n ) : null}\n\n {bestBefore ? (\n <p className=\"mt-6 text-center text-sm text-text-secondary\" data-testid=\"public-trace-best-before\">\n Best before: {bestBefore}\n </p>\n ) : null}\n </>\n ) : null}\n\n <footer className=\"mt-10 border-t border-border-subtle pt-5 text-center text-xs text-text-secondary\">\n <p>\n Verified by HealthyBowl ·{' '}\n <a href=\"https://gethealthybowl.com\" className=\"underline hover:text-text-primary\">\n gethealthybowl.com\n </a>\n </p>\n <p className=\"mt-1\">Organic. Traceable. Trusted.</p>\n </footer>\n </div>\n </main>\n );\n};\n"],"mappings":";;;AAqCA,SAAS,EAAU,GAAmC;AACpD,KAAI,CAAC,EAAK,QAAO;CACjB,IAAM,IAAO,IAAI,KAAK,EAAI;AAE1B,QADI,OAAO,MAAM,EAAK,SAAS,CAAC,GAAS,OAClC,EAAK,mBAAmB,SAAS;EAAE,KAAK;EAAW,OAAO;EAAS,MAAM;EA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;MAG5C,CAAA;KAGL,EAAM,eAAe,SAAS,IAC7B,kBAAC,WAAD;MAAS,WAAU;gBAAnB,CACE,kBAAC,MAAD;OAAI,WAAU;iBAAoE;OAAmB,CAAA,EACrG,kBAAC,OAAD;OAAK,WAAU;OAAiC,eAAY;iBACzD,EAAM,eAAe,KAAK,MACzB,kBAAC,OAAD;QAEE,WAAU;kBAFZ,CAIE,kBAAC,GAAD;SAAY,WAAU;SAAoC,eAAA;SAAc,CAAA,EACvE,EACG;UALC,EAKD,CACN;OACE,CAAA,CACE;UACR;KAEH,IACC,kBAAC,KAAD;MAAG,WAAU;MAA+C,eAAY;gBAAxE,CAAmG,iBACnF,EACZ;UACF;KACH,EAAA,CAAA;IAGL,kBAAC,UAAD;KAAQ,WAAU;eAAlB,CACE,kBAAC,KAAD,EAAA,UAAA;MAAG;MACyB;MAC1B,kBAAC,KAAD;OAAG,MAAK;OAA6B,WAAU;iBAAoC;OAE/E,CAAA;MACF,EAAA,CAAA,EACJ,kBAAC,KAAD;MAAG,WAAU;gBAAO;MAAgC,CAAA,CAC7C;;IACL;KACD"}
1
+ {"version":3,"file":"PublicTraceJourney.js","names":[],"sources":["../../../src/healthybowl/public/PublicTraceJourney.tsx"],"sourcesContent":["/**\n * \"Your food's journey\" — the branded, read-only page a shopper sees after scanning (mockup 3).\n *\n * Renders only what the server chose to send. Every field is optional because the farmer can hide\n * any of them in Trace Portal settings, and a missing field is simply absent — never faked, never\n * back-filled with a placeholder date or a generic farm name.\n */\nimport { AlertOctagon, BadgeCheck, Leaf, MapPin, Package, Sprout, Truck, Droplets } from 'lucide-react';\nimport type { ReactNode } from 'react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { PortalLanguagePicker } from './PortalLanguagePicker';\n\nexport interface PublicTraceStep {\n step: string;\n location: string | null;\n date: string | null;\n verified: boolean;\n}\n\nexport interface PublicTraceBatch {\n batchCode: string;\n product: string;\n origin: string | null;\n harvestDate: string | null;\n processingDate: string | null;\n packagingDate: string | null;\n expiryDate: string | null;\n certifications: string[];\n publishedAt: string;\n publicSlug: string;\n /** BOFF-6044: true when this batch has been recalled. Drives the recall notice below. */\n recalled: boolean;\n /** The grower's public-safe recall reason, when supplied. */\n recallNotice: string | null;\n supplyChainSteps: PublicTraceStep[];\n portal: { tagline: string | null; showVerifiedOrganicBanner: boolean };\n}\n\n/**\n * `2026-06-12T00:00:00.000Z` → `12 Jun 2026` in English, `١٢ يونيو ٢٠٢٦` in Arabic, and so on.\n * Returns null for anything unparseable.\n *\n * `locale` defaults to `en-GB` so the existing pure-function tests keep their expectations; the\n * page always passes the active locale (BOFF-6104 — this used to be hard-coded, so every date on\n * a Tamil or Arabic page rendered in British English).\n *\n * `timeZone: 'UTC'` is NOT optional. These are date-only values stored at UTC midnight; formatting\n * them in the viewer's zone shifts them a day backwards for anyone west of Greenwich, so a batch\n * harvested on the 12th reads as the 11th to a shopper in New York.\n */\nfunction formatDay(iso: string | null, locale = 'en-GB'): string | null {\n if (!iso) return null;\n const date = new Date(iso);\n if (Number.isNaN(date.getTime())) return null;\n return date.toLocaleDateString(locale, { day: '2-digit', month: 'short', year: 'numeric', timeZone: 'UTC' });\n}\n\n/** Pick an icon from the step name, falling back to a neutral marker. Exported for unit testing. */\nexport function stepIcon(step: string): ReactNode {\n const name = step.toLowerCase();\n if (name.includes('harvest')) return <Leaf className=\"h-4 w-4\" />;\n if (name.includes('process') || name.includes('wash')) return <Droplets className=\"h-4 w-4\" />;\n if (name.includes('pack')) return <Package className=\"h-4 w-4\" />;\n if (name.includes('ship') || name.includes('transit') || name.includes('deliver') || name.includes('dispatch'))\n return <Truck className=\"h-4 w-4\" />;\n return <Sprout className=\"h-4 w-4\" />;\n}\n\ninterface JourneyEntry {\n key: string;\n title: string;\n detail: string | null;\n icon: ReactNode;\n}\n\n/**\n * Build the vertical timeline. The origin and harvest date are surfaced as their own legs (they\n * are the two things a shopper actually cares about), then the recorded supply-chain steps follow\n * in the order the farmer entered them.\n *\n * BOFF-6102: `supplyChainSteps` now carries the real appended ledger (BOFF-6155) once a batch has\n * events, so a HARVESTED event and a PACKED event can duplicate the synthetic harvest/pack legs\n * below — both are guarded to skip the synthetic leg when a matching step is already present.\n */\nexport interface JourneyLabels {\n grown: string;\n harvested: string;\n packed: string;\n locale: string;\n}\n\n/**\n * English defaults so the exported pure function stays callable (and testable) with one argument.\n * The page passes translated labels and the active locale.\n *\n * Note what is NOT in here: `supplyChainSteps[].step` and `.location`. Those are the grower's own\n * words on the public allow-list, and an untranslated farm name or step label is correct — machine\n * -translating \"Washed & Graded at Nilgiris Unit 2\" would misrepresent what the grower recorded.\n */\nconst DEFAULT_JOURNEY_LABELS: JourneyLabels = {\n grown: 'Grown',\n harvested: 'Harvested',\n packed: 'Packed',\n locale: 'en-GB',\n};\n\nexport function buildJourney(batch: PublicTraceBatch, labels: JourneyLabels = DEFAULT_JOURNEY_LABELS): JourneyEntry[] {\n const entries: JourneyEntry[] = [];\n\n if (batch.origin) {\n entries.push({ key: 'grown', title: labels.grown, detail: batch.origin, icon: <Sprout className=\"h-4 w-4\" /> });\n }\n // Only add the synthetic harvest leg when it isn't already told by a supply-chain step — a\n // real appended HARVESTED ledger event (BOFF-6155) would otherwise duplicate this leg.\n const harvested = formatDay(batch.harvestDate, labels.locale);\n if (harvested && !batch.supplyChainSteps.some((step) => step.step.toLowerCase().includes('harvest'))) {\n entries.push({ key: 'harvested', title: labels.harvested, detail: harvested, icon: <Leaf className=\"h-4 w-4\" /> });\n }\n\n batch.supplyChainSteps.forEach((step, index) => {\n const parts = [step.location, formatDay(step.date, labels.locale) ?? step.date].filter(Boolean) as string[];\n entries.push({\n key: `step-${index}-${step.step}`,\n title: step.step,\n detail: parts.length ? parts.join(' · ') : null,\n icon: stepIcon(step.step),\n });\n });\n\n // Only add a packaging leg when it isn't already told by a supply-chain step.\n const packaged = formatDay(batch.packagingDate, labels.locale);\n if (packaged && !batch.supplyChainSteps.some((step) => step.step.toLowerCase().includes('pack'))) {\n entries.push({ key: 'packed', title: labels.packed, detail: packaged, icon: <Package className=\"h-4 w-4\" /> });\n }\n\n return entries;\n}\n\nexport const PublicTraceJourney = ({ batch }: { batch: PublicTraceBatch }) => {\n const { t, locale } = useI18n();\n const journey = buildJourney(batch, {\n grown: t('healthybowl.traceability.publicPortal.leg.grown', 'Grown'),\n harvested: t('healthybowl.traceability.publicPortal.leg.harvested', 'Harvested'),\n packed: t('healthybowl.traceability.publicPortal.leg.packed', 'Packed'),\n locale,\n });\n const bestBefore = formatDay(batch.expiryDate, locale);\n\n return (\n <main className=\"min-h-screen bg-bg-canvas pb-12\" data-testid=\"public-trace-page\">\n <header className=\"bg-accent-teal/10 px-4 pb-10 pt-8 text-center\">\n <div className=\"mx-auto flex max-w-lg items-center justify-between gap-2\">\n <span className=\"w-24\" aria-hidden />\n <span className=\"flex items-center gap-2\">\n <Leaf className=\"h-6 w-6 text-accent-teal\" aria-hidden />\n <span className=\"text-lg font-semibold text-text-primary\">HealthyBowl</span>\n </span>\n {/* The shell chrome (and its language switcher) is stripped on /b/:slug, so the portal\n carries its own picker — otherwise a shopper whose browser locale does not match the\n printed QR has no way to change language. */}\n <PortalLanguagePicker />\n </div>\n <h1 className=\"mt-5 text-2xl font-bold text-text-primary sm:text-3xl\">\n {t('healthybowl.traceability.publicPortal.title', \"Your food's journey\")}\n </h1>\n <p className=\"mt-1 text-sm text-text-secondary\" data-testid=\"public-trace-subtitle\">\n {batch.product} · {t('healthybowl.traceability.publicPortal.batch', 'Batch')} {batch.batchCode}\n </p>\n {batch.portal.tagline ? (\n <p className=\"mx-auto mt-3 max-w-md text-sm italic text-text-secondary\">{batch.portal.tagline}</p>\n ) : null}\n </header>\n\n <div className=\"mx-auto -mt-6 max-w-lg px-4\">\n {batch.recalled ? (\n <section\n className=\"mb-4 rounded-xl border border-status-error-border bg-status-error-bg p-4 shadow-sm\"\n data-testid=\"public-trace-recall-notice\"\n role=\"alert\"\n >\n <div className=\"flex items-start gap-3\">\n <AlertOctagon className=\"mt-0.5 h-6 w-6 shrink-0 text-status-error-text\" aria-hidden />\n <div>\n <p className=\"text-base font-bold text-status-error-text\">\n {t('healthybowl.traceability.publicPortal.recall.heading', 'This product has been recalled')}\n </p>\n <p className=\"mt-1 text-sm text-text-primary\">\n {/* The grower's own notice is free text on the public allow-list and is shown\n verbatim; only OUR default sentence is translated. */}\n {batch.recallNotice\n ? batch.recallNotice\n : t(\n 'healthybowl.traceability.publicPortal.recall.defaultNotice',\n 'The grower has recalled this batch. Do not consume it, and contact your point of purchase.'\n )}\n </p>\n </div>\n </div>\n </section>\n ) : null}\n\n {/*\n When recalled, we deliberately show ONLY the recall notice above — never the clean\n farm-to-fork journey, origin card, certifications, best-before, or the \"Verified Organic\"\n banner. Rendering that reassuring content under a recall is exactly the mis-serving this\n feature exists to prevent (defence-in-depth: the server already suppresses it too).\n */}\n {!batch.recalled ? (\n <>\n {batch.origin ? (\n <section className=\"rounded-xl border border-border-subtle bg-bg-surface p-4 shadow-sm\">\n <div className=\"flex items-start gap-3\">\n <MapPin className=\"mt-0.5 h-5 w-5 shrink-0 text-accent-teal\" aria-hidden />\n <div>\n <p className=\"text-sm font-semibold text-text-primary\" data-testid=\"public-trace-origin\">\n {batch.origin}\n </p>\n <p className=\"mt-0.5 text-xs text-text-secondary\">\n {t('healthybowl.traceability.publicPortal.originCaption', 'Farm origin recorded by the grower')}\n </p>\n </div>\n </div>\n </section>\n ) : null}\n\n {batch.portal.showVerifiedOrganicBanner ? (\n <section\n className=\"mt-4 flex items-center gap-3 rounded-xl border border-accent-teal/30 bg-accent-teal/10 p-4\"\n data-testid=\"public-trace-verified-banner\"\n >\n <BadgeCheck className=\"h-5 w-5 shrink-0 text-accent-teal\" aria-hidden />\n <p className=\"text-sm font-medium text-text-primary\">\n {t('healthybowl.traceability.publicPortal.verifiedOrganic', 'Verified Organic')}\n </p>\n </section>\n ) : null}\n\n {journey.length > 0 ? (\n <section className=\"mt-6\">\n <h2 className=\"text-sm font-semibold uppercase tracking-wide text-text-secondary\">\n {t('healthybowl.traceability.publicPortal.journeyHeading', 'Friendly journey')}\n </h2>\n <ol className=\"mt-3 space-y-1\" data-testid=\"public-trace-journey\">\n {journey.map((entry, index) => (\n <li key={entry.key} className=\"flex gap-3\">\n <div className=\"flex flex-col items-center\">\n <span className=\"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-accent-teal/15 text-accent-teal\">\n {entry.icon}\n </span>\n {index < journey.length - 1 ? <span className=\"my-1 w-px flex-1 bg-accent-teal/30\" /> : null}\n </div>\n <div className=\"pb-5 pt-1.5\">\n <p className=\"text-sm font-semibold text-text-primary\">{entry.title}</p>\n {entry.detail ? <p className=\"mt-0.5 text-sm text-text-secondary\">{entry.detail}</p> : null}\n </div>\n </li>\n ))}\n </ol>\n </section>\n ) : (\n <p className=\"mt-6 text-sm text-text-secondary\">\n {t(\n 'healthybowl.traceability.publicPortal.noJourney',\n \"This batch has no journey steps recorded yet. Nothing here is invented — the grower simply hasn't logged them.\"\n )}\n </p>\n )}\n\n {batch.certifications.length > 0 ? (\n <section className=\"mt-4\">\n <h2 className=\"text-sm font-semibold uppercase tracking-wide text-text-secondary\">\n {t('healthybowl.traceability.publicPortal.certifications', 'Certifications')}\n </h2>\n <div className=\"mt-3 grid gap-3 sm:grid-cols-2\" data-testid=\"public-trace-certifications\">\n {batch.certifications.map((certification) => (\n <div\n key={certification}\n className=\"flex items-center gap-2 rounded-xl bg-accent-teal/10 px-3 py-3 text-sm font-medium text-text-primary\"\n >\n <BadgeCheck className=\"h-4 w-4 shrink-0 text-accent-teal\" aria-hidden />\n {certification}\n </div>\n ))}\n </div>\n </section>\n ) : null}\n\n {bestBefore ? (\n <p className=\"mt-6 text-center text-sm text-text-secondary\" data-testid=\"public-trace-best-before\">\n {t('healthybowl.traceability.publicPortal.bestBefore', 'Best before:')} {bestBefore}\n </p>\n ) : null}\n </>\n ) : null}\n\n <footer className=\"mt-10 border-t border-border-subtle pt-5 text-center text-xs text-text-secondary\">\n <p>\n {t('healthybowl.traceability.publicPortal.verifiedBy', 'Verified by HealthyBowl')} ·{' '}\n <a href=\"https://gethealthybowl.com\" className=\"underline hover:text-text-primary\">\n gethealthybowl.com\n </a>\n </p>\n <p className=\"mt-1\">{t('healthybowl.traceability.publicPortal.tagline', 'Organic. Traceable. Trusted.')}</p>\n </footer>\n </div>\n </main>\n );\n};\n"],"mappings":";;;;;AAkDA,SAAS,EAAU,GAAoB,IAAS,SAAwB;AACtE,KAAI,CAAC,EAAK,QAAO;CACjB,IAAM,IAAO,IAAI,KAAK,EAAI;AAE1B,QADI,OAAO,MAAM,EAAK,SAAS,CAAC,GAAS,OAClC,EAAK,mBAAmB,GAAQ;EAAE,KAAK;EAAW,OAAO;EAAS,MAAM;EAAW,UAAU;EAAO,CAAC;;AAI9G,SAAgB,EAAS,GAAyB;CAChD,IAAM,IAAO,EAAK,aAAa;AAM/B,QALI,EAAK,SAAS,UAAU,GAAS,kBAAC,GAAD,EAAM,WAAU,WAAY,CAAA,GAC7D,EAAK,SAAS,UAAU,IAAI,EAAK,SAAS,OAAO,GAAS,kBAAC,GAAD,EAAU,WAAU,WAAY,CAAA,GAC1F,EAAK,SAAS,OAAO,GAAS,kBAAC,GAAD,EAAS,WAAU,WAAY,CAAA,GAC7D,EAAK,SAAS,OAAO,IAAI,EAAK,SAAS,UAAU,IAAI,EAAK,SAAS,UAAU,IAAI,EAAK,SAAS,WAAW,GACrG,kBAAC,GAAD,EAAO,WAAU,WAAY,CAAA,GAC/B,kBAAC,GAAD,EAAQ,WAAU,WAAY,CAAA;;AAkCvC,IAAM,IAAwC;CAC5C,OAAO;CACP,WAAW;CACX,QAAQ;CACR,QAAQ;CACT;AAED,SAAgB,EAAa,GAAyB,IAAwB,GAAwC;CACpH,IAAM,IAA0B,EAAE;AAElC,CAAI,EAAM,UACR,EAAQ,KAAK;EAAE,KAAK;EAAS,OAAO,EAAO;EAAO,QAAQ,EAAM;EAAQ,MAAM,kBAAC,GAAD,EAAQ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U;OAAiC,eAAY;iBACzD,EAAM,eAAe,KAAK,MACzB,kBAAC,OAAD;QAEE,WAAU;kBAFZ,CAIE,kBAAC,GAAD;SAAY,WAAU;SAAoC,eAAA;SAAc,CAAA,EACvE,EACG;UALC,EAKD,CACN;OACE,CAAA,CACE;UACR;KAEH,IACC,kBAAC,KAAD;MAAG,WAAU;MAA+C,eAAY;gBAAxE;OACG,EAAE,oDAAoD,eAAe;OAAC;OAAE;OACvE;UACF;KACH,EAAA,CAAA;IAGL,kBAAC,UAAD;KAAQ,WAAU;eAAlB,CACE,kBAAC,KAAD,EAAA,UAAA;MACG,EAAE,oDAAoD,0BAA0B;MAAC;MAAG;MACrF,kBAAC,KAAD;OAAG,MAAK;OAA6B,WAAU;iBAAoC;OAE/E,CAAA;MACF,EAAA,CAAA,EACJ,kBAAC,KAAD;MAAG,WAAU;gBAAQ,EAAE,iDAAiD,+BAA+B;MAAK,CAAA,CACrG;;IACL;KACD"}
@@ -1,55 +1,79 @@
1
- import { Leaf as e, SearchX as t } from "lucide-react";
2
- import { jsx as n, jsxs as r } from "react/jsx-runtime";
1
+ import { PortalLanguagePicker as e } from "./PortalLanguagePicker.js";
2
+ import { useI18n as t } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
3
+ import { Leaf as n, SearchX as r } from "lucide-react";
4
+ import { jsx as i, jsxs as a } from "react/jsx-runtime";
3
5
  //#region src/healthybowl/public/PublicTraceNotFound.tsx
4
- var i = ({ scannedCode: i }) => /* @__PURE__ */ r("main", {
5
- className: "min-h-screen bg-bg-canvas",
6
- "data-testid": "public-trace-not-found",
7
- children: [/* @__PURE__ */ r("header", {
8
- className: "flex items-center justify-center gap-2 bg-accent-teal/10 px-4 py-5",
9
- children: [/* @__PURE__ */ n(e, {
10
- className: "h-5 w-5 text-accent-teal",
11
- "aria-hidden": !0
12
- }), /* @__PURE__ */ n("span", {
13
- className: "text-sm font-semibold text-text-primary",
14
- children: "HealthyBowl · Farm-to-Fork Trace"
6
+ var o = ({ scannedCode: o }) => {
7
+ let { t: s } = t();
8
+ return /* @__PURE__ */ a("main", {
9
+ className: "min-h-screen bg-bg-canvas",
10
+ "data-testid": "public-trace-not-found",
11
+ children: [/* @__PURE__ */ a("header", {
12
+ className: "flex items-center justify-between gap-2 bg-accent-teal/10 px-4 py-5",
13
+ children: [
14
+ /* @__PURE__ */ i("span", {
15
+ className: "w-24",
16
+ "aria-hidden": !0
17
+ }),
18
+ /* @__PURE__ */ a("span", {
19
+ className: "flex items-center gap-2",
20
+ children: [/* @__PURE__ */ i(n, {
21
+ className: "h-5 w-5 text-accent-teal",
22
+ "aria-hidden": !0
23
+ }), /* @__PURE__ */ i("span", {
24
+ className: "text-sm font-semibold text-text-primary",
25
+ children: s("healthybowl.traceability.publicPortal.notFound.brand", "HealthyBowl · Farm-to-Fork Trace")
26
+ })]
27
+ }),
28
+ /* @__PURE__ */ i(e, {})
29
+ ]
30
+ }), /* @__PURE__ */ a("div", {
31
+ className: "mx-auto max-w-md px-4 py-16 text-center",
32
+ children: [
33
+ /* @__PURE__ */ i(r, {
34
+ className: "mx-auto h-16 w-16 text-text-secondary",
35
+ "aria-hidden": !0
36
+ }),
37
+ /* @__PURE__ */ i("h1", {
38
+ className: "mt-6 text-2xl font-bold text-text-primary",
39
+ children: s("healthybowl.traceability.publicPortal.notFound.title", "This trace page isn't available")
40
+ }),
41
+ /* @__PURE__ */ i("p", {
42
+ className: "mt-3 text-sm text-text-secondary",
43
+ children: s("healthybowl.traceability.publicPortal.notFound.body", "The batch you scanned hasn't been published yet, or it may have been removed. No private farm data is ever shown here.")
44
+ }),
45
+ o ? /* @__PURE__ */ a("p", {
46
+ className: "mt-6 font-mono text-xs text-text-secondary",
47
+ "data-testid": "public-trace-scanned-code",
48
+ children: [
49
+ s("healthybowl.traceability.publicPortal.notFound.scannedCode", "Scanned code:"),
50
+ " ",
51
+ o
52
+ ]
53
+ }) : null,
54
+ /* @__PURE__ */ i("p", {
55
+ className: "mt-6 rounded-lg bg-bg-sunken px-4 py-3 text-sm text-text-secondary",
56
+ children: s("healthybowl.traceability.publicPortal.notFound.publishHint", "Only farmers can publish a batch to make its journey public.")
57
+ }),
58
+ /* @__PURE__ */ i("a", {
59
+ href: "https://gethealthybowl.com",
60
+ className: "mt-8 inline-block rounded-full border border-accent-teal px-5 py-2 text-sm font-medium text-accent-teal hover:bg-accent-teal/10",
61
+ children: s("healthybowl.traceability.publicPortal.notFound.cta", "Learn about HealthyBowl traceability")
62
+ }),
63
+ /* @__PURE__ */ a("footer", {
64
+ className: "mt-12 border-t border-border-subtle pt-5 text-xs text-text-secondary",
65
+ children: [
66
+ s("healthybowl.traceability.publicPortal.notFound.footer", "Powered by HealthyBowl"),
67
+ " ·",
68
+ " ",
69
+ s("healthybowl.traceability.publicPortal.tagline", "Organic. Traceable. Trusted.")
70
+ ]
71
+ })
72
+ ]
15
73
  })]
16
- }), /* @__PURE__ */ r("div", {
17
- className: "mx-auto max-w-md px-4 py-16 text-center",
18
- children: [
19
- /* @__PURE__ */ n(t, {
20
- className: "mx-auto h-16 w-16 text-text-secondary",
21
- "aria-hidden": !0
22
- }),
23
- /* @__PURE__ */ n("h1", {
24
- className: "mt-6 text-2xl font-bold text-text-primary",
25
- children: "This trace page isn’t available"
26
- }),
27
- /* @__PURE__ */ n("p", {
28
- className: "mt-3 text-sm text-text-secondary",
29
- children: "The batch you scanned hasn’t been published yet, or it may have been removed. No private farm data is ever shown here."
30
- }),
31
- i ? /* @__PURE__ */ r("p", {
32
- className: "mt-6 font-mono text-xs text-text-secondary",
33
- "data-testid": "public-trace-scanned-code",
34
- children: ["Scanned code: ", i]
35
- }) : null,
36
- /* @__PURE__ */ n("p", {
37
- className: "mt-6 rounded-lg bg-bg-sunken px-4 py-3 text-sm text-text-secondary",
38
- children: "Only farmers can publish a batch to make its journey public."
39
- }),
40
- /* @__PURE__ */ n("a", {
41
- href: "https://gethealthybowl.com",
42
- className: "mt-8 inline-block rounded-full border border-accent-teal px-5 py-2 text-sm font-medium text-accent-teal hover:bg-accent-teal/10",
43
- children: "Learn about HealthyBowl traceability"
44
- }),
45
- /* @__PURE__ */ n("footer", {
46
- className: "mt-12 border-t border-border-subtle pt-5 text-xs text-text-secondary",
47
- children: "Powered by HealthyBowl · Organic. Traceable. Trusted."
48
- })
49
- ]
50
- })]
51
- });
74
+ });
75
+ };
52
76
  //#endregion
53
- export { i as PublicTraceNotFound };
77
+ export { o as PublicTraceNotFound };
54
78
 
55
79
  //# sourceMappingURL=PublicTraceNotFound.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PublicTraceNotFound.js","names":[],"sources":["../../../src/healthybowl/public/PublicTraceNotFound.tsx"],"sourcesContent":["/**\n * \"This trace page isn't available\" (BOFF-2879, mockup 6).\n *\n * Shown for a draft, unpublished, deleted, unknown or unreachable batch — deliberately the same\n * page for all five. Distinguishing \"this code exists but is a draft\" from \"this code does not\n * exist\" would let anyone enumerate a farmer's unpublished batch codes.\n */\nimport { Leaf, SearchX } from 'lucide-react';\n\nexport const PublicTraceNotFound = ({ scannedCode }: { scannedCode: string }) => (\n <main className=\"min-h-screen bg-bg-canvas\" data-testid=\"public-trace-not-found\">\n <header className=\"flex items-center justify-center gap-2 bg-accent-teal/10 px-4 py-5\">\n <Leaf className=\"h-5 w-5 text-accent-teal\" aria-hidden />\n <span className=\"text-sm font-semibold text-text-primary\">HealthyBowl · Farm-to-Fork Trace</span>\n </header>\n\n <div className=\"mx-auto max-w-md px-4 py-16 text-center\">\n <SearchX className=\"mx-auto h-16 w-16 text-text-secondary\" aria-hidden />\n\n <h1 className=\"mt-6 text-2xl font-bold text-text-primary\">This trace page isn&rsquo;t available</h1>\n <p className=\"mt-3 text-sm text-text-secondary\">\n The batch you scanned hasn&rsquo;t been published yet, or it may have been removed. No private farm data is ever\n shown here.\n </p>\n\n {scannedCode ? (\n <p className=\"mt-6 font-mono text-xs text-text-secondary\" data-testid=\"public-trace-scanned-code\">\n Scanned code: {scannedCode}\n </p>\n ) : null}\n\n <p className=\"mt-6 rounded-lg bg-bg-sunken px-4 py-3 text-sm text-text-secondary\">\n Only farmers can publish a batch to make its journey public.\n </p>\n\n <a\n href=\"https://gethealthybowl.com\"\n className=\"mt-8 inline-block rounded-full border border-accent-teal px-5 py-2 text-sm font-medium text-accent-teal hover:bg-accent-teal/10\"\n >\n Learn about HealthyBowl traceability\n </a>\n\n <footer className=\"mt-12 border-t border-border-subtle pt-5 text-xs text-text-secondary\">\n Powered by HealthyBowl · Organic. Traceable. Trusted.\n </footer>\n </div>\n </main>\n);\n"],"mappings":";;;AASA,IAAa,KAAuB,EAAE,qBACpC,kBAAC,QAAD;CAAM,WAAU;CAA4B,eAAY;WAAxD,CACE,kBAAC,UAAD;EAAQ,WAAU;YAAlB,CACE,kBAAC,GAAD;GAAM,WAAU;GAA2B,eAAA;GAAc,CAAA,EACzD,kBAAC,QAAD;GAAM,WAAU;aAA0C;GAAuC,CAAA,CAC1F;KAET,kBAAC,OAAD;EAAK,WAAU;YAAf;GACE,kBAAC,GAAD;IAAS,WAAU;IAAwC,eAAA;IAAc,CAAA;GAEzE,kBAAC,MAAD;IAAI,WAAU;cAA4C;IAA0C,CAAA;GACpG,kBAAC,KAAD;IAAG,WAAU;cAAmC;IAG5C,CAAA;GAEH,IACC,kBAAC,KAAD;IAAG,WAAU;IAA6C,eAAY;cAAtE,CAAkG,kBACjF,EACb;QACF;GAEJ,kBAAC,KAAD;IAAG,WAAU;cAAqE;IAE9E,CAAA;GAEJ,kBAAC,KAAD;IACE,MAAK;IACL,WAAU;cACX;IAEG,CAAA;GAEJ,kBAAC,UAAD;IAAQ,WAAU;cAAuE;IAEhF,CAAA;GACL;IACD"}
1
+ {"version":3,"file":"PublicTraceNotFound.js","names":[],"sources":["../../../src/healthybowl/public/PublicTraceNotFound.tsx"],"sourcesContent":["/**\n * \"This trace page isn't available\" (BOFF-2879, mockup 6).\n *\n * Shown for a draft, unpublished, deleted, unknown or unreachable batch — deliberately the same\n * page for all five. Distinguishing \"this code exists but is a draft\" from \"this code does not\n * exist\" would let anyone enumerate a farmer's unpublished batch codes.\n *\n * BOFF-6104: fully translated. Note that keying these strings does not change what the page\n * reveals — every branch still renders this identical page, in whatever language the shopper is\n * reading, so the non-enumeration property is unaffected.\n */\nimport { Leaf, SearchX } from 'lucide-react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { PortalLanguagePicker } from './PortalLanguagePicker';\n\nexport const PublicTraceNotFound = ({ scannedCode }: { scannedCode: string }) => {\n const { t } = useI18n();\n\n return (\n <main className=\"min-h-screen bg-bg-canvas\" data-testid=\"public-trace-not-found\">\n <header className=\"flex items-center justify-between gap-2 bg-accent-teal/10 px-4 py-5\">\n <span className=\"w-24\" aria-hidden />\n <span className=\"flex items-center gap-2\">\n <Leaf className=\"h-5 w-5 text-accent-teal\" aria-hidden />\n <span className=\"text-sm font-semibold text-text-primary\">\n {t('healthybowl.traceability.publicPortal.notFound.brand', 'HealthyBowl · Farm-to-Fork Trace')}\n </span>\n </span>\n {/* A shopper who lands here from a mistyped or retired code still needs the picker —\n this may be the only HealthyBowl page they ever see. */}\n <PortalLanguagePicker />\n </header>\n\n <div className=\"mx-auto max-w-md px-4 py-16 text-center\">\n <SearchX className=\"mx-auto h-16 w-16 text-text-secondary\" aria-hidden />\n\n <h1 className=\"mt-6 text-2xl font-bold text-text-primary\">\n {t('healthybowl.traceability.publicPortal.notFound.title', \"This trace page isn't available\")}\n </h1>\n <p className=\"mt-3 text-sm text-text-secondary\">\n {t(\n 'healthybowl.traceability.publicPortal.notFound.body',\n \"The batch you scanned hasn't been published yet, or it may have been removed. No private farm data is ever shown here.\"\n )}\n </p>\n\n {scannedCode ? (\n <p className=\"mt-6 font-mono text-xs text-text-secondary\" data-testid=\"public-trace-scanned-code\">\n {t('healthybowl.traceability.publicPortal.notFound.scannedCode', 'Scanned code:')} {scannedCode}\n </p>\n ) : null}\n\n <p className=\"mt-6 rounded-lg bg-bg-sunken px-4 py-3 text-sm text-text-secondary\">\n {t(\n 'healthybowl.traceability.publicPortal.notFound.publishHint',\n 'Only farmers can publish a batch to make its journey public.'\n )}\n </p>\n\n <a\n href=\"https://gethealthybowl.com\"\n className=\"mt-8 inline-block rounded-full border border-accent-teal px-5 py-2 text-sm font-medium text-accent-teal hover:bg-accent-teal/10\"\n >\n {t('healthybowl.traceability.publicPortal.notFound.cta', 'Learn about HealthyBowl traceability')}\n </a>\n\n <footer className=\"mt-12 border-t border-border-subtle pt-5 text-xs text-text-secondary\">\n {t('healthybowl.traceability.publicPortal.notFound.footer', 'Powered by HealthyBowl')} ·{' '}\n {t('healthybowl.traceability.publicPortal.tagline', 'Organic. Traceable. Trusted.')}\n </footer>\n </div>\n </main>\n );\n};\n"],"mappings":";;;;;AAeA,IAAa,KAAuB,EAAE,qBAA2C;CAC/E,IAAM,EAAE,SAAM,GAAS;AAEvB,QACE,kBAAC,QAAD;EAAM,WAAU;EAA4B,eAAY;YAAxD,CACE,kBAAC,UAAD;GAAQ,WAAU;aAAlB;IACE,kBAAC,QAAD;KAAM,WAAU;KAAO,eAAA;KAAc,CAAA;IACrC,kBAAC,QAAD;KAAM,WAAU;eAAhB,CACE,kBAAC,GAAD;MAAM,WAAU;MAA2B,eAAA;MAAc,CAAA,EACzD,kBAAC,QAAD;MAAM,WAAU;gBACb,EAAE,wDAAwD,mCAAmC;MACzF,CAAA,CACF;;IAGP,kBAAC,GAAD,EAAwB,CAAA;IACjB;MAET,kBAAC,OAAD;GAAK,WAAU;aAAf;IACE,kBAAC,GAAD;KAAS,WAAU;KAAwC,eAAA;KAAc,CAAA;IAEzE,kBAAC,MAAD;KAAI,WAAU;eACX,EAAE,wDAAwD,kCAAkC;KAC1F,CAAA;IACL,kBAAC,KAAD;KAAG,WAAU;eACV,EACC,uDACA,yHACD;KACC,CAAA;IAEH,IACC,kBAAC,KAAD;KAAG,WAAU;KAA6C,eAAY;eAAtE;MACG,EAAE,8DAA8D,gBAAgB;MAAC;MAAE;MAClF;SACF;IAEJ,kBAAC,KAAD;KAAG,WAAU;eACV,EACC,8DACA,+DACD;KACC,CAAA;IAEJ,kBAAC,KAAD;KACE,MAAK;KACL,WAAU;eAET,EAAE,sDAAsD,uCAAuC;KAC9F,CAAA;IAEJ,kBAAC,UAAD;KAAQ,WAAU;eAAlB;MACG,EAAE,yDAAyD,yBAAyB;MAAC;MAAG;MACxF,EAAE,iDAAiD,+BAA+B;MAC5E;;IACL;KACD"}
@@ -1,46 +1,47 @@
1
1
  import { PublicTraceNotFound as e } from "./PublicTraceNotFound.js";
2
2
  import { PublicTraceJourney as t } from "./PublicTraceJourney.js";
3
3
  import { useEffect as n, useState as r } from "react";
4
- import { jsx as i, jsxs as a } from "react/jsx-runtime";
4
+ import { useI18n as i } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
5
+ import { jsx as a, jsxs as o } from "react/jsx-runtime";
5
6
  //#region src/healthybowl/public/PublicTracePage.tsx
6
- var o = "\n query PublicHealthyBowlTraceBatch($slug: String!) {\n publicHealthyBowlTraceBatch(slug: $slug) {\n batchCode\n product\n origin\n harvestDate\n processingDate\n packagingDate\n expiryDate\n certifications\n publishedAt\n publicSlug\n recalled\n recallNotice\n supplyChainSteps {\n step\n location\n date\n verified\n }\n portal {\n tagline\n showVerifiedOrganicBanner\n }\n }\n }\n";
7
- function s(e) {
7
+ var s = "\n query PublicHealthyBowlTraceBatch($slug: String!) {\n publicHealthyBowlTraceBatch(slug: $slug) {\n batchCode\n product\n origin\n harvestDate\n processingDate\n packagingDate\n expiryDate\n certifications\n publishedAt\n publicSlug\n recalled\n recallNotice\n supplyChainSteps {\n step\n location\n date\n verified\n }\n portal {\n tagline\n showVerifiedOrganicBanner\n }\n }\n }\n";
8
+ function c(e) {
8
9
  let t = e.replace(/\/+$/, "");
9
10
  return t.endsWith("/workspaces/graphql") ? t : `${t}/workspaces/graphql`;
10
11
  }
11
- var c = ({ slug: c, apiGatewayUrl: l }) => {
12
- let [u, d] = r({ status: "loading" });
12
+ var l = ({ slug: l, apiGatewayUrl: u }) => {
13
+ let { t: d } = i(), [f, p] = r({ status: "loading" });
13
14
  return n(() => {
14
15
  let e = !1;
15
- return d({ status: "loading" }), fetch(s(l), {
16
+ return p({ status: "loading" }), fetch(c(u), {
16
17
  method: "POST",
17
18
  headers: { "Content-Type": "application/json" },
18
19
  body: JSON.stringify({
19
- query: o,
20
- variables: { slug: c }
20
+ query: s,
21
+ variables: { slug: l }
21
22
  })
22
23
  }).then((e) => e.ok ? e.json() : Promise.reject(/* @__PURE__ */ Error(`HTTP ${e.status}`))).then((t) => {
23
24
  if (e) return;
24
25
  let n = t.data?.publicHealthyBowlTraceBatch;
25
- d(n ? {
26
+ p(n ? {
26
27
  status: "found",
27
28
  batch: n
28
29
  } : { status: "not-found" });
29
30
  }).catch(() => {
30
- e || d({ status: "not-found" });
31
+ e || p({ status: "not-found" });
31
32
  }), () => {
32
33
  e = !0;
33
34
  };
34
- }, [c, l]), u.status === "loading" ? /* @__PURE__ */ a("div", {
35
+ }, [l, u]), f.status === "loading" ? /* @__PURE__ */ o("div", {
35
36
  className: "flex min-h-screen items-center justify-center bg-bg-canvas",
36
37
  "data-testid": "public-trace-loading",
37
- children: [/* @__PURE__ */ i("div", { className: "h-10 w-10 animate-spin rounded-full border-2 border-border-subtle border-t-accent-teal" }), /* @__PURE__ */ i("span", {
38
+ children: [/* @__PURE__ */ a("div", { className: "h-10 w-10 animate-spin rounded-full border-2 border-border-subtle border-t-accent-teal" }), /* @__PURE__ */ a("span", {
38
39
  className: "sr-only",
39
- children: "Loading trace page"
40
+ children: d("healthybowl.traceability.publicPortal.loading", "Loading trace page")
40
41
  })]
41
- }) : u.status === "not-found" ? /* @__PURE__ */ i(e, { scannedCode: c }) : /* @__PURE__ */ i(t, { batch: u.batch });
42
+ }) : f.status === "not-found" ? /* @__PURE__ */ a(e, { scannedCode: l }) : /* @__PURE__ */ a(t, { batch: f.batch });
42
43
  };
43
44
  //#endregion
44
- export { c as PublicTracePage };
45
+ export { l as PublicTracePage };
45
46
 
46
47
  //# sourceMappingURL=PublicTracePage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PublicTracePage.js","names":[],"sources":["../../../src/healthybowl/public/PublicTracePage.tsx"],"sourcesContent":["/**\n * Public farm-to-fork trace portal (BOFF-2879 · B-2, mockups 3 + 6).\n *\n * This is the ONE HealthyBowl surface a shopper reaches with no account, no workspace and no\n * token. Three consequences shape the code:\n *\n * 1. It does NOT use the app-shell's Apollo client. That client attaches auth links and lives\n * behind the shell's providers; an anonymous visitor has neither. It issues a bare `fetch`\n * with no credentials, straight at the workspaces public gateway.\n * 2. It renders standalone chrome. The shell's header/sidebar assume a workspace.\n * 3. Every \"not available\" case — draft, unpublished, deleted, unknown, network error — lands\n * on the same friendly page. The portal must never confirm whether a batch code exists.\n */\nimport { useEffect, useState } from 'react';\n\nimport { PublicTraceNotFound } from './PublicTraceNotFound';\nimport { PublicTraceJourney, type PublicTraceBatch } from './PublicTraceJourney';\n\nconst PUBLIC_TRACE_QUERY = `\n query PublicHealthyBowlTraceBatch($slug: String!) {\n publicHealthyBowlTraceBatch(slug: $slug) {\n batchCode\n product\n origin\n harvestDate\n processingDate\n packagingDate\n expiryDate\n certifications\n publishedAt\n publicSlug\n recalled\n recallNotice\n supplyChainSteps {\n step\n location\n date\n verified\n }\n portal {\n tagline\n showVerifiedOrganicBanner\n }\n }\n }\n`;\n\ntype LoadState = { status: 'loading' } | { status: 'found'; batch: PublicTraceBatch } | { status: 'not-found' };\n\nexport interface PublicTracePageProps {\n /** The `{slug}` from `/b/{slug}`. */\n slug: string;\n /** Workspaces public gateway endpoint, e.g. `https://graphqlworkspaces.burdenoff.com`. */\n apiGatewayUrl: string;\n}\n\nfunction graphqlEndpoint(apiGatewayUrl: string): string {\n const base = apiGatewayUrl.replace(/\\/+$/, '');\n return base.endsWith('/workspaces/graphql') ? base : `${base}/workspaces/graphql`;\n}\n\nexport const PublicTracePage = ({ slug, apiGatewayUrl }: PublicTracePageProps) => {\n const [state, setState] = useState<LoadState>({ status: 'loading' });\n\n useEffect(() => {\n let cancelled = false;\n setState({ status: 'loading' });\n\n // No Authorization header, no X-Workspace-Authorization, no credentials. The field is\n // `@rbac(public: true)`, so the gateway skips auth entirely for it.\n fetch(graphqlEndpoint(apiGatewayUrl), {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ query: PUBLIC_TRACE_QUERY, variables: { slug } }),\n })\n .then((response) => (response.ok ? response.json() : Promise.reject(new Error(`HTTP ${response.status}`))))\n .then((payload: { data?: { publicHealthyBowlTraceBatch?: PublicTraceBatch | null } }) => {\n if (cancelled) return;\n const batch = payload.data?.publicHealthyBowlTraceBatch;\n setState(batch ? { status: 'found', batch } : { status: 'not-found' });\n })\n .catch(() => {\n if (!cancelled) {\n // A transport failure is indistinguishable from an unknown batch, on purpose.\n setState({ status: 'not-found' });\n }\n });\n\n return () => {\n cancelled = true;\n };\n }, [slug, apiGatewayUrl]);\n\n if (state.status === 'loading') {\n return (\n <div className=\"flex min-h-screen items-center justify-center bg-bg-canvas\" data-testid=\"public-trace-loading\">\n <div className=\"h-10 w-10 animate-spin rounded-full border-2 border-border-subtle border-t-accent-teal\" />\n <span className=\"sr-only\">Loading trace page</span>\n </div>\n );\n }\n\n if (state.status === 'not-found') {\n return <PublicTraceNotFound scannedCode={slug} />;\n }\n\n return <PublicTraceJourney batch={state.batch} />;\n};\n"],"mappings":";;;;;AAkBA,IAAM,IAAqB;AAsC3B,SAAS,EAAgB,GAA+B;CACtD,IAAM,IAAO,EAAc,QAAQ,QAAQ,GAAG;AAC9C,QAAO,EAAK,SAAS,sBAAsB,GAAG,IAAO,GAAG,EAAK;;AAG/D,IAAa,KAAmB,EAAE,SAAM,uBAA0C;CAChF,IAAM,CAAC,GAAO,KAAY,EAAoB,EAAE,QAAQ,WAAW,CAAC;AA4CpE,QA1CA,QAAgB;EACd,IAAI,IAAY;AAuBhB,SAtBA,EAAS,EAAE,QAAQ,WAAW,CAAC,EAI/B,MAAM,EAAgB,EAAc,EAAE;GACpC,QAAQ;GACR,SAAS,EAAE,gBAAgB,oBAAoB;GAC/C,MAAM,KAAK,UAAU;IAAE,OAAO;IAAoB,WAAW,EAAE,SAAM;IAAE,CAAC;GACzE,CAAC,CACC,MAAM,MAAc,EAAS,KAAK,EAAS,MAAM,GAAG,QAAQ,OAAO,gBAAI,MAAM,QAAQ,EAAS,SAAS,CAAC,CAAE,CAC1G,MAAM,MAAkF;AACvF,OAAI,EAAW;GACf,IAAM,IAAQ,EAAQ,MAAM;AAC5B,KAAS,IAAQ;IAAE,QAAQ;IAAS;IAAO,GAAG,EAAE,QAAQ,aAAa,CAAC;IACtE,CACD,YAAY;AACX,GAAK,KAEH,EAAS,EAAE,QAAQ,aAAa,CAAC;IAEnC,QAES;AACX,OAAY;;IAEb,CAAC,GAAM,EAAc,CAAC,EAErB,EAAM,WAAW,YAEjB,kBAAC,OAAD;EAAK,WAAU;EAA6D,eAAY;YAAxF,CACE,kBAAC,OAAD,EAAK,WAAU,0FAA2F,CAAA,EAC1G,kBAAC,QAAD;GAAM,WAAU;aAAU;GAAyB,CAAA,CAC/C;MAIN,EAAM,WAAW,cACZ,kBAAC,GAAD,EAAqB,aAAa,GAAQ,CAAA,GAG5C,kBAAC,GAAD,EAAoB,OAAO,EAAM,OAAS,CAAA"}
1
+ {"version":3,"file":"PublicTracePage.js","names":[],"sources":["../../../src/healthybowl/public/PublicTracePage.tsx"],"sourcesContent":["/**\n * Public farm-to-fork trace portal (BOFF-2879 · B-2, mockups 3 + 6).\n *\n * This is the ONE HealthyBowl surface a shopper reaches with no account, no workspace and no\n * token. Three consequences shape the code:\n *\n * 1. It does NOT use the app-shell's Apollo client. That client attaches auth links and lives\n * behind the shell's providers; an anonymous visitor has neither. It issues a bare `fetch`\n * with no credentials, straight at the workspaces public gateway.\n * 2. It renders standalone chrome. The shell's header/sidebar assume a workspace.\n * 3. Every \"not available\" case — draft, unpublished, deleted, unknown, network error — lands\n * on the same friendly page. The portal must never confirm whether a batch code exists.\n */\nimport { useEffect, useState } from 'react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\n\nimport { PublicTraceNotFound } from './PublicTraceNotFound';\nimport { PublicTraceJourney, type PublicTraceBatch } from './PublicTraceJourney';\n\nconst PUBLIC_TRACE_QUERY = `\n query PublicHealthyBowlTraceBatch($slug: String!) {\n publicHealthyBowlTraceBatch(slug: $slug) {\n batchCode\n product\n origin\n harvestDate\n processingDate\n packagingDate\n expiryDate\n certifications\n publishedAt\n publicSlug\n recalled\n recallNotice\n supplyChainSteps {\n step\n location\n date\n verified\n }\n portal {\n tagline\n showVerifiedOrganicBanner\n }\n }\n }\n`;\n\ntype LoadState = { status: 'loading' } | { status: 'found'; batch: PublicTraceBatch } | { status: 'not-found' };\n\nexport interface PublicTracePageProps {\n /** The `{slug}` from `/b/{slug}`. */\n slug: string;\n /** Workspaces public gateway endpoint, e.g. `https://graphqlworkspaces.burdenoff.com`. */\n apiGatewayUrl: string;\n}\n\nfunction graphqlEndpoint(apiGatewayUrl: string): string {\n const base = apiGatewayUrl.replace(/\\/+$/, '');\n return base.endsWith('/workspaces/graphql') ? base : `${base}/workspaces/graphql`;\n}\n\nexport const PublicTracePage = ({ slug, apiGatewayUrl }: PublicTracePageProps) => {\n const { t } = useI18n();\n const [state, setState] = useState<LoadState>({ status: 'loading' });\n\n useEffect(() => {\n let cancelled = false;\n setState({ status: 'loading' });\n\n // No Authorization header, no X-Workspace-Authorization, no credentials. The field is\n // `@rbac(public: true)`, so the gateway skips auth entirely for it.\n fetch(graphqlEndpoint(apiGatewayUrl), {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ query: PUBLIC_TRACE_QUERY, variables: { slug } }),\n })\n .then((response) => (response.ok ? response.json() : Promise.reject(new Error(`HTTP ${response.status}`))))\n .then((payload: { data?: { publicHealthyBowlTraceBatch?: PublicTraceBatch | null } }) => {\n if (cancelled) return;\n const batch = payload.data?.publicHealthyBowlTraceBatch;\n setState(batch ? { status: 'found', batch } : { status: 'not-found' });\n })\n .catch(() => {\n if (!cancelled) {\n // A transport failure is indistinguishable from an unknown batch, on purpose.\n setState({ status: 'not-found' });\n }\n });\n\n return () => {\n cancelled = true;\n };\n }, [slug, apiGatewayUrl]);\n\n if (state.status === 'loading') {\n return (\n <div className=\"flex min-h-screen items-center justify-center bg-bg-canvas\" data-testid=\"public-trace-loading\">\n <div className=\"h-10 w-10 animate-spin rounded-full border-2 border-border-subtle border-t-accent-teal\" />\n <span className=\"sr-only\">{t('healthybowl.traceability.publicPortal.loading', 'Loading trace page')}</span>\n </div>\n );\n }\n\n if (state.status === 'not-found') {\n return <PublicTraceNotFound scannedCode={slug} />;\n }\n\n return <PublicTraceJourney batch={state.batch} />;\n};\n"],"mappings":";;;;;;AAmBA,IAAM,IAAqB;AAsC3B,SAAS,EAAgB,GAA+B;CACtD,IAAM,IAAO,EAAc,QAAQ,QAAQ,GAAG;AAC9C,QAAO,EAAK,SAAS,sBAAsB,GAAG,IAAO,GAAG,EAAK;;AAG/D,IAAa,KAAmB,EAAE,SAAM,uBAA0C;CAChF,IAAM,EAAE,SAAM,GAAS,EACjB,CAAC,GAAO,KAAY,EAAoB,EAAE,QAAQ,WAAW,CAAC;AA4CpE,QA1CA,QAAgB;EACd,IAAI,IAAY;AAuBhB,SAtBA,EAAS,EAAE,QAAQ,WAAW,CAAC,EAI/B,MAAM,EAAgB,EAAc,EAAE;GACpC,QAAQ;GACR,SAAS,EAAE,gBAAgB,oBAAoB;GAC/C,MAAM,KAAK,UAAU;IAAE,OAAO;IAAoB,WAAW,EAAE,SAAM;IAAE,CAAC;GACzE,CAAC,CACC,MAAM,MAAc,EAAS,KAAK,EAAS,MAAM,GAAG,QAAQ,OAAO,gBAAI,MAAM,QAAQ,EAAS,SAAS,CAAC,CAAE,CAC1G,MAAM,MAAkF;AACvF,OAAI,EAAW;GACf,IAAM,IAAQ,EAAQ,MAAM;AAC5B,KAAS,IAAQ;IAAE,QAAQ;IAAS;IAAO,GAAG,EAAE,QAAQ,aAAa,CAAC;IACtE,CACD,YAAY;AACX,GAAK,KAEH,EAAS,EAAE,QAAQ,aAAa,CAAC;IAEnC,QAES;AACX,OAAY;;IAEb,CAAC,GAAM,EAAc,CAAC,EAErB,EAAM,WAAW,YAEjB,kBAAC,OAAD;EAAK,WAAU;EAA6D,eAAY;YAAxF,CACE,kBAAC,OAAD,EAAK,WAAU,0FAA2F,CAAA,EAC1G,kBAAC,QAAD;GAAM,WAAU;aAAW,EAAE,iDAAiD,qBAAqB;GAAQ,CAAA,CACvG;MAIN,EAAM,WAAW,cACZ,kBAAC,GAAD,EAAqB,aAAa,GAAQ,CAAA,GAG5C,kBAAC,GAAD,EAAoB,OAAO,EAAM,OAAS,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/microfe-healthybowl",
3
- "version": "2026.813.15",
3
+ "version": "2026.813.16",
4
4
  "description": "Burdenoff HealthyBowl Microfrontend - Comprehensive organic farming and agro-foods management platform",
5
5
  "type": "module",
6
6
  "files": [