@burdenoff/microfe-healthybowl 2026.813.29 → 2026.813.30
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHarvestInventory.js","names":[],"sources":["../../../src/healthybowl/hooks/useHarvestInventory.ts"],"sourcesContent":["/**\n * Harvest → inventory linkage (BOFF-6095).\n *\n * `addToInventory` is a create-time-only flag and the main harvest form never sent it, so produce\n * recorded through the primary route was stranded outside inventory permanently. This hook is the\n * way back in: it links an already-recorded harvest to sellable stock.\n *\n *
|
|
1
|
+
{"version":3,"file":"useHarvestInventory.js","names":[],"sources":["../../../src/healthybowl/hooks/useHarvestInventory.ts"],"sourcesContent":["/**\n * Harvest → inventory linkage (BOFF-6095).\n *\n * `addToInventory` is a create-time-only flag and the main harvest form never sent it, so produce\n * recorded through the primary route was stranded outside inventory permanently. This hook is the\n * way back in: it links an already-recorded harvest to sellable stock.\n *\n * Uses the generated document and types (BOFF-6307). This previously carried a hand-written `gql`\n * document because the committed supergraph snapshot did not yet contain\n * `linkHealthyBowlHarvestToInventory`, so codegen could not type it however often it ran.\n * @module healthybowl\n */\nimport { useCallback, useState } from 'react';\nimport { useMutation } from '@apollo/client/react';\nimport {\n HealthyBowlLinkHarvestToInventoryDocument,\n type HealthyBowlLinkHarvestToInventoryMutation,\n type HealthyBowlLinkHarvestToInventoryMutationVariables,\n} from '../../generated/wspace-operations';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\n\n/**\n * Exposes a single action: bank a recorded harvest into inventory.\n *\n * `isLinking(id)` reports whether that specific harvest is in flight, so a list disables only the\n * row being linked. This tracks a SET rather than one id: with a single id, linking card A and then\n * card B meant A's completion cleared the flag while B was still in flight, re-enabling B's button\n * mid-request. The server side is idempotent by `HarvestRecord.productId` and its stamp is a\n * compare-and-set, so a stray second click could not double-bank — but the UI should not invite one.\n */\nexport function useHarvestInventory() {\n const { workspaceId } = useHealthyBowl();\n const context = { workspaceId };\n const [linkingIds, setLinkingIds] = useState<ReadonlySet<string>>(() => new Set());\n const [linkMutation] = useMutation<\n HealthyBowlLinkHarvestToInventoryMutation,\n HealthyBowlLinkHarvestToInventoryMutationVariables\n >(HealthyBowlLinkHarvestToInventoryDocument);\n\n const linkToInventory = useCallback(\n async (harvestId: string, productCategory?: string) => {\n setLinkingIds((prev) => new Set(prev).add(harvestId));\n try {\n const res = await linkMutation({\n variables: { input: { id: harvestId, productCategory, context } },\n });\n return res.data?.linkHealthyBowlHarvestToInventory?.productId ?? null;\n } finally {\n setLinkingIds((prev) => {\n const next = new Set(prev);\n next.delete(harvestId);\n return next;\n });\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [linkMutation, workspaceId]\n );\n\n const isLinking = useCallback((harvestId: string) => linkingIds.has(harvestId), [linkingIds]);\n\n return { linkToInventory, isLinking };\n}\n"],"mappings":";;;;;AA8BA,SAAgB,IAAsB;CACpC,IAAM,EAAE,mBAAgB,GAAgB,EAClC,IAAU,EAAE,gBAAa,EACzB,CAAC,GAAY,KAAiB,wBAAoC,IAAI,KAAK,CAAC,EAC5E,CAAC,KAAgB,EAGrB,EAA0C;AAwB5C,QAAO;EAAE,iBAtBe,EACtB,OAAO,GAAmB,MAA6B;AACrD,MAAe,MAAS,IAAI,IAAI,EAAK,CAAC,IAAI,EAAU,CAAC;AACrD,OAAI;AAIF,YAHY,MAAM,EAAa,EAC7B,WAAW,EAAE,OAAO;KAAE,IAAI;KAAW;KAAiB;KAAS,EAAE,EAClE,CAAC,EACS,MAAM,mCAAmC,aAAa;aACzD;AACR,OAAe,MAAS;KACtB,IAAM,IAAO,IAAI,IAAI,EAAK;AAE1B,YADA,EAAK,OAAO,EAAU,EACf;MACP;;KAIN,CAAC,GAAc,EAAY,CAC5B;EAIyB,WAFR,GAAa,MAAsB,EAAW,IAAI,EAAU,EAAE,CAAC,EAAW,CAAC;EAExD"}
|
package/package.json
CHANGED