@burdenoff/microfe-healthybowl 2026.816.2 → 2026.816.3

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.
@@ -27,11 +27,14 @@ function c(n) {
27
27
  notifyOnNetworkStatusChange: !0
28
28
  }), [p, { loading: m }] = r(s), h = t(async (e) => {
29
29
  let t = e.trim();
30
- !n || !t || (await p({ variables: { input: {
30
+ if (!n || !t) return;
31
+ let r = await p({ variables: { input: {
31
32
  supplierId: n,
32
33
  body: t,
33
34
  context: c
34
- } } }), await f());
35
+ } } });
36
+ if (r.error) throw Error(r.error.message || "Could not send your message. Please try again.");
37
+ await f();
35
38
  }, [
36
39
  p,
37
40
  f,
@@ -1 +1 @@
1
- {"version":3,"file":"useSupplierMessages.js","names":[],"sources":["../../../src/healthybowl/hooks/useSupplierMessages.ts"],"sourcesContent":["/**\n * Supplier conversation-thread hook (roadmap #5, \"Message supplier\").\n *\n * Backs the real, persisted supplier message thread with wspace-conversations-svc\n * (via the HB backend). Mirrors the raw-gql pattern used by `useSuppliers` /\n * `useNursery`: the offline codegen doesn't type these ops, so they are hand-written\n * `gql` documents run directly against the live gateway, each carrying the workspace\n * `context`.\n * @module healthybowl\n */\nimport { useCallback } from 'react';\nimport { gql } from '@apollo/client';\nimport { useMutation, useQuery } from '@apollo/client/react';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\n\n/** A single message in a supplier's conversation thread. */\nexport interface SupplierMessage {\n id: string;\n supplierId: string;\n conversationId: string;\n body: string;\n authorId: string;\n authorType?: string | null;\n /** ISO-8601 timestamp. */\n createdAt: string;\n}\n\nconst MESSAGE_FIELDS = `\n id\n supplierId\n conversationId\n body\n authorId\n authorType\n createdAt\n`;\n\nconst SUPPLIER_MESSAGES_QUERY = gql`\n query HealthyBowlSupplierMessages($supplierId: ID!, $context: ContextInput!) {\n healthyBowlSupplierMessages(supplierId: $supplierId, context: $context) {\n ${MESSAGE_FIELDS}\n }\n }\n`;\n\nconst SEND_SUPPLIER_MESSAGE = gql`\n mutation SendHealthyBowlSupplierMessage($input: SendHealthyBowlSupplierMessageInput!) {\n sendHealthyBowlSupplierMessage(input: $input) {\n ${MESSAGE_FIELDS}\n }\n }\n`;\n\ninterface SupplierMessagesQueryData {\n healthyBowlSupplierMessages: SupplierMessage[];\n}\n\n/**\n * Loads (and lets you send to) the conversation thread for a single supplier. Pass\n * `null` for `supplierId` to keep the hook dormant (e.g. while the thread modal is\n * closed) — the query is skipped and `sendMessage` is a no-op. Sending refetches the\n * thread so the new message appears without hand-managing the cache.\n */\nexport function useSupplierMessages(supplierId: string | null) {\n const { workspaceId } = useHealthyBowl();\n const context = { workspaceId };\n\n const { data, loading, error, refetch } = useQuery<SupplierMessagesQueryData>(SUPPLIER_MESSAGES_QUERY, {\n variables: { supplierId: supplierId ?? '', context },\n skip: !workspaceId || !supplierId,\n fetchPolicy: 'cache-and-network',\n notifyOnNetworkStatusChange: true,\n });\n\n const [sendMutation, { loading: sending }] = useMutation(SEND_SUPPLIER_MESSAGE);\n\n const sendMessage = useCallback(\n async (body: string) => {\n const trimmed = body.trim();\n if (!supplierId || !trimmed) return;\n await sendMutation({ variables: { input: { supplierId, body: trimmed, context } } });\n await refetch();\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [sendMutation, refetch, supplierId, workspaceId]\n );\n\n return {\n messages: data?.healthyBowlSupplierMessages ?? [],\n loading,\n sending,\n error,\n refetch,\n sendMessage,\n };\n}\n"],"mappings":";;;;;AA2BA,IAAM,IAAiB,2FAUjB,IAA0B,CAAG;;;QAG3B,EAAe;;;GAKjB,IAAwB,CAAG;;;QAGzB,EAAe;;;;AAevB,SAAgB,EAAoB,GAA2B;CAC7D,IAAM,EAAE,mBAAgB,GAAgB,EAClC,IAAU,EAAE,gBAAa,EAEzB,EAAE,SAAM,YAAS,UAAO,eAAY,EAAoC,GAAyB;EACrG,WAAW;GAAE,YAAY,KAAc;GAAI;GAAS;EACpD,MAAM,CAAC,KAAe,CAAC;EACvB,aAAa;EACb,6BAA6B;EAC9B,CAAC,EAEI,CAAC,GAAc,EAAE,SAAS,OAAa,EAAY,EAAsB,EAEzE,IAAc,EAClB,OAAO,MAAiB;EACtB,IAAM,IAAU,EAAK,MAAM;AACvB,GAAC,KAAc,CAAC,MACpB,MAAM,EAAa,EAAE,WAAW,EAAE,OAAO;GAAE;GAAY,MAAM;GAAS;GAAS,EAAE,EAAE,CAAC,EACpF,MAAM,GAAS;IAGjB;EAAC;EAAc;EAAS;EAAY;EAAY,CACjD;AAED,QAAO;EACL,UAAU,GAAM,+BAA+B,EAAE;EACjD;EACA;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"useSupplierMessages.js","names":[],"sources":["../../../src/healthybowl/hooks/useSupplierMessages.ts"],"sourcesContent":["/**\n * Supplier conversation-thread hook (roadmap #5, \"Message supplier\").\n *\n * Backs the real, persisted supplier message thread with wspace-conversations-svc\n * (via the HB backend). Mirrors the raw-gql pattern used by `useSuppliers` /\n * `useNursery`: the offline codegen doesn't type these ops, so they are hand-written\n * `gql` documents run directly against the live gateway, each carrying the workspace\n * `context`.\n * @module healthybowl\n */\nimport { useCallback } from 'react';\nimport { gql } from '@apollo/client';\nimport { useMutation, useQuery } from '@apollo/client/react';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\n\n/** A single message in a supplier's conversation thread. */\nexport interface SupplierMessage {\n id: string;\n supplierId: string;\n conversationId: string;\n body: string;\n authorId: string;\n authorType?: string | null;\n /** ISO-8601 timestamp. */\n createdAt: string;\n}\n\nconst MESSAGE_FIELDS = `\n id\n supplierId\n conversationId\n body\n authorId\n authorType\n createdAt\n`;\n\nconst SUPPLIER_MESSAGES_QUERY = gql`\n query HealthyBowlSupplierMessages($supplierId: ID!, $context: ContextInput!) {\n healthyBowlSupplierMessages(supplierId: $supplierId, context: $context) {\n ${MESSAGE_FIELDS}\n }\n }\n`;\n\nconst SEND_SUPPLIER_MESSAGE = gql`\n mutation SendHealthyBowlSupplierMessage($input: SendHealthyBowlSupplierMessageInput!) {\n sendHealthyBowlSupplierMessage(input: $input) {\n ${MESSAGE_FIELDS}\n }\n }\n`;\n\ninterface SupplierMessagesQueryData {\n healthyBowlSupplierMessages: SupplierMessage[];\n}\n\n/**\n * Loads (and lets you send to) the conversation thread for a single supplier. Pass\n * `null` for `supplierId` to keep the hook dormant (e.g. while the thread modal is\n * closed) — the query is skipped and `sendMessage` is a no-op. Sending refetches the\n * thread so the new message appears without hand-managing the cache.\n */\nexport function useSupplierMessages(supplierId: string | null) {\n const { workspaceId } = useHealthyBowl();\n const context = { workspaceId };\n\n const { data, loading, error, refetch } = useQuery<SupplierMessagesQueryData>(SUPPLIER_MESSAGES_QUERY, {\n variables: { supplierId: supplierId ?? '', context },\n skip: !workspaceId || !supplierId,\n fetchPolicy: 'cache-and-network',\n notifyOnNetworkStatusChange: true,\n });\n\n const [sendMutation, { loading: sending }] = useMutation(SEND_SUPPLIER_MESSAGE);\n\n const sendMessage = useCallback(\n async (body: string) => {\n const trimmed = body.trim();\n if (!supplierId || !trimmed) return;\n const res = await sendMutation({ variables: { input: { supplierId, body: trimmed, context } } });\n // ★ The shared Apollo client runs `errorPolicy: 'all'`, so a server-side\n // failure does NOT reject — it comes back in-band as `res.errors`. Without\n // this check `sendMessage` resolved on a failed send, the composer cleared\n // the draft, and the refetch returned an empty thread: the message simply\n // vanished with no error anywhere on screen. The modal meanwhile promises\n // \"Messages are saved and persist across visits.\"\n //\n // SuppliersPage already renders a `sendError` line and keeps the draft on\n // failure — it just never fired, because nothing ever threw.\n if (res.error) {\n throw new Error(res.error.message || 'Could not send your message. Please try again.');\n }\n await refetch();\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [sendMutation, refetch, supplierId, workspaceId]\n );\n\n return {\n messages: data?.healthyBowlSupplierMessages ?? [],\n loading,\n sending,\n error,\n refetch,\n sendMessage,\n };\n}\n"],"mappings":";;;;;AA2BA,IAAM,IAAiB,2FAUjB,IAA0B,CAAG;;;QAG3B,EAAe;;;GAKjB,IAAwB,CAAG;;;QAGzB,EAAe;;;;AAevB,SAAgB,EAAoB,GAA2B;CAC7D,IAAM,EAAE,mBAAgB,GAAgB,EAClC,IAAU,EAAE,gBAAa,EAEzB,EAAE,SAAM,YAAS,UAAO,eAAY,EAAoC,GAAyB;EACrG,WAAW;GAAE,YAAY,KAAc;GAAI;GAAS;EACpD,MAAM,CAAC,KAAe,CAAC;EACvB,aAAa;EACb,6BAA6B;EAC9B,CAAC,EAEI,CAAC,GAAc,EAAE,SAAS,OAAa,EAAY,EAAsB,EAEzE,IAAc,EAClB,OAAO,MAAiB;EACtB,IAAM,IAAU,EAAK,MAAM;AAC3B,MAAI,CAAC,KAAc,CAAC,EAAS;EAC7B,IAAM,IAAM,MAAM,EAAa,EAAE,WAAW,EAAE,OAAO;GAAE;GAAY,MAAM;GAAS;GAAS,EAAE,EAAE,CAAC;AAUhG,MAAI,EAAI,MACN,OAAU,MAAM,EAAI,MAAM,WAAW,iDAAiD;AAExF,QAAM,GAAS;IAGjB;EAAC;EAAc;EAAS;EAAY;EAAY,CACjD;AAED,QAAO;EACL,UAAU,GAAM,+BAA+B,EAAE;EACjD;EACA;EACA;EACA;EACA;EACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/microfe-healthybowl",
3
- "version": "2026.816.2",
3
+ "version": "2026.816.3",
4
4
  "description": "Burdenoff HealthyBowl Microfrontend - Comprehensive organic farming and agro-foods management platform",
5
5
  "type": "module",
6
6
  "files": [