@burdenoff/microfe-healthybowl 2026.810.3 → 2026.810.5

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.
Files changed (27) hide show
  1. package/dist/healthybowl/hooks/useDiseaseWarning.js +1 -1
  2. package/dist/healthybowl/hooks/useDiseaseWarning.js.map +1 -1
  3. package/dist/healthybowl/hooks/useHarvestInventory.js +38 -0
  4. package/dist/healthybowl/hooks/useHarvestInventory.js.map +1 -0
  5. package/dist/healthybowl/hooks/useHealthyBowlData.js +521 -489
  6. package/dist/healthybowl/hooks/useHealthyBowlData.js.map +1 -1
  7. package/dist/healthybowl/hooks/useHealthyBowlSustainability.js +1 -1
  8. package/dist/healthybowl/hooks/useHealthyBowlSustainability.js.map +1 -1
  9. package/dist/healthybowl/hooks/useWeatherIntelligence.js +1 -1
  10. package/dist/healthybowl/hooks/useWeatherIntelligence.js.map +1 -1
  11. package/dist/healthybowl/pages/crops/CropHarvestPage.js +203 -141
  12. package/dist/healthybowl/pages/crops/CropHarvestPage.js.map +1 -1
  13. package/dist/healthybowl/pages/crops/HarvestDetailsPage.js +6 -1
  14. package/dist/healthybowl/pages/crops/HarvestDetailsPage.js.map +1 -1
  15. package/dist/healthybowl/pages/network/ExpertsPage.js +450 -399
  16. package/dist/healthybowl/pages/network/ExpertsPage.js.map +1 -1
  17. package/dist/healthybowl/pages/network/MentorsPage.js +552 -496
  18. package/dist/healthybowl/pages/network/MentorsPage.js.map +1 -1
  19. package/dist/healthybowl/pages/sustainability/CarbonCreditLedgerPage.js +129 -107
  20. package/dist/healthybowl/pages/sustainability/CarbonCreditLedgerPage.js.map +1 -1
  21. package/dist/healthybowl/pages/sustainability/GenerateCreditWizardPage.js +294 -187
  22. package/dist/healthybowl/pages/sustainability/GenerateCreditWizardPage.js.map +1 -1
  23. package/dist/healthybowl/pages/weather/WeatherAlertHistoryPage.js +7 -1
  24. package/dist/healthybowl/pages/weather/WeatherAlertHistoryPage.js.map +1 -1
  25. package/dist/healthybowl/pages/weather/WeatherAlertRulesPage.js +445 -291
  26. package/dist/healthybowl/pages/weather/WeatherAlertRulesPage.js.map +1 -1
  27. package/package.json +1 -1
@@ -3,7 +3,7 @@ import { useCallback as t } from "react";
3
3
  import { gql as n } from "@apollo/client";
4
4
  import { useMutation as r, useQuery as i } from "@apollo/client/react";
5
5
  //#region src/healthybowl/hooks/useDiseaseWarning.ts
