@burdenoff/microfe-healthybowl 2026.1110.1 → 2026.1114.1
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/healthybowl/components/StoreImage.d.ts +10 -0
- package/dist/healthybowl/components/StoreImage.js +19 -0
- package/dist/healthybowl/hooks/useAgriInputs.d.ts +2 -0
- package/dist/healthybowl/hooks/useAgriInputs.js +58 -41
- package/dist/healthybowl/hooks/useStoreProduce.d.ts +5 -0
- package/dist/healthybowl/hooks/useStoreProduce.js +43 -29
- package/dist/healthybowl/pages/agri-inputs/AgriInputsStorePage.js +153 -151
- package/dist/healthybowl/pages/marketplace/StoreProduceStrip.js +47 -42
- package/dist/healthybowl/utils/storeImage.d.ts +62 -0
- package/dist/healthybowl/utils/storeImage.js +54 -0
- package/package.json +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
export interface StoreImageProps {
|
|
3
|
+
/** Raw image value from the store API (prefer `storeProductIconSrc(product)`). */
|
|
4
|
+
src: string | null | undefined;
|
|
5
|
+
/** Rendered when the value is not renderable or the image fails to load. */
|
|
6
|
+
fallback: ReactNode;
|
|
7
|
+
alt?: string;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const StoreImage: FC<StoreImageProps>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { classifyStoreImageSrc as e } from "../utils/storeImage.js";
|
|
2
|
+
import { useState as t } from "react";
|
|
3
|
+
import { Fragment as n, jsx as r } from "react/jsx-runtime";
|
|
4
|
+
// src/healthybowl/components/StoreImage.tsx
|
|
5
|
+
var i = ({ src: i, fallback: a, alt: o = "", className: s }) => {
|
|
6
|
+
let [c, l] = t(null), u = e(i);
|
|
7
|
+
if (u.kind === "none" || c === u.src) return /* @__PURE__ */ r(n, { children: a });
|
|
8
|
+
let d = u.src;
|
|
9
|
+
return /* @__PURE__ */ r("img", {
|
|
10
|
+
src: d,
|
|
11
|
+
alt: o,
|
|
12
|
+
className: s,
|
|
13
|
+
loading: "lazy",
|
|
14
|
+
decoding: "async",
|
|
15
|
+
referrerPolicy: "no-referrer",
|
|
16
|
+
onError: () => l(d)
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
export { i as StoreImage };
|
|
@@ -33,6 +33,8 @@ export interface AgriInputItem {
|
|
|
33
33
|
price: number;
|
|
34
34
|
currency: string;
|
|
35
35
|
icon: string | null;
|
|
36
|
+
/** Browser-renderable icon resolved by global-store-svc; undefined on the pre-iconUrl fallback. */
|
|
37
|
+
iconUrl?: string | null;
|
|
36
38
|
category: string | null;
|
|
37
39
|
brand: string | null;
|
|
38
40
|
stockQuantity: number | null;
|
|
@@ -1,24 +1,48 @@
|
|
|
1
1
|
import { useHealthyBowl as e } from "../context/HealthyBowlContext.js";
|
|
2
|
-
import {
|
|
2
|
+
import { queryGlobalStore as t } from "../utils/storeImage.js";
|
|
3
|
+
import { useCallback as n, useEffect as r, useMemo as i, useState as a } from "react";
|
|
3
4
|
// src/healthybowl/hooks/useAgriInputs.ts
|
|
4
|
-
var
|
|
5
|
+
var o = [
|
|
5
6
|
"agri-seeds",
|
|
6
7
|
"agri-fertilizer",
|
|
7
8
|
"agri-biopesticide",
|
|
8
9
|
"agri-tools",
|
|
9
10
|
"agri-irrigation"
|
|
10
11
|
];
|
|
11
|
-
function
|
|
12
|
+
function s(e) {
|
|
12
13
|
return typeof e == "string" && e.startsWith("agri-");
|
|
13
14
|
}
|
|
14
|
-
var
|
|
15
|
+
var c = {
|
|
15
16
|
"agri-seeds": "Seeds",
|
|
16
17
|
"agri-fertilizer": "Organic Fertilizer",
|
|
17
18
|
"agri-biopesticide": "Bio-Pesticides",
|
|
18
19
|
"agri-tools": "Tools",
|
|
19
20
|
"agri-irrigation": "Irrigation"
|
|
20
|
-
},
|
|
21
|
-
|
|
21
|
+
}, l = (e) => `
|
|
22
|
+
query AgriInputsStore($input: BrowseStoreInput!) {
|
|
23
|
+
browseStore(input: $input) {
|
|
24
|
+
products {
|
|
25
|
+
id
|
|
26
|
+
name
|
|
27
|
+
slug
|
|
28
|
+
description
|
|
29
|
+
price
|
|
30
|
+
currency
|
|
31
|
+
icon
|
|
32
|
+
${e ? "iconUrl" : ""}
|
|
33
|
+
category
|
|
34
|
+
brand
|
|
35
|
+
stockQuantity
|
|
36
|
+
tags
|
|
37
|
+
}
|
|
38
|
+
totalCount
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
`, u = {
|
|
42
|
+
primary: l(!0),
|
|
43
|
+
withoutIconUrl: l(!1)
|
|
44
|
+
}, d = 100;
|
|
45
|
+
function f(e) {
|
|
22
46
|
let t = e.tags ?? [];
|
|
23
47
|
return {
|
|
24
48
|
id: e.id,
|
|
@@ -28,6 +52,7 @@ function u(e) {
|
|
|
28
52
|
price: e.price,
|
|
29
53
|
currency: e.currency,
|
|
30
54
|
icon: e.icon,
|
|
55
|
+
iconUrl: e.iconUrl,
|
|
31
56
|
category: e.category,
|
|
32
57
|
brand: e.brand,
|
|
33
58
|
stockQuantity: e.stockQuantity,
|
|
@@ -35,51 +60,43 @@ function u(e) {
|
|
|
35
60
|
organicCertified: t.some((e) => e.toLowerCase() === "organic")
|
|
36
61
|
};
|
|
37
62
|
}
|
|
38
|
-
function
|
|
39
|
-
let { globalGatewayUrl:
|
|
63
|
+
function p() {
|
|
64
|
+
let { globalGatewayUrl: i } = e(), [c, l] = a({
|
|
40
65
|
products: [],
|
|
41
66
|
totalCount: 0,
|
|
42
|
-
loading: !!
|
|
67
|
+
loading: !!i,
|
|
43
68
|
error: null
|
|
44
|
-
}),
|
|
45
|
-
if (!
|
|
69
|
+
}), p = n(async () => {
|
|
70
|
+
if (!i) l({
|
|
46
71
|
products: [],
|
|
47
72
|
totalCount: 0,
|
|
48
73
|
loading: !1,
|
|
49
74
|
error: null
|
|
50
75
|
});
|
|
51
76
|
else {
|
|
52
|
-
|
|
77
|
+
l((e) => ({
|
|
53
78
|
...e,
|
|
54
79
|
loading: !0,
|
|
55
80
|
error: null
|
|
56
81
|
}));
|
|
57
82
|
try {
|
|
58
|
-
let e = await (
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
filter: {
|
|
66
|
-
nature: "PHYSICAL",
|
|
67
|
-
categories: [...a]
|
|
68
|
-
},
|
|
69
|
-
pagination: { limit: l }
|
|
70
|
-
} }
|
|
71
|
-
})
|
|
72
|
-
})).json();
|
|
83
|
+
let e = await t(i, u, { input: {
|
|
84
|
+
filter: {
|
|
85
|
+
nature: "PHYSICAL",
|
|
86
|
+
categories: [...o]
|
|
87
|
+
},
|
|
88
|
+
pagination: { limit: d }
|
|
89
|
+
} });
|
|
73
90
|
if (e.errors?.length) throw Error(e.errors[0]?.message ?? "browseStore request failed");
|
|
74
|
-
let
|
|
75
|
-
|
|
76
|
-
products:
|
|
77
|
-
totalCount:
|
|
91
|
+
let n = e.data?.browseStore, r = (n?.products ?? []).filter((e) => s(e.category)).map(f);
|
|
92
|
+
l({
|
|
93
|
+
products: r,
|
|
94
|
+
totalCount: n?.totalCount ?? r.length,
|
|
78
95
|
loading: !1,
|
|
79
96
|
error: null
|
|
80
97
|
});
|
|
81
98
|
} catch (e) {
|
|
82
|
-
|
|
99
|
+
l({
|
|
83
100
|
products: [],
|
|
84
101
|
totalCount: 0,
|
|
85
102
|
loading: !1,
|
|
@@ -87,19 +104,19 @@ function d() {
|
|
|
87
104
|
});
|
|
88
105
|
}
|
|
89
106
|
}
|
|
90
|
-
}, [
|
|
91
|
-
return
|
|
92
|
-
|
|
93
|
-
}, [
|
|
94
|
-
...
|
|
95
|
-
refetch: () => void
|
|
107
|
+
}, [i]);
|
|
108
|
+
return r(() => {
|
|
109
|
+
p();
|
|
110
|
+
}, [p]), {
|
|
111
|
+
...c,
|
|
112
|
+
refetch: () => void p()
|
|
96
113
|
};
|
|
97
114
|
}
|
|
98
|
-
function
|
|
99
|
-
return
|
|
115
|
+
function m(e) {
|
|
116
|
+
return i(() => {
|
|
100
117
|
let t = {};
|
|
101
118
|
for (let n of e) n.category && (t[n.category] = (t[n.category] ?? 0) + 1);
|
|
102
119
|
return t;
|
|
103
120
|
}, [e]);
|
|
104
121
|
}
|
|
105
|
-
export {
|
|
122
|
+
export { c as AGRI_CATEGORY_LABELS, o as AGRI_INPUT_CATEGORIES, s as isAgriInputCategory, m as useAgriCategoryCounts, p as useAgriInputs };
|
|
@@ -16,6 +16,11 @@ export interface StoreProduceItem {
|
|
|
16
16
|
price: number;
|
|
17
17
|
currency: string;
|
|
18
18
|
icon: string | null;
|
|
19
|
+
/**
|
|
20
|
+
* Browser-renderable icon resolved by global-store-svc (https or data URI), or null. Undefined
|
|
21
|
+
* when the gateway's supergraph predates the field and the read fell back to `icon` only.
|
|
22
|
+
*/
|
|
23
|
+
iconUrl?: string | null;
|
|
19
24
|
category: string | null;
|
|
20
25
|
stockQuantity: number | null;
|
|
21
26
|
}
|
|
@@ -1,47 +1,61 @@
|
|
|
1
1
|
import { useHealthyBowl as e } from "../context/HealthyBowlContext.js";
|
|
2
2
|
import { isAgriInputCategory as t } from "./useAgriInputs.js";
|
|
3
|
-
import {
|
|
3
|
+
import { queryGlobalStore as n } from "../utils/storeImage.js";
|
|
4
|
+
import { useCallback as r, useEffect as i, useState as a } from "react";
|
|
4
5
|
// src/healthybowl/hooks/useStoreProduce.ts
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
var o = (e) => `
|
|
7
|
+
query MarketplaceStoreProduce($input: BrowseStoreInput!) {
|
|
8
|
+
browseStore(input: $input) {
|
|
9
|
+
products {
|
|
10
|
+
id
|
|
11
|
+
name
|
|
12
|
+
slug
|
|
13
|
+
description
|
|
14
|
+
price
|
|
15
|
+
currency
|
|
16
|
+
icon
|
|
17
|
+
${e ? "iconUrl" : ""}
|
|
18
|
+
category
|
|
19
|
+
stockQuantity
|
|
20
|
+
}
|
|
21
|
+
totalCount
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
`, s = {
|
|
25
|
+
primary: o(!0),
|
|
26
|
+
withoutIconUrl: o(!1)
|
|
27
|
+
};
|
|
28
|
+
function c(o = 12) {
|
|
29
|
+
let { globalGatewayUrl: c } = e(), [l, u] = a({
|
|
8
30
|
produce: [],
|
|
9
31
|
totalCount: 0,
|
|
10
|
-
loading: !!
|
|
32
|
+
loading: !!c,
|
|
11
33
|
error: null
|
|
12
|
-
}),
|
|
13
|
-
if (!
|
|
34
|
+
}), d = r(async () => {
|
|
35
|
+
if (!c) u({
|
|
14
36
|
produce: [],
|
|
15
37
|
totalCount: 0,
|
|
16
38
|
loading: !1,
|
|
17
39
|
error: null
|
|
18
40
|
});
|
|
19
41
|
else {
|
|
20
|
-
|
|
42
|
+
u((e) => ({
|
|
21
43
|
...e,
|
|
22
44
|
loading: !0,
|
|
23
45
|
error: null
|
|
24
46
|
}));
|
|
25
47
|
try {
|
|
26
|
-
let e = await (
|
|
27
|
-
method: "POST",
|
|
28
|
-
credentials: "include",
|
|
29
|
-
headers: { "content-type": "application/json" },
|
|
30
|
-
body: JSON.stringify({
|
|
31
|
-
query: a,
|
|
32
|
-
variables: { input: { filter: { nature: "PHYSICAL" } } }
|
|
33
|
-
})
|
|
34
|
-
})).json();
|
|
48
|
+
let e = await n(c, s, { input: { filter: { nature: "PHYSICAL" } } });
|
|
35
49
|
if (e.errors?.length) throw Error(e.errors[0]?.message ?? "browseStore request failed");
|
|
36
|
-
let
|
|
37
|
-
|
|
38
|
-
produce:
|
|
39
|
-
totalCount:
|
|
50
|
+
let r = e.data?.browseStore, i = (r?.products ?? []).filter((e) => !t(e.category)).slice(0, o);
|
|
51
|
+
u({
|
|
52
|
+
produce: i,
|
|
53
|
+
totalCount: r?.totalCount ?? 0,
|
|
40
54
|
loading: !1,
|
|
41
55
|
error: null
|
|
42
56
|
});
|
|
43
57
|
} catch (e) {
|
|
44
|
-
|
|
58
|
+
u({
|
|
45
59
|
produce: [],
|
|
46
60
|
totalCount: 0,
|
|
47
61
|
loading: !1,
|
|
@@ -49,12 +63,12 @@ function o(o = 12) {
|
|
|
49
63
|
});
|
|
50
64
|
}
|
|
51
65
|
}
|
|
52
|
-
}, [
|
|
53
|
-
return
|
|
54
|
-
|
|
55
|
-
}, [
|
|
56
|
-
...
|
|
57
|
-
refetch: () => void
|
|
66
|
+
}, [c, o]);
|
|
67
|
+
return i(() => {
|
|
68
|
+
d();
|
|
69
|
+
}, [d]), {
|
|
70
|
+
...l,
|
|
71
|
+
refetch: () => void d()
|
|
58
72
|
};
|
|
59
73
|
}
|
|
60
|
-
export {
|
|
74
|
+
export { c as useStoreProduce };
|
|
@@ -1,313 +1,315 @@
|
|
|
1
1
|
import "../../components/index.js";
|
|
2
2
|
import { PageLayout as e } from "../../components/PageLayout.js";
|
|
3
|
-
import {
|
|
3
|
+
import { StoreImage as t } from "../../components/StoreImage.js";
|
|
4
4
|
import { StatCard as n } from "../../components/StatCard.js";
|
|
5
5
|
import { EmptyState as r } from "../../components/EmptyState.js";
|
|
6
6
|
import { ErrorState as i } from "../../components/ErrorState.js";
|
|
7
|
-
import {
|
|
8
|
-
import { PageLoader as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
7
|
+
import { storeProductIconSrc as a } from "../../utils/storeImage.js";
|
|
8
|
+
import { PageLoader as o } from "../../components/PageLoader.js";
|
|
9
|
+
import { ToastContainer as ee } from "../../components/Toast.js";
|
|
10
|
+
import { useToast as te } from "../../hooks/useToast.js";
|
|
11
|
+
import { useBasePath as s } from "../../hooks/useBasePath.js";
|
|
12
|
+
import { useHealthyBowlData as c } from "../../hooks/useHealthyBowlData.js";
|
|
13
|
+
import { useHealthyBowlStore as l } from "../../store/healthybowlStore.js";
|
|
14
|
+
import { cn as u, formatCurrency as d, resolveLineCurrency as f } from "../../utils/helpers.js";
|
|
15
|
+
import { AGRI_CATEGORY_LABELS as p, AGRI_INPUT_CATEGORIES as m, useAgriCategoryCounts as h, useAgriInputs as g } from "../../hooks/useAgriInputs.js";
|
|
16
|
+
import { useMemo as _, useState as v } from "react";
|
|
17
|
+
import { useI18n as ne } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
18
|
+
import { Leaf as y, MapPin as re, Minus as ie, Package as b, Plus as ae, ShieldCheck as oe, ShoppingCart as x, Sprout as S, Store as C, Trash2 as w, X as T } from "lucide-react";
|
|
19
|
+
import { useNavigate as E } from "react-router";
|
|
20
|
+
import { Fragment as D, jsx as O, jsxs as k } from "react/jsx-runtime";
|
|
21
|
+
import { Button as A } from "@burdenoff/fe-libs/ui";
|
|
20
22
|
// src/healthybowl/pages/agri-inputs/AgriInputsStorePage.tsx
|
|
21
|
-
var
|
|
22
|
-
let { t:
|
|
23
|
-
|
|
23
|
+
var j = "all", M = () => {
|
|
24
|
+
let { t: M } = ne(), N = E(), { buildPath: P } = s(), { toasts: F, toast: I, dismiss: L } = te(), { products: R, loading: z, error: B, refetch: se } = g(), V = h(R), { farm: H } = c(), { cart: U, addToCart: W, updateCartQuantity: G, removeFromCart: K, clearCart: ce, getCartItemCount: le, deliveryAddress: q, setDeliveryAddress: J } = l(), [Y, ue] = v(j), [de, X] = v(!1), Z = [H.name, H.location].filter(Boolean).join(", "), Q = _(() => Y === j ? R : R.filter((e) => e.category === Y), [R, Y]), $ = le(), fe = U.reduce((e, t) => e + t.price * t.quantity, 0), pe = f(U), me = _(() => R.filter((e) => e.organicCertified).length, [R]), he = (e) => {
|
|
25
|
+
W({
|
|
24
26
|
productId: e.id,
|
|
25
27
|
name: e.name,
|
|
26
28
|
price: e.price,
|
|
27
29
|
unit: "unit",
|
|
28
|
-
seller: e.brand ??
|
|
30
|
+
seller: e.brand ?? M("healthybowl.agriInputs.seller", "Agri-Inputs Store"),
|
|
29
31
|
currency: e.currency
|
|
30
|
-
}),
|
|
31
|
-
title:
|
|
32
|
-
description:
|
|
32
|
+
}), I({
|
|
33
|
+
title: M("healthybowl.agriInputs.toast.added.title", "Added to cart"),
|
|
34
|
+
description: M("healthybowl.agriInputs.toast.added.description", "{{name}} added to your cart.", { name: e.name }),
|
|
33
35
|
variant: "success"
|
|
34
36
|
}), X(!0);
|
|
35
|
-
},
|
|
36
|
-
J(q.trim() || Z),
|
|
37
|
-
},
|
|
38
|
-
key:
|
|
39
|
-
label:
|
|
40
|
-
count:
|
|
41
|
-
}, ...
|
|
37
|
+
}, ge = () => {
|
|
38
|
+
J(q.trim() || Z), N(P("marketplace/cart"));
|
|
39
|
+
}, _e = [{
|
|
40
|
+
key: j,
|
|
41
|
+
label: M("healthybowl.agriInputs.tab.all", "All"),
|
|
42
|
+
count: R.length
|
|
43
|
+
}, ...m.map((e) => ({
|
|
42
44
|
key: e,
|
|
43
|
-
label:
|
|
44
|
-
count:
|
|
45
|
-
}))],
|
|
45
|
+
label: M(`healthybowl.agriInputs.tab.${e}`, p[e]),
|
|
46
|
+
count: V[e] ?? 0
|
|
47
|
+
}))], ve = /* @__PURE__ */ k(A, {
|
|
46
48
|
variant: "outline",
|
|
47
49
|
size: "sm",
|
|
48
50
|
onClick: () => X(!0),
|
|
49
51
|
className: "relative",
|
|
50
52
|
children: [
|
|
51
|
-
/* @__PURE__ */
|
|
52
|
-
|
|
53
|
-
$ > 0 && /* @__PURE__ */
|
|
53
|
+
/* @__PURE__ */ O(x, { className: "h-4 w-4" }),
|
|
54
|
+
M("healthybowl.agriInputs.cart.open", "Cart"),
|
|
55
|
+
$ > 0 && /* @__PURE__ */ O("span", {
|
|
54
56
|
className: "ms-1 inline-flex h-5 min-w-[1.25rem] items-center justify-center rounded-full bg-action-primary-bg px-1.5 text-[11px] font-semibold text-action-primary-text",
|
|
55
57
|
children: $
|
|
56
58
|
})
|
|
57
59
|
]
|
|
58
60
|
});
|
|
59
|
-
return /* @__PURE__ */
|
|
60
|
-
title:
|
|
61
|
-
description:
|
|
61
|
+
return /* @__PURE__ */ k(e, {
|
|
62
|
+
title: M("healthybowl.agriInputs.title", "Agri-Inputs Store"),
|
|
63
|
+
description: M("healthybowl.agriInputs.description", "Buy seeds, organic fertilizer, bio-pesticides, tools and irrigation — delivered to your farm."),
|
|
62
64
|
purpose: "Order the supplies you need to run the farm — this is the buy side of commerce, powered by the platform store and billing. Add items to your cart, set a delivery address, and check out.",
|
|
63
|
-
actions:
|
|
65
|
+
actions: ve,
|
|
64
66
|
children: [
|
|
65
|
-
/* @__PURE__ */
|
|
67
|
+
/* @__PURE__ */ k("div", {
|
|
66
68
|
className: "grid grid-cols-2 gap-4 lg:grid-cols-4",
|
|
67
69
|
children: [
|
|
68
|
-
/* @__PURE__ */
|
|
70
|
+
/* @__PURE__ */ O(n, {
|
|
69
71
|
hero: !0,
|
|
70
|
-
label:
|
|
71
|
-
value:
|
|
72
|
-
icon: /* @__PURE__ */
|
|
72
|
+
label: M("healthybowl.agriInputs.stats.products", "Products"),
|
|
73
|
+
value: R.length,
|
|
74
|
+
icon: /* @__PURE__ */ O(b, { className: "h-5 w-5" })
|
|
73
75
|
}),
|
|
74
|
-
/* @__PURE__ */
|
|
75
|
-
label:
|
|
76
|
-
value:
|
|
77
|
-
icon: /* @__PURE__ */
|
|
76
|
+
/* @__PURE__ */ O(n, {
|
|
77
|
+
label: M("healthybowl.agriInputs.stats.categories", "Categories"),
|
|
78
|
+
value: m.length,
|
|
79
|
+
icon: /* @__PURE__ */ O(S, { className: "h-5 w-5" })
|
|
78
80
|
}),
|
|
79
|
-
/* @__PURE__ */
|
|
80
|
-
label:
|
|
81
|
-
value:
|
|
82
|
-
icon: /* @__PURE__ */
|
|
81
|
+
/* @__PURE__ */ O(n, {
|
|
82
|
+
label: M("healthybowl.agriInputs.stats.organic", "Organic Certified"),
|
|
83
|
+
value: me,
|
|
84
|
+
icon: /* @__PURE__ */ O(y, { className: "h-5 w-5" })
|
|
83
85
|
}),
|
|
84
|
-
/* @__PURE__ */
|
|
85
|
-
label:
|
|
86
|
+
/* @__PURE__ */ O(n, {
|
|
87
|
+
label: M("healthybowl.agriInputs.stats.inCart", "In Cart"),
|
|
86
88
|
value: $,
|
|
87
|
-
icon: /* @__PURE__ */
|
|
89
|
+
icon: /* @__PURE__ */ O(x, { className: "h-5 w-5" })
|
|
88
90
|
})
|
|
89
91
|
]
|
|
90
92
|
}),
|
|
91
|
-
/* @__PURE__ */
|
|
93
|
+
/* @__PURE__ */ O("div", {
|
|
92
94
|
className: "flex flex-wrap gap-1.5",
|
|
93
|
-
children:
|
|
95
|
+
children: _e.map((e) => /* @__PURE__ */ k("button", {
|
|
94
96
|
type: "button",
|
|
95
|
-
onClick: () =>
|
|
96
|
-
className:
|
|
97
|
+
onClick: () => ue(e.key),
|
|
98
|
+
className: u("rounded-full px-3 py-1 text-xs font-medium transition-colors", Y === e.key ? "bg-action-primary-bg text-action-primary-text" : "border border-border-subtle text-text-secondary hover:bg-bg-sunken/50 hover:text-text-primary"),
|
|
97
99
|
children: [e.label, e.count > 0 ? ` (${e.count})` : ""]
|
|
98
100
|
}, e.key))
|
|
99
101
|
}),
|
|
100
|
-
|
|
102
|
+
z && R.length === 0 ? /* @__PURE__ */ O(o, {}) : B && R.length === 0 ? /* @__PURE__ */ O(i, { onRetry: () => se() }) : Q.length === 0 ? /* @__PURE__ */ O(r, {
|
|
101
103
|
illustration: "empty-files",
|
|
102
|
-
title:
|
|
103
|
-
description:
|
|
104
|
-
}) : /* @__PURE__ */
|
|
104
|
+
title: M("healthybowl.agriInputs.empty.title", "No agri-inputs to show"),
|
|
105
|
+
description: M("healthybowl.agriInputs.empty.description", "No products in this category yet. Check back soon — suppliers list new inputs from the Seller Portal.")
|
|
106
|
+
}) : /* @__PURE__ */ O("div", {
|
|
105
107
|
className: "grid gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",
|
|
106
|
-
children: Q.map((e) => /* @__PURE__ */
|
|
108
|
+
children: Q.map((e) => /* @__PURE__ */ k("div", {
|
|
107
109
|
className: "flex flex-col overflow-hidden rounded-lg border border-border-subtle bg-bg-surface shadow-sm transition-shadow hover:shadow-md",
|
|
108
|
-
children: [/* @__PURE__ */
|
|
110
|
+
children: [/* @__PURE__ */ k("div", {
|
|
109
111
|
className: "relative flex h-36 items-center justify-center bg-bg-sunken",
|
|
110
|
-
children: [
|
|
111
|
-
src: e
|
|
112
|
+
children: [/* @__PURE__ */ O(t, {
|
|
113
|
+
src: a(e),
|
|
112
114
|
alt: e.name,
|
|
113
|
-
loading: "lazy",
|
|
114
115
|
className: "h-full w-full object-cover",
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
fallback: /* @__PURE__ */ O(S, {
|
|
117
|
+
className: "h-8 w-8 text-text-muted",
|
|
118
|
+
"aria-hidden": "true"
|
|
119
|
+
})
|
|
120
|
+
}), e.organicCertified && /* @__PURE__ */ k("span", {
|
|
119
121
|
className: "absolute start-2 top-2 flex items-center gap-0.5 rounded-full bg-success-subtle px-2 py-0.5 text-[10px] font-medium text-success",
|
|
120
|
-
children: [/* @__PURE__ */
|
|
122
|
+
children: [/* @__PURE__ */ O(y, { className: "h-2.5 w-2.5" }), M("healthybowl.agriInputs.badge.organic", "Organic Certified")]
|
|
121
123
|
})]
|
|
122
|
-
}), /* @__PURE__ */
|
|
124
|
+
}), /* @__PURE__ */ k("div", {
|
|
123
125
|
className: "flex flex-1 flex-col gap-1.5 p-3",
|
|
124
126
|
children: [
|
|
125
|
-
/* @__PURE__ */
|
|
127
|
+
/* @__PURE__ */ O("p", {
|
|
126
128
|
className: "line-clamp-2 text-sm font-semibold text-text-primary",
|
|
127
129
|
children: e.name
|
|
128
130
|
}),
|
|
129
|
-
e.brand && /* @__PURE__ */
|
|
131
|
+
e.brand && /* @__PURE__ */ O("p", {
|
|
130
132
|
className: "text-xs text-text-secondary",
|
|
131
133
|
children: e.brand
|
|
132
134
|
}),
|
|
133
|
-
e.description && /* @__PURE__ */
|
|
135
|
+
e.description && /* @__PURE__ */ O("p", {
|
|
134
136
|
className: "line-clamp-2 text-xs text-text-secondary",
|
|
135
137
|
children: e.description
|
|
136
138
|
}),
|
|
137
|
-
/* @__PURE__ */
|
|
139
|
+
/* @__PURE__ */ k("div", {
|
|
138
140
|
className: "mt-auto flex items-center justify-between pt-2",
|
|
139
|
-
children: [/* @__PURE__ */
|
|
141
|
+
children: [/* @__PURE__ */ O("span", {
|
|
140
142
|
className: "text-base font-bold text-text-primary",
|
|
141
|
-
children:
|
|
142
|
-
}), /* @__PURE__ */
|
|
143
|
+
children: d(e.price, e.currency)
|
|
144
|
+
}), /* @__PURE__ */ O("span", {
|
|
143
145
|
className: "text-[10px] text-text-secondary",
|
|
144
|
-
children: e.stockQuantity && e.stockQuantity > 0 ?
|
|
146
|
+
children: e.stockQuantity && e.stockQuantity > 0 ? M("healthybowl.agriInputs.inStock", "In stock") : M("healthybowl.agriInputs.outOfStock", "Out of stock")
|
|
145
147
|
})]
|
|
146
148
|
}),
|
|
147
|
-
/* @__PURE__ */
|
|
149
|
+
/* @__PURE__ */ k(A, {
|
|
148
150
|
size: "sm",
|
|
149
151
|
className: "mt-2 w-full",
|
|
150
|
-
onClick: () =>
|
|
152
|
+
onClick: () => he(e),
|
|
151
153
|
disabled: !(e.stockQuantity && e.stockQuantity > 0),
|
|
152
|
-
children: [/* @__PURE__ */
|
|
154
|
+
children: [/* @__PURE__ */ O(x, { className: "h-3.5 w-3.5" }), M("healthybowl.agriInputs.card.addToCart", "Add to Cart")]
|
|
153
155
|
})
|
|
154
156
|
]
|
|
155
157
|
})]
|
|
156
158
|
}, e.id))
|
|
157
159
|
}),
|
|
158
|
-
|
|
160
|
+
de && /* @__PURE__ */ k("div", {
|
|
159
161
|
className: "fixed inset-0 z-50 flex justify-end",
|
|
160
162
|
role: "dialog",
|
|
161
163
|
"aria-modal": "true",
|
|
162
|
-
children: [/* @__PURE__ */
|
|
164
|
+
children: [/* @__PURE__ */ O("button", {
|
|
163
165
|
type: "button",
|
|
164
|
-
"aria-label":
|
|
166
|
+
"aria-label": M("healthybowl.agriInputs.cart.close", "Close cart"),
|
|
165
167
|
className: "absolute inset-0 bg-black/40",
|
|
166
168
|
onClick: () => X(!1)
|
|
167
|
-
}), /* @__PURE__ */
|
|
169
|
+
}), /* @__PURE__ */ k("div", {
|
|
168
170
|
className: "relative flex h-full w-full max-w-md flex-col bg-bg-surface shadow-xl",
|
|
169
|
-
children: [/* @__PURE__ */
|
|
171
|
+
children: [/* @__PURE__ */ k("div", {
|
|
170
172
|
className: "flex items-center justify-between border-b border-border-subtle p-4",
|
|
171
|
-
children: [/* @__PURE__ */
|
|
173
|
+
children: [/* @__PURE__ */ k("h2", {
|
|
172
174
|
className: "flex items-center gap-2 text-sm font-semibold text-text-primary",
|
|
173
175
|
children: [
|
|
174
|
-
/* @__PURE__ */
|
|
175
|
-
|
|
176
|
+
/* @__PURE__ */ O(x, { className: "h-4 w-4" }),
|
|
177
|
+
M("healthybowl.agriInputs.cart.title", "Your Cart"),
|
|
176
178
|
$ > 0 ? ` (${$})` : ""
|
|
177
179
|
]
|
|
178
|
-
}), /* @__PURE__ */
|
|
180
|
+
}), /* @__PURE__ */ O(A, {
|
|
179
181
|
variant: "ghost",
|
|
180
182
|
size: "icon-sm",
|
|
181
183
|
onClick: () => X(!1),
|
|
182
|
-
"aria-label":
|
|
183
|
-
children: /* @__PURE__ */ T
|
|
184
|
+
"aria-label": M("healthybowl.agriInputs.cart.close", "Close cart"),
|
|
185
|
+
children: /* @__PURE__ */ O(T, { className: "h-4 w-4" })
|
|
184
186
|
})]
|
|
185
|
-
}),
|
|
187
|
+
}), U.length === 0 ? /* @__PURE__ */ k("div", {
|
|
186
188
|
className: "flex flex-1 flex-col items-center justify-center gap-3 p-8 text-center",
|
|
187
189
|
children: [
|
|
188
|
-
/* @__PURE__ */
|
|
189
|
-
/* @__PURE__ */
|
|
190
|
+
/* @__PURE__ */ O(x, { className: "h-10 w-10 text-text-muted" }),
|
|
191
|
+
/* @__PURE__ */ O("p", {
|
|
190
192
|
className: "text-sm font-medium text-text-primary",
|
|
191
|
-
children:
|
|
193
|
+
children: M("healthybowl.agriInputs.cart.empty.title", "Your cart is empty")
|
|
192
194
|
}),
|
|
193
|
-
/* @__PURE__ */
|
|
195
|
+
/* @__PURE__ */ O("p", {
|
|
194
196
|
className: "text-xs text-text-secondary",
|
|
195
|
-
children:
|
|
197
|
+
children: M("healthybowl.agriInputs.cart.empty.description", "Add agri-inputs to get started.")
|
|
196
198
|
})
|
|
197
199
|
]
|
|
198
|
-
}) : /* @__PURE__ */
|
|
200
|
+
}) : /* @__PURE__ */ k(D, { children: [/* @__PURE__ */ O("div", {
|
|
199
201
|
className: "flex-1 space-y-3 overflow-y-auto p-4",
|
|
200
|
-
children:
|
|
202
|
+
children: U.map((e) => /* @__PURE__ */ k("div", {
|
|
201
203
|
className: "flex items-center gap-3 rounded-lg border border-border-subtle bg-bg-sunken/30 p-3",
|
|
202
204
|
children: [
|
|
203
|
-
/* @__PURE__ */
|
|
205
|
+
/* @__PURE__ */ O("div", {
|
|
204
206
|
className: "flex h-9 w-9 shrink-0 items-center justify-center rounded-md bg-bg-sunken",
|
|
205
|
-
children: /* @__PURE__ */
|
|
207
|
+
children: /* @__PURE__ */ O(b, { className: "h-4 w-4 text-text-secondary" })
|
|
206
208
|
}),
|
|
207
|
-
/* @__PURE__ */
|
|
209
|
+
/* @__PURE__ */ k("div", {
|
|
208
210
|
className: "min-w-0 flex-1",
|
|
209
|
-
children: [/* @__PURE__ */
|
|
211
|
+
children: [/* @__PURE__ */ O("p", {
|
|
210
212
|
className: "truncate text-sm font-medium text-text-primary",
|
|
211
213
|
children: e.name
|
|
212
|
-
}), /* @__PURE__ */
|
|
214
|
+
}), /* @__PURE__ */ O("p", {
|
|
213
215
|
className: "text-xs text-text-secondary",
|
|
214
|
-
children:
|
|
216
|
+
children: d(e.price, e.currency ?? "INR")
|
|
215
217
|
})]
|
|
216
218
|
}),
|
|
217
|
-
/* @__PURE__ */
|
|
219
|
+
/* @__PURE__ */ k("div", {
|
|
218
220
|
className: "flex items-center gap-1",
|
|
219
221
|
children: [
|
|
220
|
-
/* @__PURE__ */
|
|
222
|
+
/* @__PURE__ */ O(A, {
|
|
221
223
|
variant: "outline",
|
|
222
224
|
size: "icon-sm",
|
|
223
|
-
"aria-label":
|
|
224
|
-
onClick: () =>
|
|
225
|
-
children: /* @__PURE__ */
|
|
225
|
+
"aria-label": M("healthybowl.agriInputs.cart.decrease", "Decrease quantity"),
|
|
226
|
+
onClick: () => G(e.productId, e.quantity - 1),
|
|
227
|
+
children: /* @__PURE__ */ O(ie, { className: "h-3 w-3" })
|
|
226
228
|
}),
|
|
227
|
-
/* @__PURE__ */
|
|
229
|
+
/* @__PURE__ */ O("span", {
|
|
228
230
|
className: "min-w-[1.75rem] text-center text-sm font-semibold text-text-primary",
|
|
229
231
|
children: e.quantity
|
|
230
232
|
}),
|
|
231
|
-
/* @__PURE__ */
|
|
233
|
+
/* @__PURE__ */ O(A, {
|
|
232
234
|
variant: "outline",
|
|
233
235
|
size: "icon-sm",
|
|
234
|
-
"aria-label":
|
|
235
|
-
onClick: () =>
|
|
236
|
-
children: /* @__PURE__ */
|
|
236
|
+
"aria-label": M("healthybowl.agriInputs.cart.increase", "Increase quantity"),
|
|
237
|
+
onClick: () => G(e.productId, e.quantity + 1),
|
|
238
|
+
children: /* @__PURE__ */ O(ae, { className: "h-3 w-3" })
|
|
237
239
|
})
|
|
238
240
|
]
|
|
239
241
|
}),
|
|
240
|
-
/* @__PURE__ */
|
|
242
|
+
/* @__PURE__ */ O(A, {
|
|
241
243
|
variant: "ghost",
|
|
242
244
|
size: "icon-sm",
|
|
243
|
-
"aria-label":
|
|
244
|
-
onClick: () =>
|
|
245
|
+
"aria-label": M("healthybowl.agriInputs.cart.remove", "Remove item"),
|
|
246
|
+
onClick: () => K(e.productId),
|
|
245
247
|
className: "text-status-error-text hover:text-status-error-text",
|
|
246
|
-
children: /* @__PURE__ */
|
|
248
|
+
children: /* @__PURE__ */ O(w, { className: "h-4 w-4" })
|
|
247
249
|
})
|
|
248
250
|
]
|
|
249
251
|
}, e.id))
|
|
250
|
-
}), /* @__PURE__ */
|
|
252
|
+
}), /* @__PURE__ */ k("div", {
|
|
251
253
|
className: "space-y-3 border-t border-border-subtle p-4",
|
|
252
254
|
children: [
|
|
253
|
-
/* @__PURE__ */
|
|
254
|
-
/* @__PURE__ */
|
|
255
|
+
/* @__PURE__ */ k("div", { children: [
|
|
256
|
+
/* @__PURE__ */ k("label", {
|
|
255
257
|
htmlFor: "agri-delivery-address",
|
|
256
258
|
className: "mb-1 flex items-center gap-1.5 text-xs font-medium text-text-secondary",
|
|
257
|
-
children: [/* @__PURE__ */
|
|
259
|
+
children: [/* @__PURE__ */ O(re, { className: "h-3.5 w-3.5" }), M("healthybowl.agriInputs.cart.deliverTo", "Deliver to")]
|
|
258
260
|
}),
|
|
259
|
-
/* @__PURE__ */
|
|
261
|
+
/* @__PURE__ */ O("textarea", {
|
|
260
262
|
id: "agri-delivery-address",
|
|
261
263
|
rows: 2,
|
|
262
264
|
value: q || Z,
|
|
263
265
|
onChange: (e) => J(e.target.value),
|
|
264
|
-
placeholder:
|
|
266
|
+
placeholder: M("healthybowl.agriInputs.cart.addressPlaceholder", "Delivery address (defaults to your farm location)"),
|
|
265
267
|
className: "w-full resize-none rounded-md border border-border-subtle bg-bg-surface p-2 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]"
|
|
266
268
|
}),
|
|
267
|
-
/* @__PURE__ */
|
|
269
|
+
/* @__PURE__ */ O("p", {
|
|
268
270
|
className: "mt-1 text-[10px] text-text-secondary",
|
|
269
|
-
children:
|
|
271
|
+
children: M("healthybowl.agriInputs.cart.addressHint", "Defaults to your farm location — edit if needed.")
|
|
270
272
|
})
|
|
271
273
|
] }),
|
|
272
|
-
/* @__PURE__ */
|
|
274
|
+
/* @__PURE__ */ k("div", {
|
|
273
275
|
className: "flex items-center justify-between text-sm",
|
|
274
|
-
children: [/* @__PURE__ */
|
|
276
|
+
children: [/* @__PURE__ */ O("span", {
|
|
275
277
|
className: "text-text-secondary",
|
|
276
|
-
children:
|
|
277
|
-
}), /* @__PURE__ */
|
|
278
|
+
children: M("healthybowl.agriInputs.cart.subtotal", "Subtotal")
|
|
279
|
+
}), /* @__PURE__ */ O("span", {
|
|
278
280
|
className: "text-base font-bold text-text-primary",
|
|
279
|
-
children:
|
|
281
|
+
children: d(fe, pe)
|
|
280
282
|
})]
|
|
281
283
|
}),
|
|
282
|
-
/* @__PURE__ */
|
|
284
|
+
/* @__PURE__ */ O(A, {
|
|
283
285
|
className: "w-full",
|
|
284
|
-
onClick:
|
|
285
|
-
disabled:
|
|
286
|
-
children:
|
|
286
|
+
onClick: ge,
|
|
287
|
+
disabled: U.length === 0,
|
|
288
|
+
children: M("healthybowl.agriInputs.cart.checkout", "Proceed to Checkout")
|
|
287
289
|
}),
|
|
288
|
-
/* @__PURE__ */
|
|
290
|
+
/* @__PURE__ */ O("button", {
|
|
289
291
|
type: "button",
|
|
290
|
-
onClick:
|
|
292
|
+
onClick: ce,
|
|
291
293
|
className: "w-full text-center text-xs text-text-secondary hover:text-status-error-text",
|
|
292
|
-
children:
|
|
294
|
+
children: M("healthybowl.agriInputs.cart.clear", "Clear cart")
|
|
293
295
|
}),
|
|
294
|
-
/* @__PURE__ */
|
|
296
|
+
/* @__PURE__ */ k("p", {
|
|
295
297
|
className: "flex items-center justify-center gap-1.5 text-[11px] text-text-secondary",
|
|
296
|
-
children: [/* @__PURE__ */
|
|
298
|
+
children: [/* @__PURE__ */ O(oe, { className: "h-3.5 w-3.5" }), M("healthybowl.agriInputs.cart.poweredBy", "Powered by Global Store + Billing")]
|
|
297
299
|
})
|
|
298
300
|
]
|
|
299
301
|
})] })]
|
|
300
302
|
})]
|
|
301
303
|
}),
|
|
302
|
-
/* @__PURE__ */
|
|
304
|
+
/* @__PURE__ */ k("div", {
|
|
303
305
|
className: "flex items-start gap-2 rounded-lg border border-border-subtle bg-bg-sunken/40 p-3 text-xs text-text-secondary",
|
|
304
|
-
children: [/* @__PURE__ */
|
|
306
|
+
children: [/* @__PURE__ */ O(C, { className: "mt-0.5 h-4 w-4 shrink-0 text-text-secondary" }), /* @__PURE__ */ O("p", { children: M("healthybowl.agriInputs.footerNote", "Products are served from the platform store catalog. HealthyBowl adds no product, order or payment tables for the store; your order is recorded on your HealthyBowl account and paid on the platform billing rail.") })]
|
|
305
307
|
}),
|
|
306
|
-
/* @__PURE__ */
|
|
307
|
-
toasts:
|
|
308
|
-
onDismiss:
|
|
308
|
+
/* @__PURE__ */ O(ee, {
|
|
309
|
+
toasts: F,
|
|
310
|
+
onDismiss: L
|
|
309
311
|
})
|
|
310
312
|
]
|
|
311
313
|
});
|
|
312
314
|
};
|
|
313
|
-
export {
|
|
315
|
+
export { M as AgriInputsStorePage };
|
|
@@ -1,74 +1,79 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { StoreImage as e } from "../../components/StoreImage.js";
|
|
2
|
+
import { useStoreProduce as t } from "../../hooks/useStoreProduce.js";
|
|
3
|
+
import { storeProductIconSrc as n } from "../../utils/storeImage.js";
|
|
4
|
+
import { formatCurrency as r } from "../../utils/helpers.js";
|
|
5
|
+
import { useI18n as i } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
6
|
+
import { Store as a } from "lucide-react";
|
|
7
|
+
import { useNavigate as o } from "react-router";
|
|
8
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
7
9
|
// src/healthybowl/pages/marketplace/StoreProduceStrip.tsx
|
|
8
|
-
var
|
|
9
|
-
let { t:
|
|
10
|
-
return
|
|
11
|
-
"aria-label":
|
|
10
|
+
var l = () => {
|
|
11
|
+
let { t: l } = i(), u = o(), { produce: d, totalCount: f, loading: p } = t(8);
|
|
12
|
+
return p || d.length === 0 ? null : /* @__PURE__ */ c("section", {
|
|
13
|
+
"aria-label": l("healthybowl.marketplace.store.title", "Fresh from other farms"),
|
|
12
14
|
className: "rounded-lg border border-border-subtle bg-bg-surface p-4",
|
|
13
|
-
children: [/* @__PURE__ */
|
|
15
|
+
children: [/* @__PURE__ */ c("div", {
|
|
14
16
|
className: "mb-3 flex items-center justify-between gap-3",
|
|
15
|
-
children: [/* @__PURE__ */
|
|
17
|
+
children: [/* @__PURE__ */ c("div", {
|
|
16
18
|
className: "flex items-center gap-2",
|
|
17
|
-
children: [/* @__PURE__ */
|
|
19
|
+
children: [/* @__PURE__ */ s("span", {
|
|
18
20
|
className: "flex h-8 w-8 items-center justify-center rounded-md bg-bg-sunken text-text-secondary",
|
|
19
|
-
children: /* @__PURE__ */ a
|
|
20
|
-
}), /* @__PURE__ */
|
|
21
|
+
children: /* @__PURE__ */ s(a, { className: "h-4 w-4" })
|
|
22
|
+
}), /* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("h3", {
|
|
21
23
|
className: "text-sm font-semibold text-text-primary",
|
|
22
|
-
children:
|
|
23
|
-
}), /* @__PURE__ */
|
|
24
|
+
children: l("healthybowl.marketplace.store.title", "Fresh from other farms")
|
|
25
|
+
}), /* @__PURE__ */ s("p", {
|
|
24
26
|
className: "text-xs text-text-secondary",
|
|
25
|
-
children:
|
|
27
|
+
children: l("healthybowl.marketplace.store.subtitle", "Published produce from across the marketplace store.")
|
|
26
28
|
})] })]
|
|
27
|
-
}), /* @__PURE__ */
|
|
29
|
+
}), /* @__PURE__ */ c("button", {
|
|
28
30
|
type: "button",
|
|
29
|
-
onClick: () =>
|
|
31
|
+
onClick: () => u("/store/marketplace"),
|
|
30
32
|
className: "shrink-0 text-xs font-medium text-action-primary-text underline-offset-2 hover:underline",
|
|
31
|
-
children: [
|
|
33
|
+
children: [l("healthybowl.marketplace.store.viewAll", "Browse store"), f > d.length ? ` (${f})` : ""]
|
|
32
34
|
})]
|
|
33
|
-
}), /* @__PURE__ */
|
|
35
|
+
}), /* @__PURE__ */ s("div", {
|
|
34
36
|
className: "grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4",
|
|
35
|
-
children:
|
|
37
|
+
children: d.map((t) => /* @__PURE__ */ c("button", {
|
|
36
38
|
type: "button",
|
|
37
|
-
onClick: () =>
|
|
39
|
+
onClick: () => u(`/store/marketplace/product/${t.id}`),
|
|
38
40
|
className: "flex flex-col overflow-hidden rounded-md border border-border-subtle bg-bg-sunken/40 text-start transition-colors hover:border-border-default",
|
|
39
|
-
children: [/* @__PURE__ */
|
|
41
|
+
children: [/* @__PURE__ */ s("div", {
|
|
40
42
|
className: "flex h-24 items-center justify-center bg-bg-sunken",
|
|
41
|
-
children:
|
|
42
|
-
src:
|
|
43
|
-
alt:
|
|
43
|
+
children: /* @__PURE__ */ s(e, {
|
|
44
|
+
src: n(t),
|
|
45
|
+
alt: t.name,
|
|
44
46
|
className: "h-full w-full object-cover",
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
fallback: /* @__PURE__ */ s(a, {
|
|
48
|
+
className: "h-6 w-6 text-text-muted",
|
|
49
|
+
"aria-hidden": "true"
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
}), /* @__PURE__ */ c("div", {
|
|
48
53
|
className: "flex flex-1 flex-col gap-1 p-2",
|
|
49
54
|
children: [
|
|
50
|
-
/* @__PURE__ */
|
|
55
|
+
/* @__PURE__ */ s("p", {
|
|
51
56
|
className: "line-clamp-2 text-xs font-medium text-text-primary",
|
|
52
|
-
children:
|
|
57
|
+
children: t.name
|
|
53
58
|
}),
|
|
54
|
-
|
|
59
|
+
t.category ? /* @__PURE__ */ s("span", {
|
|
55
60
|
className: "w-fit rounded bg-bg-surface px-1.5 py-0.5 text-[10px] text-text-secondary",
|
|
56
|
-
children:
|
|
61
|
+
children: t.category
|
|
57
62
|
}) : null,
|
|
58
|
-
/* @__PURE__ */
|
|
63
|
+
/* @__PURE__ */ c("div", {
|
|
59
64
|
className: "mt-auto flex items-center justify-between pt-1",
|
|
60
|
-
children: [/* @__PURE__ */
|
|
65
|
+
children: [/* @__PURE__ */ s("span", {
|
|
61
66
|
className: "text-xs font-semibold text-text-primary",
|
|
62
|
-
children: t
|
|
63
|
-
}), /* @__PURE__ */
|
|
67
|
+
children: r(t.price, t.currency)
|
|
68
|
+
}), /* @__PURE__ */ s("span", {
|
|
64
69
|
className: "text-[10px] text-text-secondary",
|
|
65
|
-
children:
|
|
70
|
+
children: t.stockQuantity && t.stockQuantity > 0 ? l("healthybowl.marketplace.store.inStock", "{{n}} in stock", { n: t.stockQuantity }) : l("healthybowl.marketplace.store.outOfStock", "Out of stock")
|
|
66
71
|
})]
|
|
67
72
|
})
|
|
68
73
|
]
|
|
69
74
|
})]
|
|
70
|
-
},
|
|
75
|
+
}, t.id))
|
|
71
76
|
})]
|
|
72
77
|
});
|
|
73
78
|
};
|
|
74
|
-
export {
|
|
79
|
+
export { l as StoreProduceStrip };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for rendering global-store catalogue imagery (product icons) and for reading the
|
|
3
|
+
* `browseStore` query while the deployed supergraph may not yet know `StoreProduct.iconUrl`.
|
|
4
|
+
*
|
|
5
|
+
* Store `icon` values are free-form: https URLs, bare Iconify names such as `mdi:sprout`,
|
|
6
|
+
* expiring presigned S3 links or dead third-party URLs. global-store-svc now resolves them into
|
|
7
|
+
* `StoreProduct.iconUrl` (an https URL or an offline-rendered `data:image/svg+xml` URI, or null when
|
|
8
|
+
* the icon cannot be rendered). The UI prefers `iconUrl`, filters whatever it falls back to through
|
|
9
|
+
* {@link classifyStoreImageSrc}, and swaps in a placeholder when an image still fails to load.
|
|
10
|
+
*
|
|
11
|
+
* @module healthybowl
|
|
12
|
+
*/
|
|
13
|
+
/** Whether a stored image value can go into an `<img src>`, and the value to use. */
|
|
14
|
+
export type StoreImageSource = {
|
|
15
|
+
kind: 'url';
|
|
16
|
+
src: string;
|
|
17
|
+
} | {
|
|
18
|
+
kind: 'none';
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Decides whether a store image value is safe and likely to render in a browser `<img>`.
|
|
22
|
+
*
|
|
23
|
+
* Accepted: absolute `https:` URLs that are not signed, expiring object-storage links;
|
|
24
|
+
* `data:image/...` URIs (such as the offline-rendered Iconify SVGs in `StoreProduct.iconUrl`); and
|
|
25
|
+
* root-relative paths such as `/images/icon.png`.
|
|
26
|
+
*
|
|
27
|
+
* Rejected: bare Iconify names (`mdi:sprout`), protocol-relative `//host` URLs, `http:`,
|
|
28
|
+
* `javascript:` and any other scheme, signed/presigned URLs, and empty or malformed values.
|
|
29
|
+
*/
|
|
30
|
+
export declare function classifyStoreImageSrc(value: string | null | undefined): StoreImageSource;
|
|
31
|
+
/**
|
|
32
|
+
* The image value to render for a store product's icon: the server-resolved `iconUrl` when present
|
|
33
|
+
* (always browser-renderable or null), otherwise the raw `icon`, which {@link classifyStoreImageSrc}
|
|
34
|
+
* still filters before it reaches an `<img>`.
|
|
35
|
+
*/
|
|
36
|
+
export declare function storeProductIconSrc(product: {
|
|
37
|
+
icon?: string | null;
|
|
38
|
+
iconUrl?: string | null;
|
|
39
|
+
}): string | null;
|
|
40
|
+
/** Minimal GraphQL response shape returned by the global gateway. */
|
|
41
|
+
export interface StoreGraphQLResponse<T> {
|
|
42
|
+
data?: T | null;
|
|
43
|
+
errors?: {
|
|
44
|
+
message?: string;
|
|
45
|
+
}[];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* True when the gateway refused the document because its supergraph predates
|
|
49
|
+
* `StoreProduct.iconUrl` (for example `Cannot query field "iconUrl" on type "StoreProduct".`) and
|
|
50
|
+
* returned no data. Any other failure returns false and keeps its normal handling.
|
|
51
|
+
*/
|
|
52
|
+
export declare function storeQueryRejectedIconUrl<T>(res: StoreGraphQLResponse<T>): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* POST a `browseStore` read to the global gateway, selecting `iconUrl` first and retrying once with
|
|
55
|
+
* the matching document that omits it when the gateway does not know the field yet. Products from
|
|
56
|
+
* the fallback have no `iconUrl`, so {@link storeProductIconSrc} uses the raw `icon` as before. The
|
|
57
|
+
* fallback response is returned as is, success or not.
|
|
58
|
+
*/
|
|
59
|
+
export declare function queryGlobalStore<T>(globalGatewayUrl: string, documents: {
|
|
60
|
+
primary: string;
|
|
61
|
+
withoutIconUrl: string;
|
|
62
|
+
}, variables: Record<string, unknown>): Promise<StoreGraphQLResponse<T>>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// src/healthybowl/utils/storeImage.ts
|
|
2
|
+
var e = /* @__PURE__ */ new Set([
|
|
3
|
+
"x-amz-signature",
|
|
4
|
+
"x-amz-expires",
|
|
5
|
+
"x-amz-credential",
|
|
6
|
+
"x-goog-signature",
|
|
7
|
+
"x-goog-expires"
|
|
8
|
+
]), t = { kind: "none" };
|
|
9
|
+
function n(t) {
|
|
10
|
+
for (let n of t.searchParams.keys()) if (e.has(n.toLowerCase())) return !0;
|
|
11
|
+
return !1;
|
|
12
|
+
}
|
|
13
|
+
function r(e) {
|
|
14
|
+
if (typeof e != "string") return t;
|
|
15
|
+
let r = e.trim();
|
|
16
|
+
if (!r) return t;
|
|
17
|
+
if (/^data:image\//i.test(r)) return {
|
|
18
|
+
kind: "url",
|
|
19
|
+
src: r
|
|
20
|
+
};
|
|
21
|
+
if (r.startsWith("/")) return r.startsWith("//") || r.startsWith("/\\") ? t : {
|
|
22
|
+
kind: "url",
|
|
23
|
+
src: r
|
|
24
|
+
};
|
|
25
|
+
let i;
|
|
26
|
+
try {
|
|
27
|
+
i = new URL(r);
|
|
28
|
+
} catch {
|
|
29
|
+
return t;
|
|
30
|
+
}
|
|
31
|
+
return i.protocol !== "https:" || !i.hostname || n(i) ? t : {
|
|
32
|
+
kind: "url",
|
|
33
|
+
src: r
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function i(e) {
|
|
37
|
+
return e.iconUrl ?? e.icon ?? null;
|
|
38
|
+
}
|
|
39
|
+
function a(e) {
|
|
40
|
+
return !e.data && (e.errors ?? []).some((e) => /Cannot query field ["']?iconUrl["']?/i.test(e.message ?? ""));
|
|
41
|
+
}
|
|
42
|
+
async function o(e, t, n) {
|
|
43
|
+
let r = async (t) => await (await fetch(`${e}/global/graphql`, {
|
|
44
|
+
method: "POST",
|
|
45
|
+
credentials: "include",
|
|
46
|
+
headers: { "content-type": "application/json" },
|
|
47
|
+
body: JSON.stringify({
|
|
48
|
+
query: t,
|
|
49
|
+
variables: n
|
|
50
|
+
})
|
|
51
|
+
})).json(), i = await r(t.primary);
|
|
52
|
+
return a(i) ? r(t.withoutIconUrl) : i;
|
|
53
|
+
}
|
|
54
|
+
export { r as classifyStoreImageSrc, o as queryGlobalStore, i as storeProductIconSrc, a as storeQueryRejectedIconUrl };
|
package/package.json
CHANGED