@burdenoff/microfe-healthybowl 2026.714.1 → 2026.714.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,87 @@
1
+ import { useHealthyBowl as e } from "../context/HealthyBowlContext.js";
2
+ import { useCallback as t, useMemo as n } from "react";
3
+ import { gql as r } from "@apollo/client";
4
+ import { useMutation as i, useQuery as a } from "@apollo/client/react";
5
+ //#region src/healthybowl/hooks/useOrderPayments.ts
6
+ var o = "https://checkout.razorpay.com/v1/checkout.js", s = null;
7
+ function c() {
8
+ return typeof window > "u" || typeof document > "u" ? Promise.reject(/* @__PURE__ */ Error("Razorpay checkout is only available in a browser")) : window.Razorpay ? Promise.resolve(window.Razorpay) : s || (s = new Promise((e, t) => {
9
+ document.querySelectorAll(`script[src="${o}"]`).forEach((e) => e.remove());
10
+ let n = document.createElement("script"), r = (e) => {
11
+ s = null, n.remove(), t(Error(e));
12
+ };
13
+ n.addEventListener("load", () => {
14
+ if (window.Razorpay) {
15
+ e(window.Razorpay);
16
+ return;
17
+ }
18
+ r("Razorpay checkout loaded but window.Razorpay is missing");
19
+ }), n.addEventListener("error", () => r("Could not load the Razorpay checkout script")), n.src = o, n.async = !0, document.body.appendChild(n);
20
+ }), s);
21
+ }
22
+ var l = "\n id\n orderNumber\n status\n paymentStatus\n total\n paymentProvider\n paymentReference\n paidAmount\n paidAt\n", u = r`
23
+ query HealthyBowlOrderPayments($context: ContextInput!) {
24
+ getHealthyBowlMarketplaceData(context: $context) {
25
+ orders {
26
+ ${l}
27
+ }
28
+ }
29
+ }
30
+ `, d = r`
31
+ mutation CheckoutHealthyBowlOrder($orderId: ID!, $context: ContextInput!) {
32
+ checkoutHealthyBowlOrder(orderId: $orderId, context: $context) {
33
+ orderId
34
+ billingOrderId
35
+ provider
36
+ providerOrderId
37
+ razorpayKeyId
38
+ clientSecret
39
+ subtotal
40
+ taxAmount
41
+ total
42
+ currency
43
+ }
44
+ }
45
+ `, f = r`
46
+ mutation SyncHealthyBowlOrderPayment($orderId: ID!, $context: ContextInput!) {
47
+ syncHealthyBowlOrderPayment(orderId: $orderId, context: $context) {
48
+ ${l}
49
+ }
50
+ }
51
+ `;
52
+ function p() {
53
+ let { workspaceId: r } = e(), o = { workspaceId: r }, { data: s, refetch: c } = a(u, {
54
+ variables: { context: o },
55
+ skip: !r,
56
+ fetchPolicy: "cache-and-network",
57
+ errorPolicy: "all",
58
+ notifyOnNetworkStatusChange: !0
59
+ }), [l] = i(d), [p] = i(f);
60
+ return {
61
+ payments: n(() => {
62
+ let e = s?.getHealthyBowlMarketplaceData?.orders ?? [];
63
+ return Object.fromEntries(e.map((e) => [e.id, e]));
64
+ }, [s]),
65
+ refetchPayments: c,
66
+ checkoutOrder: t(async (e) => {
67
+ let t = (await l({ variables: {
68
+ orderId: e,
69
+ context: o
70
+ } })).data?.checkoutHealthyBowlOrder;
71
+ if (!t) throw Error("Checkout did not return a payment session");
72
+ return t;
73
+ }, [l, r]),
74
+ syncOrderPayment: t(async (e) => {
75
+ let t = (await p({ variables: {
76
+ orderId: e,
77
+ context: o
78
+ } })).data?.syncHealthyBowlOrderPayment;
79
+ if (!t) throw Error("Payment sync did not return the order");
80
+ return t;
81
+ }, [p, r])
82
+ };
83
+ }
84
+ //#endregion
85
+ export { c as loadRazorpayCheckout, p as useOrderPayments };
86
+
87
+ //# sourceMappingURL=useOrderPayments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOrderPayments.js","names":[],"sources":["../../../src/healthybowl/hooks/useOrderPayments.ts"],"sourcesContent":["/**\n * Real marketplace payments (roadmap #6, acceptance D-2).\n *\n * A fixed-price \"Buy Now\" purchase and a won auction both create an Order with `paymentStatus:\n * pending`. Paying it goes through the platform billing rail, never through this client:\n *\n * 1. `checkoutHealthyBowlOrder` → the backend creates the BillingOrder in global-billing and\n * initiates the payment, handing back what the provider's checkout widget needs.\n * 2. the buyer pays in the provider's widget (Razorpay), loaded lazily on first use.\n * 3. `syncHealthyBowlOrderPayment` → the backend RE-READS the authoritative Payment from billing\n * and only then flips the order to PAID with the gateway's real payment reference.\n *\n * The client never marks anything paid — it only asks the backend to settle, and the backend only\n * settles what billing reports as SUCCEEDED. Calling sync on an abandoned checkout is safe: it\n * simply confirms the order is still pending.\n *\n * These operations post-date the checked-in SDL, so — mirroring `useAuctions` / `useSharedMarket` —\n * they are hand-written `gql` documents executed directly against the live gateway.\n * @module healthybowl\n */\nimport { useCallback, useMemo } from 'react';\nimport { gql } from '@apollo/client';\nimport { useMutation, useQuery } from '@apollo/client/react';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\n\n// ── Razorpay checkout widget ──────────────────────────────────────────────────\n/** The subset of Razorpay's checkout options this flow uses. */\nexport interface RazorpayCheckoutOptions {\n /** Razorpay publishable key id (from the backend — never hard-coded here). */\n key: string;\n /** The provider's own order id (`order_xxx`), created by global-billing. */\n order_id: string;\n /** Amount in the smallest currency unit (paise for INR). */\n amount: number;\n currency: string;\n name: string;\n description?: string;\n /** Called by Razorpay when the payment succeeds. */\n handler?: (response: RazorpayPaymentResponse) => void;\n modal?: { ondismiss?: () => void };\n theme?: { color?: string };\n}\n\n/** What Razorpay hands back on success. HB ignores the values (billing is the authority) — it only\n * uses the callback as a signal to ask the backend to settle. */\nexport interface RazorpayPaymentResponse {\n razorpay_payment_id?: string;\n razorpay_order_id?: string;\n razorpay_signature?: string;\n}\n\nexport interface RazorpayInstance {\n open: () => void;\n close?: () => void;\n}\n\nexport type RazorpayConstructor = new (options: RazorpayCheckoutOptions) => RazorpayInstance;\n\ndeclare global {\n interface Window {\n Razorpay?: RazorpayConstructor;\n }\n}\n\nconst RAZORPAY_CHECKOUT_SRC = 'https://checkout.razorpay.com/v1/checkout.js';\n\n/** Cached so the script is injected at most once per page, however many orders get paid. */\nlet razorpayScriptPromise: Promise<RazorpayConstructor> | null = null;\n\n/**\n * Lazily inject Razorpay's checkout script and resolve with the global constructor. It is loaded on\n * first use rather than from index.html so that the vast majority of sessions — which never pay for\n * anything — don't fetch a third-party script at all.\n */\nexport function loadRazorpayCheckout(): Promise<RazorpayConstructor> {\n if (typeof window === 'undefined' || typeof document === 'undefined') {\n return Promise.reject(new Error('Razorpay checkout is only available in a browser'));\n }\n if (window.Razorpay) return Promise.resolve(window.Razorpay);\n if (razorpayScriptPromise) return razorpayScriptPromise;\n\n razorpayScriptPromise = new Promise<RazorpayConstructor>((resolve, reject) => {\n // Never adopt a <script> we didn't just inject. An element already in the DOM may have fired\n // its load/error before we could listen, and listeners attached afterwards would never run —\n // leaving this promise (and the cached one every later call returns) pending forever, with the\n // Pay Now button stuck disabled. Dropping any pre-existing tag and injecting a fresh one makes\n // load/error guaranteed to fire. We only get here when window.Razorpay is absent, so nothing\n // usable is being thrown away.\n document.querySelectorAll<HTMLScriptElement>(`script[src=\"${RAZORPAY_CHECKOUT_SRC}\"]`).forEach((el) => el.remove());\n\n const script = document.createElement('script');\n\n /**\n * A failed load must leave NO trace: null the cached promise *and* drop the dead <script>, so\n * the next attempt injects a genuinely fresh one rather than replaying a rejected promise or\n * waiting on a spent element.\n */\n const fail = (message: string) => {\n razorpayScriptPromise = null;\n script.remove();\n reject(new Error(message));\n };\n\n script.addEventListener('load', () => {\n if (window.Razorpay) {\n resolve(window.Razorpay);\n return;\n }\n fail('Razorpay checkout loaded but window.Razorpay is missing');\n });\n script.addEventListener('error', () => fail('Could not load the Razorpay checkout script'));\n\n script.src = RAZORPAY_CHECKOUT_SRC;\n script.async = true;\n document.body.appendChild(script);\n });\n\n return razorpayScriptPromise;\n}\n\n// ── Operations ────────────────────────────────────────────────────────────────\n/** Everything the client needs to open the provider's checkout for an order. */\nexport interface OrderCheckout {\n orderId: string;\n billingOrderId: string;\n /** RAZORPAY / STRIPE — billing decides, the client only reacts. */\n provider: string;\n /** Razorpay `order_xxx`; null when billing routed to another provider. */\n providerOrderId?: string | null;\n razorpayKeyId?: string | null;\n /** Stripe's client secret, when billing routes to Stripe (not handled by this UI). */\n clientSecret?: string | null;\n subtotal: number;\n /** Tax computed by billing, not by HB. */\n taxAmount: number;\n total: number;\n currency: string;\n}\n\n/** The payment provenance of an order, as mirrored from the billing rail. */\nexport interface OrderPayment {\n id: string;\n orderNumber?: string;\n status?: string;\n paymentStatus?: string;\n total?: number;\n /** RAZORPAY / STRIPE for a gateway-verified payment; MANUAL for an offline sale marked paid. */\n paymentProvider?: string | null;\n /** The gateway's own payment reference (e.g. Razorpay `pay_xxx`). Null for a MANUAL sale. */\n paymentReference?: string | null;\n paidAmount?: number | null;\n paidAt?: string | null;\n}\n\nconst ORDER_PAYMENT_FIELDS = `\n id\n orderNumber\n status\n paymentStatus\n total\n paymentProvider\n paymentReference\n paidAmount\n paidAt\n`;\n\n/**\n * The payment provenance of every order. Read through the marketplace payload (the only order read\n * this service exposes) but selecting ONLY the payment columns, which the codegen'd\n * `GetHealthyBowlMarketplaceData` document cannot carry — the checked-in SDL predates them.\n */\nconst ORDER_PAYMENTS_QUERY = gql`\n query HealthyBowlOrderPayments($context: ContextInput!) {\n getHealthyBowlMarketplaceData(context: $context) {\n orders {\n ${ORDER_PAYMENT_FIELDS}\n }\n }\n }\n`;\n\nconst CHECKOUT_ORDER = gql`\n mutation CheckoutHealthyBowlOrder($orderId: ID!, $context: ContextInput!) {\n checkoutHealthyBowlOrder(orderId: $orderId, context: $context) {\n orderId\n billingOrderId\n provider\n providerOrderId\n razorpayKeyId\n clientSecret\n subtotal\n taxAmount\n total\n currency\n }\n }\n`;\n\nconst SYNC_ORDER_PAYMENT = gql`\n mutation SyncHealthyBowlOrderPayment($orderId: ID!, $context: ContextInput!) {\n syncHealthyBowlOrderPayment(orderId: $orderId, context: $context) {\n ${ORDER_PAYMENT_FIELDS}\n }\n }\n`;\n\ninterface OrderPaymentsQueryData {\n getHealthyBowlMarketplaceData: { orders: OrderPayment[] } | null;\n}\ninterface CheckoutOrderData {\n checkoutHealthyBowlOrder: OrderCheckout;\n}\ninterface SyncOrderPaymentData {\n syncHealthyBowlOrderPayment: OrderPayment;\n}\n\n/**\n * Exposes the payment provenance of each order plus the two settlement calls.\n *\n * The provenance read is best-effort (`errorPolicy: 'all'`): the orders list itself comes from\n * `useHealthyBowlData`, so if this read fails the page still renders — it just can't show where the\n * money came from.\n */\nexport function useOrderPayments() {\n const { workspaceId } = useHealthyBowl();\n const context = { workspaceId };\n\n const { data, refetch } = useQuery<OrderPaymentsQueryData>(ORDER_PAYMENTS_QUERY, {\n variables: { context },\n skip: !workspaceId,\n fetchPolicy: 'cache-and-network',\n errorPolicy: 'all',\n notifyOnNetworkStatusChange: true,\n });\n\n const [checkoutMutation] = useMutation<CheckoutOrderData>(CHECKOUT_ORDER);\n const [syncMutation] = useMutation<SyncOrderPaymentData>(SYNC_ORDER_PAYMENT);\n\n /** Payment provenance keyed by order id. */\n const payments = useMemo<Record<string, OrderPayment>>(() => {\n const orders = data?.getHealthyBowlMarketplaceData?.orders ?? [];\n return Object.fromEntries(orders.map((o) => [o.id, o]));\n }, [data]);\n\n /** Start a real payment. Idempotent server-side — a re-checkout reuses the existing BillingOrder. */\n const checkoutOrder = useCallback(\n async (orderId: string): Promise<OrderCheckout> => {\n const res = await checkoutMutation({ variables: { orderId, context } });\n const checkout = res.data?.checkoutHealthyBowlOrder;\n if (!checkout) throw new Error('Checkout did not return a payment session');\n return checkout;\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [checkoutMutation, workspaceId]\n );\n\n /**\n * Ask the backend to settle the order against the billing rail. It re-reads the authoritative\n * Payment and marks the order paid ONLY if billing reports it SUCCEEDED — so this is also the\n * right call to make when the buyer closes the widget without paying (the order stays pending).\n */\n const syncOrderPayment = useCallback(\n async (orderId: string): Promise<OrderPayment> => {\n const res = await syncMutation({ variables: { orderId, context } });\n const order = res.data?.syncHealthyBowlOrderPayment;\n if (!order) throw new Error('Payment sync did not return the order');\n return order;\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [syncMutation, workspaceId]\n );\n\n return { payments, refetchPayments: refetch, checkoutOrder, syncOrderPayment };\n}\n"],"mappings":";;;;;AAgEA,IAAM,IAAwB,gDAG1B,IAA6D;AAOjE,SAAgB,IAAqD;AA2CnE,QA1CI,OAAO,SAAW,OAAe,OAAO,WAAa,MAChD,QAAQ,OAAO,gBAAI,MAAM,mDAAmD,CAAC,GAElF,OAAO,WAAiB,QAAQ,QAAQ,OAAO,SAAS,GACxD,MAEJ,IAAwB,IAAI,SAA8B,GAAS,MAAW;AAO5E,WAAS,iBAAoC,eAAe,EAAsB,IAAI,CAAC,SAAS,MAAO,EAAG,QAAQ,CAAC;EAEnH,IAAM,IAAS,SAAS,cAAc,SAAS,EAOzC,KAAQ,MAAoB;AAGhC,GAFA,IAAwB,MACxB,EAAO,QAAQ,EACf,EAAW,MAAM,EAAQ,CAAC;;AAc5B,EAXA,EAAO,iBAAiB,cAAc;AACpC,OAAI,OAAO,UAAU;AACnB,MAAQ,OAAO,SAAS;AACxB;;AAEF,KAAK,0DAA0D;IAC/D,EACF,EAAO,iBAAiB,eAAe,EAAK,8CAA8C,CAAC,EAE3F,EAAO,MAAM,GACb,EAAO,QAAQ,IACf,SAAS,KAAK,YAAY,EAAO;GACjC,EAEK;;AAqCT,IAAM,IAAuB,8HAiBvB,IAAuB,CAAG;;;;UAItB,EAAqB;;;;GAMzB,IAAiB,CAAG;;;;;;;;;;;;;;;GAiBpB,IAAqB,CAAG;;;QAGtB,EAAqB;;;;AAsB7B,SAAgB,IAAmB;CACjC,IAAM,EAAE,mBAAgB,GAAgB,EAClC,IAAU,EAAE,gBAAa,EAEzB,EAAE,SAAM,eAAY,EAAiC,GAAsB;EAC/E,WAAW,EAAE,YAAS;EACtB,MAAM,CAAC;EACP,aAAa;EACb,aAAa;EACb,6BAA6B;EAC9B,CAAC,EAEI,CAAC,KAAoB,EAA+B,EAAe,EACnE,CAAC,KAAgB,EAAkC,EAAmB;AAoC5E,QAAO;EAAE,UAjCQ,QAA4C;GAC3D,IAAM,IAAS,GAAM,+BAA+B,UAAU,EAAE;AAChE,UAAO,OAAO,YAAY,EAAO,KAAK,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;KACtD,CAAC,EAAK,CAAC;EA8BS,iBAAiB;EAAS,eA3BvB,EACpB,OAAO,MAA4C;GAEjD,IAAM,KADM,MAAM,EAAiB,EAAE,WAAW;IAAE;IAAS;IAAS,EAAE,CAAC,EAClD,MAAM;AAC3B,OAAI,CAAC,EAAU,OAAU,MAAM,4CAA4C;AAC3E,UAAO;KAGT,CAAC,GAAkB,EAAY,CAChC;EAkB2D,kBAXnC,EACvB,OAAO,MAA2C;GAEhD,IAAM,KADM,MAAM,EAAa,EAAE,WAAW;IAAE;IAAS;IAAS,EAAE,CAAC,EACjD,MAAM;AACxB,OAAI,CAAC,EAAO,OAAU,MAAM,wCAAwC;AACpE,UAAO;KAGT,CAAC,GAAc,EAAY,CAC5B;EAE6E"}
@@ -0,0 +1,54 @@
1
+ import { useHealthyBowl as e } from "../context/HealthyBowlContext.js";
2
+ import { useCallback as t, useMemo as n } from "react";
3
+ import { gql as r } from "@apollo/client";
4
+ import { useMutation as i, useQuery as a } from "@apollo/client/react";
5
+ //#region src/healthybowl/hooks/useSharedMarket.ts
6
+ var o = r`
7
+ query HealthyBowlSharedMarketListings($context: ContextInput!, $category: String, $search: String, $limit: Int) {
8
+ healthyBowlSharedMarketListings(context: $context, category: $category, search: $search, limit: $limit) {
9
+ ${"\n id\n name\n category\n price\n unit\n stock\n organicCertified\n image\n description\n seller\n sellerRating\n location\n rating\n"}
10
+ }
11
+ }
12
+ `, s = r`
13
+ mutation SetHealthyBowlListingShared($id: ID!, $shared: Boolean!, $context: ContextInput!) {
14
+ setHealthyBowlListingShared(id: $id, shared: $shared, context: $context) {
15
+ id
16
+ name
17
+ }
18
+ }
19
+ `;
20
+ function c(t = {}) {
21
+ let { workspaceId: r } = e(), { data: i, loading: s, error: c, refetch: l } = a(o, {
22
+ variables: {
23
+ context: { workspaceId: r },
24
+ category: t.category && t.category !== "All" ? t.category : null,
25
+ search: t.search?.trim() ? t.search.trim() : null,
26
+ limit: t.limit ?? null
27
+ },
28
+ skip: !r,
29
+ fetchPolicy: "cache-and-network",
30
+ notifyOnNetworkStatusChange: !0
31
+ }), u = n(() => i?.healthyBowlSharedMarketListings ?? [], [i]);
32
+ return {
33
+ listings: u,
34
+ sharedListingIds: n(() => new Set(u.map((e) => e.id)), [u]),
35
+ loading: s,
36
+ error: c,
37
+ refetch: l
38
+ };
39
+ }
40
+ function l() {
41
+ let { workspaceId: n } = e(), r = { workspaceId: n }, [a, { loading: o }] = i(s);
42
+ return {
43
+ setListingShared: t(async (e, t) => (await a({ variables: {
44
+ id: e,
45
+ shared: t,
46
+ context: r
47
+ } })).data?.setHealthyBowlListingShared, [a, n]),
48
+ saving: o
49
+ };
50
+ }
51
+ //#endregion
52
+ export { l as useSetListingShared, c as useSharedMarketListings };
53
+
54
+ //# sourceMappingURL=useSharedMarket.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSharedMarket.js","names":[],"sources":["../../../src/healthybowl/hooks/useSharedMarket.ts"],"sourcesContent":["/**\n * Shared cross-farm marketplace (roadmap #6, acceptance D-1).\n *\n * `MarketplaceProduct` is workspace-scoped, so a buyer normally only ever sees their own farm's\n * listings. A farm OPTS IN per listing (`setHealthyBowlListingShared`) and the shared read then\n * returns listings from EVERY farm that has opted in — a narrowed projection\n * (`SharedMarketListing`) that carries the selling farm's identity, which is the entire point of a\n * cross-farm view.\n *\n * The offline codegen doesn't type these operations (they post-date the checked-in SDL), so —\n * mirroring the raw-gql pattern used for Auctions (`useAuctions`) and Irrigation (`useIrrigation`)\n * — they are hand-written `gql` documents executed directly against the live gateway. Every op\n * carries the workspace `context`.\n * @module healthybowl\n */\nimport { useCallback, useMemo } from 'react';\nimport { gql } from '@apollo/client';\nimport { useMutation, useQuery } from '@apollo/client/react';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\n\n/** A listing some farm has published to the shared cross-farm market. */\nexport interface SharedMarketListing {\n id: string;\n name: string;\n category: string;\n price: number;\n unit: string;\n stock: number;\n organicCertified: boolean;\n image?: string | null;\n description: string;\n /** The selling farm — what makes a cross-farm view legible. */\n seller?: string | null;\n sellerRating?: number | null;\n location?: string | null;\n rating: number;\n}\n\n/** Server-side filters for the shared-market read. */\nexport interface SharedMarketFilters {\n /** Exact category match; pass null/undefined (or 'All') for every category. */\n category?: string | null;\n /** Free-text match on name / description / seller. */\n search?: string | null;\n limit?: number | null;\n}\n\nconst SHARED_LISTING_FIELDS = `\n id\n name\n category\n price\n unit\n stock\n organicCertified\n image\n description\n seller\n sellerRating\n location\n rating\n`;\n\nconst SHARED_LISTINGS_QUERY = gql`\n query HealthyBowlSharedMarketListings($context: ContextInput!, $category: String, $search: String, $limit: Int) {\n healthyBowlSharedMarketListings(context: $context, category: $category, search: $search, limit: $limit) {\n ${SHARED_LISTING_FIELDS}\n }\n }\n`;\n\nconst SET_LISTING_SHARED = gql`\n mutation SetHealthyBowlListingShared($id: ID!, $shared: Boolean!, $context: ContextInput!) {\n setHealthyBowlListingShared(id: $id, shared: $shared, context: $context) {\n id\n name\n }\n }\n`;\n\ninterface SharedListingsQueryData {\n healthyBowlSharedMarketListings: SharedMarketListing[];\n}\n\ninterface SetListingSharedData {\n setHealthyBowlListingShared: { id: string; name: string };\n}\n\n/**\n * Loads the shared cross-farm listings. Filters are passed to the server (not applied client-side)\n * so the buyer searches every farm's catalogue, not just the page they happen to have loaded.\n *\n * `sharedListingIds` is the set of listing ids currently visible in the shared market. The\n * fixed-price tab uses it to show whether one of the farm's OWN listings is published — the\n * `MarketplaceProduct` type deliberately exposes no `sharedMarket` field, so this is the only\n * server-truth available. Caveat: the shared read excludes out-of-stock listings, so a published\n * listing with zero stock reads as unpublished until it is restocked; a toggle performed in-session\n * overrides that (see `MarketplacePage`).\n */\nexport function useSharedMarketListings(filters: SharedMarketFilters = {}) {\n const { workspaceId } = useHealthyBowl();\n const context = { workspaceId };\n const category = filters.category && filters.category !== 'All' ? filters.category : null;\n const search = filters.search?.trim() ? filters.search.trim() : null;\n const limit = filters.limit ?? null;\n\n const { data, loading, error, refetch } = useQuery<SharedListingsQueryData>(SHARED_LISTINGS_QUERY, {\n variables: { context, category, search, limit },\n skip: !workspaceId,\n fetchPolicy: 'cache-and-network',\n notifyOnNetworkStatusChange: true,\n });\n\n const listings = useMemo(() => data?.healthyBowlSharedMarketListings ?? [], [data]);\n const sharedListingIds = useMemo(() => new Set(listings.map((l) => l.id)), [listings]);\n\n return { listings, sharedListingIds, loading, error, refetch };\n}\n\n/**\n * Publish / unpublish one of the farm's OWN listings to the shared cross-farm market.\n * Workspace-scoped server-side: a farm can only ever change the flag on its own listings.\n */\nexport function useSetListingShared() {\n const { workspaceId } = useHealthyBowl();\n const context = { workspaceId };\n const [mutate, { loading }] = useMutation<SetListingSharedData>(SET_LISTING_SHARED);\n\n const setListingShared = useCallback(\n async (id: string, shared: boolean) => {\n const res = await mutate({ variables: { id, shared, context } });\n return res.data?.setHealthyBowlListingShared;\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [mutate, workspaceId]\n );\n\n return { setListingShared, saving: loading };\n}\n"],"mappings":";;;;;AA+DA,IAAM,IAAwB,CAAG;;;QAhBH,qJAmBA;;;GAKxB,IAAqB,CAAG;;;;;;;;AA4B9B,SAAgB,EAAwB,IAA+B,EAAE,EAAE;CACzE,IAAM,EAAE,mBAAgB,GAAgB,EAMlC,EAAE,SAAM,YAAS,UAAO,eAAY,EAAkC,GAAuB;EACjG,WAAW;GAAE,SANC,EAAE,gBAAa;GAMP,UALP,EAAQ,YAAY,EAAQ,aAAa,QAAQ,EAAQ,WAAW;GAKnD,QAJnB,EAAQ,QAAQ,MAAM,GAAG,EAAQ,OAAO,MAAM,GAAG;GAItB,OAH5B,EAAQ,SAAS;GAGkB;EAC/C,MAAM,CAAC;EACP,aAAa;EACb,6BAA6B;EAC9B,CAAC,EAEI,IAAW,QAAc,GAAM,mCAAmC,EAAE,EAAE,CAAC,EAAK,CAAC;AAGnF,QAAO;EAAE;EAAU,kBAFM,QAAc,IAAI,IAAI,EAAS,KAAK,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC,EAAS,CAAC;EAEjD;EAAS;EAAO;EAAS;;AAOhE,SAAgB,IAAsB;CACpC,IAAM,EAAE,mBAAgB,GAAgB,EAClC,IAAU,EAAE,gBAAa,EACzB,CAAC,GAAQ,EAAE,gBAAa,EAAkC,EAAmB;AAWnF,QAAO;EAAE,kBATgB,EACvB,OAAO,GAAY,OACL,MAAM,EAAO,EAAE,WAAW;GAAE;GAAI;GAAQ;GAAS,EAAE,CAAC,EACrD,MAAM,6BAGnB,CAAC,GAAQ,EAAY,CACtB;EAE0B,QAAQ;EAAS"}