6
- var a = "\n id\n name\n alertType\n metric\n operator\n threshold\n unit\n appliesToCrops\n evaluateUsing\n notifyInApp\n advisoryMessage\n status\n workflowKey\n lastRunId\n lastEvaluatedAt\n lastTriggeredAt\n lastOutcome\n", o = n`
6
+ var a = "\n id\n name\n alertType\n metric\n operator\n threshold\n unit\n logicalOperator\n conditions {\n \n id\n ruleId\n metric\n operator\n threshold\n thresholdMax\n unit\n durationHours\n consecutiveDays\n sortOrder\n\n }\n appliesToCrops\n evaluateUsing\n notifyInApp\n advisoryMessage\n status\n workflowKey\n lastRunId\n lastEvaluatedAt\n lastTriggeredAt\n lastOutcome\n", o = n`
7
7
  query HealthyBowlDiseaseWarningRules($context: ContextInput!) {
8
8
  healthyBowlDiseaseWarningRules(context: $context) {
9
9
  ${a}
@@ -1 +1 @@
1
- {"version":3,"file":"useDiseaseWarning.js","names":[],"sources":["../../../src/healthybowl/hooks/useDiseaseWarning.ts"],"sourcesContent":["/**\n * Disease Early-Warning data hook — FluidGrids-backed weather alert rules\n * (roadmap #20, DEWS).\n *\n * Mirrors the raw-gql pattern used by `useIrrigationAutomation` (and Suppliers /\n * Nursery): the offline codegen doesn't type the DiseaseWarningRule operations,\n * so these are hand-written `gql` documents executed directly against the live\n * gateway. Every op carries the workspace `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 FluidGrids-backed early-warning alert rule (frost / storm / heat / disease). */\nexport interface DiseaseWarningRule {\n id: string;\n /** Human-readable rule name. */\n name: string;\n /** Alert category: FROST | STORM | HEAT | DISEASE. */\n alertType: string;\n /** Weather metric evaluated: temp_min | temp_max | humidity | precip | precip_prob | wind. */\n metric: string;\n /** Comparison operator: below | above. */\n operator: string;\n /** Numeric threshold the metric is compared against. */\n threshold: number;\n /** Free-form unit label (°C, %, mm, km/h). */\n unit?: string | null;\n /** Crop names the rule applies to (empty = all crops). */\n appliesToCrops?: string[] | null;\n /** Data source the rule evaluates against: forecast | live. */\n evaluateUsing?: string | null;\n /** When true, fires an in-app notification when the rule triggers. */\n notifyInApp?: boolean | null;\n /** Optional advisory message surfaced to the farmer on trigger. */\n advisoryMessage?: string | null;\n /** Lifecycle status: active / paused. */\n status: string;\n /** FluidGrids workflow key; null until the workflow is provisioned. */\n workflowKey?: string | null;\n /** WorkflowRun id of the most recent run, if any. */\n lastRunId?: string | null;\n /** ISO-8601 timestamp of the last evaluation, if any. */\n lastEvaluatedAt?: string | null;\n /** ISO-8601 timestamp of the last time the rule actually triggered. */\n lastTriggeredAt?: string | null;\n /** Outcome summary of the last evaluation (e.g. triggered / clear). */\n lastOutcome?: string | null;\n}\n\n/** Editable fields for rule create (context is attached from the hook). */\nexport interface CreateDiseaseWarningRuleInput {\n name: string;\n alertType: string;\n metric: string;\n operator: string;\n threshold: number;\n unit?: string | null;\n appliesToCrops?: string[] | null;\n evaluateUsing?: string | null;\n notifyInApp?: boolean | null;\n advisoryMessage?: string | null;\n status?: string | null;\n}\n\n/** Editable fields for rule update (context is attached from the hook). */\nexport interface UpdateDiseaseWarningRuleInput {\n name?: string | null;\n alertType?: string | null;\n metric?: string | null;\n operator?: string | null;\n threshold?: number | null;\n unit?: string | null;\n appliesToCrops?: string[] | null;\n evaluateUsing?: string | null;\n notifyInApp?: boolean | null;\n advisoryMessage?: string | null;\n status?: string | null;\n}\n\nconst DISEASE_WARNING_RULE_FIELDS = `\n id\n name\n alertType\n metric\n operator\n threshold\n unit\n appliesToCrops\n evaluateUsing\n notifyInApp\n advisoryMessage\n status\n workflowKey\n lastRunId\n lastEvaluatedAt\n lastTriggeredAt\n lastOutcome\n`;\n\nconst DISEASE_WARNING_RULES_QUERY = gql`\n query HealthyBowlDiseaseWarningRules($context: ContextInput!) {\n healthyBowlDiseaseWarningRules(context: $context) {\n ${DISEASE_WARNING_RULE_FIELDS}\n }\n }\n`;\n\nconst CREATE_DISEASE_WARNING_RULE = gql`\n mutation CreateHealthyBowlDiseaseWarningRule($input: CreateHealthyBowlDiseaseWarningRuleInput!) {\n createHealthyBowlDiseaseWarningRule(input: $input) {\n ${DISEASE_WARNING_RULE_FIELDS}\n }\n }\n`;\n\nconst UPDATE_DISEASE_WARNING_RULE = gql`\n mutation UpdateHealthyBowlDiseaseWarningRule($input: UpdateHealthyBowlDiseaseWarningRuleInput!) {\n updateHealthyBowlDiseaseWarningRule(input: $input) {\n ${DISEASE_WARNING_RULE_FIELDS}\n }\n }\n`;\n\nconst DELETE_DISEASE_WARNING_RULE = gql`\n mutation DeleteHealthyBowlDiseaseWarningRule($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlDiseaseWarningRule(id: $id, context: $context)\n }\n`;\n\nconst RUN_DISEASE_WARNING_RULE = gql`\n mutation RunHealthyBowlDiseaseWarningRule($id: ID!, $context: ContextInput!) {\n runHealthyBowlDiseaseWarningRule(id: $id, context: $context)\n }\n`;\n\ninterface DiseaseWarningRulesQueryData {\n healthyBowlDiseaseWarningRules: DiseaseWarningRule[];\n}\ninterface RunRuleMutationData {\n runHealthyBowlDiseaseWarningRule: string | null;\n}\n\n/**\n * Loads disease early-warning alert rules for the active workspace and exposes\n * rule CRUD (incl. pause/resume via `status`) plus a `runRule` trigger.\n * Mutations refetch the list so the caller's view stays in sync.\n */\nexport function useDiseaseWarning() {\n const { workspaceId } = useHealthyBowl();\n const context = { workspaceId };\n\n const { data, loading, error, refetch } = useQuery<DiseaseWarningRulesQueryData>(DISEASE_WARNING_RULES_QUERY, {\n variables: { context },\n skip: !workspaceId,\n fetchPolicy: 'cache-and-network',\n notifyOnNetworkStatusChange: true,\n });\n\n const [createRuleMutation] = useMutation(CREATE_DISEASE_WARNING_RULE);\n const [updateRuleMutation] = useMutation(UPDATE_DISEASE_WARNING_RULE);\n const [deleteRuleMutation] = useMutation(DELETE_DISEASE_WARNING_RULE);\n const [runRuleMutation] = useMutation<RunRuleMutationData>(RUN_DISEASE_WARNING_RULE);\n\n const createRule = useCallback(\n async (input: CreateDiseaseWarningRuleInput) => {\n await createRuleMutation({ variables: { input: { ...input, context } } });\n await refetch();\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [createRuleMutation, refetch, workspaceId]\n );\n\n const updateRule = useCallback(\n async (id: string, input: UpdateDiseaseWarningRuleInput) => {\n await updateRuleMutation({ variables: { input: { id, ...input, context } } });\n await refetch();\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [updateRuleMutation, refetch, workspaceId]\n );\n\n const deleteRule = useCallback(\n async (id: string) => {\n await deleteRuleMutation({ variables: { id, context } });\n await refetch();\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [deleteRuleMutation, refetch, workspaceId]\n );\n\n const runRule = useCallback(\n async (id: string): Promise<string | null> => {\n const result = await runRuleMutation({ variables: { id, context } });\n await refetch();\n return result.data?.runHealthyBowlDiseaseWarningRule ?? null;\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [runRuleMutation, refetch, workspaceId]\n );\n\n return {\n rules: data?.healthyBowlDiseaseWarningRules ?? [],\n loading,\n error: error ?? null,\n refetch,\n createRule,\n updateRule,\n deleteRule,\n runRule,\n };\n}\n"],"mappings":";;;;;AAkFA,IAAM,IAA8B,4OAoB9B,IAA8B,CAAG;;;QAG/B,EAA4B;;;GAK9B,IAA8B,CAAG;;;QAG/B,EAA4B;;;GAK9B,IAA8B,CAAG;;;QAG/B,EAA4B;;;GAK9B,IAA8B,CAAG;;;;GAMjC,IAA2B,CAAG;;;;;AAkBpC,SAAgB,IAAoB;CAClC,IAAM,EAAE,mBAAgB,GAAgB,EAClC,IAAU,EAAE,gBAAa,EAEzB,EAAE,SAAM,YAAS,UAAO,eAAY,EAAuC,GAA6B;EAC5G,WAAW,EAAE,YAAS;EACtB,MAAM,CAAC;EACP,aAAa;EACb,6BAA6B;EAC9B,CAAC,EAEI,CAAC,KAAsB,EAAY,EAA4B,EAC/D,CAAC,KAAsB,EAAY,EAA4B,EAC/D,CAAC,KAAsB,EAAY,EAA4B,EAC/D,CAAC,KAAmB,EAAiC,EAAyB,EAE9E,IAAa,EACjB,OAAO,MAAyC;AAE9C,EADA,MAAM,EAAmB,EAAE,WAAW,EAAE,OAAO;GAAE,GAAG;GAAO;GAAS,EAAE,EAAE,CAAC,EACzE,MAAM,GAAS;IAGjB;EAAC;EAAoB;EAAS;EAAY,CAC3C,EAEK,IAAa,EACjB,OAAO,GAAY,MAAyC;AAE1D,EADA,MAAM,EAAmB,EAAE,WAAW,EAAE,OAAO;GAAE;GAAI,GAAG;GAAO;GAAS,EAAE,EAAE,CAAC,EAC7E,MAAM,GAAS;IAGjB;EAAC;EAAoB;EAAS;EAAY,CAC3C,EAEK,IAAa,EACjB,OAAO,MAAe;AAEpB,EADA,MAAM,EAAmB,EAAE,WAAW;GAAE;GAAI;GAAS,EAAE,CAAC,EACxD,MAAM,GAAS;IAGjB;EAAC;EAAoB;EAAS;EAAY,CAC3C,EAEK,IAAU,EACd,OAAO,MAAuC;EAC5C,IAAM,IAAS,MAAM,EAAgB,EAAE,WAAW;GAAE;GAAI;GAAS,EAAE,CAAC;AAEpE,SADA,MAAM,GAAS,EACR,EAAO,MAAM,oCAAoC;IAG1D;EAAC;EAAiB;EAAS;EAAY,CACxC;AAED,QAAO;EACL,OAAO,GAAM,kCAAkC,EAAE;EACjD;EACA,OAAO,KAAS;EAChB;EACA;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"useDiseaseWarning.js","names":[],"sources":["../../../src/healthybowl/hooks/useDiseaseWarning.ts"],"sourcesContent":["/**\n * Disease Early-Warning data hook — FluidGrids-backed weather alert rules\n * (roadmap #20, DEWS).\n *\n * Mirrors the raw-gql pattern used by `useIrrigationAutomation` (and Suppliers /\n * Nursery): the offline codegen doesn't type the DiseaseWarningRule operations,\n * so these are hand-written `gql` documents executed directly against the live\n * gateway. Every op carries the workspace `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 metric + threshold + duration condition within a rule. */\nexport interface DiseaseWarningRuleCondition {\n id?: string | null;\n metric: string;\n operator: 'above' | 'below' | 'between';\n threshold: number;\n thresholdMax?: number | null;\n unit?: string | null;\n durationHours?: number | null;\n consecutiveDays?: number | null;\n sortOrder?: number | null;\n}\n\n/** A FluidGrids-backed early-warning alert rule (frost / storm / heat / disease). */\nexport interface DiseaseWarningRule {\n id: string;\n /** Human-readable rule name. */\n name: string;\n /** Alert category: FROST | STORM | HEAT | DISEASE. */\n alertType: string;\n /** Legacy single-condition metric (kept for backward compatibility). */\n metric: string;\n /** Legacy single-condition operator (kept for backward compatibility). */\n operator: string;\n /** Legacy single-condition threshold (kept for backward compatibility). */\n threshold: number;\n /** Legacy single-condition unit (kept for backward compatibility). */\n unit?: string | null;\n /** How multiple conditions are combined: AND | OR. */\n logicalOperator: string;\n /** Metric/threshold conditions that make up this rule. */\n conditions: DiseaseWarningRuleCondition[];\n /** Crop names the rule applies to (empty = all crops). */\n appliesToCrops?: string[] | null;\n /** Data source the rule evaluates against: forecast | live. */\n evaluateUsing?: string | null;\n /** When true, fires an in-app notification when the rule triggers. */\n notifyInApp?: boolean | null;\n /** Optional advisory message surfaced to the farmer on trigger. */\n advisoryMessage?: string | null;\n /** Lifecycle status: active / paused. */\n status: string;\n /** FluidGrids workflow key; null until the workflow is provisioned. */\n workflowKey?: string | null;\n /** WorkflowRun id of the most recent run, if any. */\n lastRunId?: string | null;\n /** ISO-8601 timestamp of the last evaluation, if any. */\n lastEvaluatedAt?: string | null;\n /** ISO-8601 timestamp of the last time the rule actually triggered. */\n lastTriggeredAt?: string | null;\n /** Outcome summary of the last evaluation (e.g. triggered / clear). */\n lastOutcome?: string | null;\n}\n\n/** Editable fields for a single condition on create/update. */\nexport interface DiseaseWarningRuleConditionInput {\n id?: string | null;\n metric: string;\n operator: 'above' | 'below' | 'between';\n threshold: number;\n thresholdMax?: number | null;\n unit?: string | null;\n durationHours?: number | null;\n consecutiveDays?: number | null;\n sortOrder?: number | null;\n}\n\n/** Editable fields for rule create (context is attached from the hook). */\nexport interface CreateDiseaseWarningRuleInput {\n name: string;\n alertType: string;\n logicalOperator: 'AND' | 'OR';\n conditions: DiseaseWarningRuleConditionInput[];\n unit?: string | null;\n appliesToCrops?: string[] | null;\n evaluateUsing?: string | null;\n notifyInApp?: boolean | null;\n advisoryMessage?: string | null;\n status?: string | null;\n}\n\n/** Editable fields for rule update (context is attached from the hook). */\nexport interface UpdateDiseaseWarningRuleInput {\n name?: string | null;\n alertType?: string | null;\n logicalOperator: 'AND' | 'OR';\n conditions: DiseaseWarningRuleConditionInput[];\n unit?: string | null;\n appliesToCrops?: string[] | null;\n evaluateUsing?: string | null;\n notifyInApp?: boolean | null;\n advisoryMessage?: string | null;\n status?: string | null;\n}\n\nconst DISEASE_WARNING_RULE_CONDITION_FIELDS = `\n id\n ruleId\n metric\n operator\n threshold\n thresholdMax\n unit\n durationHours\n consecutiveDays\n sortOrder\n`;\n\nconst DISEASE_WARNING_RULE_FIELDS = `\n id\n name\n alertType\n metric\n operator\n threshold\n unit\n logicalOperator\n conditions {\n ${DISEASE_WARNING_RULE_CONDITION_FIELDS}\n }\n appliesToCrops\n evaluateUsing\n notifyInApp\n advisoryMessage\n status\n workflowKey\n lastRunId\n lastEvaluatedAt\n lastTriggeredAt\n lastOutcome\n`;\n\nconst DISEASE_WARNING_RULES_QUERY = gql`\n query HealthyBowlDiseaseWarningRules($context: ContextInput!) {\n healthyBowlDiseaseWarningRules(context: $context) {\n ${DISEASE_WARNING_RULE_FIELDS}\n }\n }\n`;\n\nconst CREATE_DISEASE_WARNING_RULE = gql`\n mutation CreateHealthyBowlDiseaseWarningRule($input: CreateHealthyBowlDiseaseWarningRuleInput!) {\n createHealthyBowlDiseaseWarningRule(input: $input) {\n ${DISEASE_WARNING_RULE_FIELDS}\n }\n }\n`;\n\nconst UPDATE_DISEASE_WARNING_RULE = gql`\n mutation UpdateHealthyBowlDiseaseWarningRule($input: UpdateHealthyBowlDiseaseWarningRuleInput!) {\n updateHealthyBowlDiseaseWarningRule(input: $input) {\n ${DISEASE_WARNING_RULE_FIELDS}\n }\n }\n`;\n\nconst DELETE_DISEASE_WARNING_RULE = gql`\n mutation DeleteHealthyBowlDiseaseWarningRule($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlDiseaseWarningRule(id: $id, context: $context)\n }\n`;\n\nconst RUN_DISEASE_WARNING_RULE = gql`\n mutation RunHealthyBowlDiseaseWarningRule($id: ID!, $context: ContextInput!) {\n runHealthyBowlDiseaseWarningRule(id: $id, context: $context)\n }\n`;\n\ninterface DiseaseWarningRulesQueryData {\n healthyBowlDiseaseWarningRules: DiseaseWarningRule[];\n}\ninterface RunRuleMutationData {\n runHealthyBowlDiseaseWarningRule: string | null;\n}\n\n/**\n * Loads disease early-warning alert rules for the active workspace and exposes\n * rule CRUD (incl. pause/resume via `status`) plus a `runRule` trigger.\n * Mutations refetch the list so the caller's view stays in sync.\n */\nexport function useDiseaseWarning() {\n const { workspaceId } = useHealthyBowl();\n const context = { workspaceId };\n\n const { data, loading, error, refetch } = useQuery<DiseaseWarningRulesQueryData>(DISEASE_WARNING_RULES_QUERY, {\n variables: { context },\n skip: !workspaceId,\n fetchPolicy: 'cache-and-network',\n notifyOnNetworkStatusChange: true,\n });\n\n const [createRuleMutation] = useMutation(CREATE_DISEASE_WARNING_RULE);\n const [updateRuleMutation] = useMutation(UPDATE_DISEASE_WARNING_RULE);\n const [deleteRuleMutation] = useMutation(DELETE_DISEASE_WARNING_RULE);\n const [runRuleMutation] = useMutation<RunRuleMutationData>(RUN_DISEASE_WARNING_RULE);\n\n const createRule = useCallback(\n async (input: CreateDiseaseWarningRuleInput) => {\n await createRuleMutation({ variables: { input: { ...input, context } } });\n await refetch();\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [createRuleMutation, refetch, workspaceId]\n );\n\n const updateRule = useCallback(\n async (id: string, input: UpdateDiseaseWarningRuleInput) => {\n await updateRuleMutation({ variables: { input: { id, ...input, context } } });\n await refetch();\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [updateRuleMutation, refetch, workspaceId]\n );\n\n const deleteRule = useCallback(\n async (id: string) => {\n await deleteRuleMutation({ variables: { id, context } });\n await refetch();\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [deleteRuleMutation, refetch, workspaceId]\n );\n\n const runRule = useCallback(\n async (id: string): Promise<string | null> => {\n const result = await runRuleMutation({ variables: { id, context } });\n await refetch();\n return result.data?.runHealthyBowlDiseaseWarningRule ?? null;\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [runRuleMutation, refetch, workspaceId]\n );\n\n return {\n rules: data?.healthyBowlDiseaseWarningRules ?? [],\n loading,\n error: error ?? null,\n refetch,\n createRule,\n updateRule,\n deleteRule,\n runRule,\n };\n}\n"],"mappings":";;;;;AA2HA,IAAM,IAA8B,wZAwB9B,IAA8B,CAAG;;;QAG/B,EAA4B;;;GAK9B,IAA8B,CAAG;;;QAG/B,EAA4B;;;GAK9B,IAA8B,CAAG;;;QAG/B,EAA4B;;;GAK9B,IAA8B,CAAG;;;;GAMjC,IAA2B,CAAG;;;;;AAkBpC,SAAgB,IAAoB;CAClC,IAAM,EAAE,mBAAgB,GAAgB,EAClC,IAAU,EAAE,gBAAa,EAEzB,EAAE,SAAM,YAAS,UAAO,eAAY,EAAuC,GAA6B;EAC5G,WAAW,EAAE,YAAS;EACtB,MAAM,CAAC;EACP,aAAa;EACb,6BAA6B;EAC9B,CAAC,EAEI,CAAC,KAAsB,EAAY,EAA4B,EAC/D,CAAC,KAAsB,EAAY,EAA4B,EAC/D,CAAC,KAAsB,EAAY,EAA4B,EAC/D,CAAC,KAAmB,EAAiC,EAAyB,EAE9E,IAAa,EACjB,OAAO,MAAyC;AAE9C,EADA,MAAM,EAAmB,EAAE,WAAW,EAAE,OAAO;GAAE,GAAG;GAAO;GAAS,EAAE,EAAE,CAAC,EACzE,MAAM,GAAS;IAGjB;EAAC;EAAoB;EAAS;EAAY,CAC3C,EAEK,IAAa,EACjB,OAAO,GAAY,MAAyC;AAE1D,EADA,MAAM,EAAmB,EAAE,WAAW,EAAE,OAAO;GAAE;GAAI,GAAG;GAAO;GAAS,EAAE,EAAE,CAAC,EAC7E,MAAM,GAAS;IAGjB;EAAC;EAAoB;EAAS;EAAY,CAC3C,EAEK,IAAa,EACjB,OAAO,MAAe;AAEpB,EADA,MAAM,EAAmB,EAAE,WAAW;GAAE;GAAI;GAAS,EAAE,CAAC,EACxD,MAAM,GAAS;IAGjB;EAAC;EAAoB;EAAS;EAAY,CAC3C,EAEK,IAAU,EACd,OAAO,MAAuC;EAC5C,IAAM,IAAS,MAAM,EAAgB,EAAE,WAAW;GAAE;GAAI;GAAS,EAAE,CAAC;AAEpE,SADA,MAAM,GAAS,EACR,EAAO,MAAM,oCAAoC;IAG1D;EAAC;EAAiB;EAAS;EAAY,CACxC;AAED,QAAO;EACL,OAAO,GAAM,kCAAkC,EAAE;EACjD;EACA,OAAO,KAAS;EAChB;EACA;EACA;EACA;EACA;EACD"}
@@ -0,0 +1,38 @@
1
+ import { useHealthyBowl as e } from "../context/HealthyBowlContext.js";
2
+ import { useCallback as t, useState as n } from "react";
3
+ import { gql as r } from "@apollo/client";
4
+ import { useMutation as i } from "@apollo/client/react";
5
+ //#region src/healthybowl/hooks/useHarvestInventory.ts
6
+ var a = r`
7
+ mutation HealthyBowlLinkHarvestToInventory($input: LinkHarvestToInventoryInput!) {
8
+ linkHealthyBowlHarvestToInventory(input: $input) {
9
+ id
10
+ productId
11
+ }
12
+ }
13
+ `;
14
+ function o() {
15
+ let { workspaceId: r } = e(), o = { workspaceId: r }, [s, c] = n(() => /* @__PURE__ */ new Set()), [l] = i(a);
16
+ return {
17
+ linkToInventory: t(async (e, t) => {
18
+ c((t) => new Set(t).add(e));
19
+ try {
20
+ return (await l({ variables: { input: {
21
+ id: e,
22
+ productCategory: t,
23
+ context: o
24
+ } } })).data?.linkHealthyBowlHarvestToInventory?.productId ?? null;
25
+ } finally {
26
+ c((t) => {
27
+ let n = new Set(t);
28
+ return n.delete(e), n;
29
+ });
30
+ }
31
+ }, [l, r]),
32
+ isLinking: t((e) => s.has(e), [s])
33
+ };
34
+ }
35
+ //#endregion
36
+ export { o as useHarvestInventory };
37
+
38
+ //# sourceMappingURL=useHarvestInventory.js.map
@@ -0,0 +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 * Mirrors the raw-`gql` pattern used by {@link usePlanExecution} — the offline codegen doesn't type\n * these operations, so they're hand-written documents executed directly against the live gateway.\n * @module healthybowl\n */\nimport { useCallback, useState } from 'react';\nimport { gql } from '@apollo/client';\nimport { useMutation } from '@apollo/client/react';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\n\nconst LINK_HARVEST_TO_INVENTORY = gql`\n mutation HealthyBowlLinkHarvestToInventory($input: LinkHarvestToInventoryInput!) {\n linkHealthyBowlHarvestToInventory(input: $input) {\n id\n productId\n }\n }\n`;\n\ninterface LinkResult {\n linkHealthyBowlHarvestToInventory?: { id?: string; productId?: string | null };\n}\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<LinkResult>(LINK_HARVEST_TO_INVENTORY);\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":";;;;;AAgBA,IAAM,IAA4B,CAAG;;;;;;;;AAsBrC,SAAgB,IAAsB;CACpC,IAAM,EAAE,mBAAgB,GAAgB,EAClC,IAAU,EAAE,gBAAa,EACzB,CAAC,GAAY,KAAiB,wBAAoC,IAAI,KAAK,CAAC,EAC5E,CAAC,KAAgB,EAAwB,EAA0B;AAwBzE,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"}