@burdenoff/microfe-healthybowl 2026.1013.2 → 2026.1015.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.
@@ -67,7 +67,7 @@ var o = "00000000-0000-0000-0000-000000000001", s = "\n status\n blocked\n en
67
67
  groups { ${c} }
68
68
  }
69
69
  }
70
- `, h = "\n animalId tagNumber name type breed gender dateOfBirth generation relation archived childAnimalId\n", g = r`
70
+ `, h = "\n animalId tagNumber name type breed gender dateOfBirth generation relation archived childAnimalId\n childAnimalIds\n", g = r`
71
71
  query HealthyBowlAnimalPedigree($context: ContextInput!, $animalId: ID!, $ancestorDepth: Int, $offspringDepth: Int) {
72
72
  healthyBowlAnimalPedigree(
73
73
  context: $context
@@ -17,8 +17,8 @@ import { useToast as oe } from "../../hooks/useToast.js";
17
17
  import "../../components/index.js";
18
18
  import { useHealthyBowlData as se } from "../../hooks/useHealthyBowlData.js";
19
19
  import { BED_GEOMETRY_NOTICE as ce, BED_GEOMETRY_NOTICE_SHORT as le, GROW_GEOMETRY_PROMPT as ue, capacityModelFor as d, growLocationTypeLabel as f, usesBedGeometry as p } from "../../utils/growLocationType.js";
20
- import { DEFAULT_BED_WIDTH_M as m, DEFAULT_CROP_SPACING_PRESET as de, DEFAULT_PATH_WIDTH_M as fe, estimateGrowCapacity as pe, estimatePlantingCapacity as me, getCropSpacingPreset as h } from "../../utils/plantingCapacity.js";
21
- import { computeSeedRate as he } from "../../utils/seedRate.js";
20
+ import { DEFAULT_BED_WIDTH_M as m, DEFAULT_CROP_SPACING_PRESET as de, DEFAULT_PATH_WIDTH_M as fe, estimateGrowCapacity as pe, estimatePlantingCapacitySafely as me, getCropSpacingPreset as h } from "../../utils/plantingCapacity.js";
21
+ import { computeSeedRateSafely as he } from "../../utils/seedRate.js";
22
22
  import { cropMatchesField as g } from "./planningEdit.js";
23
23
  import { useEffect as ge, useMemo as _, useRef as _e, useState as v } from "react";
24
24
  import { useI18n as ve } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
@@ -72,7 +72,7 @@ var je = (e) => {
72
72
  pathWidthM: fe,
73
73
  plantSpacingCm: n.plantSpacingCm,
74
74
  rowSpacingCm: n.rowSpacingCm
75
- });
75
+ }).estimate;
76
76
  }, ze = (e, t) => {
77
77
  if (!t) return null;
78
78
  let n = h(e);
@@ -99,7 +99,10 @@ var je = (e) => {
99
99
  row: !1
100
100
  }), xt = () => {
101
101
  Qe(""), $e(""), tt("kharif"), rt("low"), at(""), st(""), lt(""), dt("");
102
- }, { crop: St } = o(ft), V = _(() => t.find((e) => e.id === L) ?? null, [L, t]), H = _(() => h(St), [St]), U = p(V?.type), W = _(() => !V || !p(V.type) ? null : me({
102
+ }, { crop: St } = o(ft), V = _(() => t.find((e) => e.id === L) ?? null, [L, t]), H = _(() => h(St), [St]), U = p(V?.type), { estimate: W, error: Ct } = _(() => !V || !p(V.type) ? {
103
+ estimate: null,
104
+ error: null
105
+ } : me({
103
106
  fieldArea: V.area,
104
107
  fieldUnit: V.unit,
105
108
  bedWidthM: A(_t, m),
@@ -126,7 +129,7 @@ var je = (e) => {
126
129
  R,
127
130
  z,
128
131
  H
129
- ]), K = o(Ze, { skip: !Xe }), q = K.crop, J = te(q, { skip: !Xe }), Y = J.entry, X = _(() => t.find((e) => e.id === I) ?? null, [t, I]), Ct = p(X?.type), Z = _(() => {
132
+ ]), K = o(Ze, { skip: !Xe }), q = K.crop, J = te(q, { skip: !Xe }), Y = J.entry, X = _(() => t.find((e) => e.id === I) ?? null, [t, I]), wt = p(X?.type), Z = _(() => {
130
133
  if (!q || !X || !p(X.type)) return null;
131
134
  let e = h(q);
132
135
  return me({
@@ -136,7 +139,7 @@ var je = (e) => {
136
139
  pathWidthM: fe,
137
140
  plantSpacingCm: e.plantSpacingCm,
138
141
  rowSpacingCm: e.rowSpacingCm
139
- });
142
+ }).estimate;
140
143
  }, [q, X]), Q = _(() => {
141
144
  if (!q || !X) return null;
142
145
  let e = h(q);
@@ -148,13 +151,13 @@ var je = (e) => {
148
151
  plantSpacingCm: e.plantSpacingCm,
149
152
  rowSpacingCm: e.rowSpacingCm
150
153
  });
151
- }, [q, X]), wt = _(() => Z ? Z.totalPlants : Q ? Q.totalPlants : null, [Z, Q]), $ = _(() => wt == null || Q && !Q.usesSeed ? null : he({
152
- plantsNeeded: wt,
154
+ }, [q, X]), Tt = _(() => Z ? Z.totalPlants : Q ? Q.totalPlants : null, [Z, Q]), $ = _(() => Tt == null || Q && !Q.usesSeed ? null : he({
155
+ plantsNeeded: Tt,
153
156
  seedsPerGram: Y?.seedsPerGram ?? null,
154
157
  germinationRate: Y?.germinationRate ?? null,
155
158
  seedsPerCell: Y?.seedsPerCell ?? null
156
- }), [
157
- wt,
159
+ }).seedRate, [
160
+ Tt,
158
161
  Q,
159
162
  Y
160
163
  ]);
@@ -169,13 +172,13 @@ var je = (e) => {
169
172
  ]), ge(() => {
170
173
  L || t.length === 0 || mt(t[0].id);
171
174
  }, [L, t]);
172
- let Tt = e.filter((e) => {
175
+ let Et = e.filter((e) => {
173
176
  let t = (e.cropName ?? "").toLowerCase().includes(We.toLowerCase()) || (e.fieldName ?? "").toLowerCase().includes(We.toLowerCase()), n = Ke === "all" || e.status === Ke, r = Je === "all" || e.season === Je;
174
177
  return t && n && r;
175
- }), Et = e.length, Dt = e.reduce((e, t) => e + t.expectedYield, 0), Ot = e.filter((e) => e.status === "active" || e.status === "approved").length, kt = [...new Set(e.map((e) => e.season))], At = [...new Set(e.map((e) => e.status))], jt = e.reduce((e, n) => {
178
+ }), Dt = e.length, Ot = e.reduce((e, t) => e + t.expectedYield, 0), kt = e.filter((e) => e.status === "active" || e.status === "approved").length, At = [...new Set(e.map((e) => e.season))], jt = [...new Set(e.map((e) => e.status))], Mt = e.reduce((e, n) => {
176
179
  let r = Pe(n, t);
177
180
  return e + (r ? r.area : 0);
178
- }, 0), Mt = g.map((n) => {
181
+ }, 0), Nt = g.map((n) => {
179
182
  let r = e.filter((e) => Fe(e, n)), i = k(n, t);
180
183
  return {
181
184
  crop: n,
@@ -186,18 +189,18 @@ var je = (e) => {
186
189
  capacityNotApplicableFor: i && !p(i.type) && d(i.type) === "NONE" ? i : null,
187
190
  awaitingGeometryFor: i && !p(i.type) && d(i.type) !== "NONE" && ze(n, i) === null ? i : null
188
191
  };
189
- }), Nt = Mt.filter((e) => e.plans.length > 0).length, Pt = (e, n) => {
192
+ }), Pt = Nt.filter((e) => e.plans.length > 0).length, Ft = (e, n) => {
190
193
  if (pt(e), !n) return;
191
194
  let r = h(n), i = k(n, t);
192
195
  B.current = {
193
196
  plant: !1,
194
197
  row: !1
195
198
  }, ht(String(r.plantSpacingCm)), gt(String(r.rowSpacingCm)), i && mt(i.id);
196
- }, Ft = (e, n) => {
199
+ }, It = (e, n) => {
197
200
  if (Qe(e), !n) return;
198
201
  let r = k(n, t);
199
202
  tt(n.season), r && $e(r.id);
200
- }, It = (e) => {
203
+ }, Lt = (e) => {
201
204
  let n = k(e, t);
202
205
  Qe(e.id), $e(n?.id ?? ""), tt(e.season), at(e.plantingDate || ""), st(e.expectedHarvestDate || ""), lt(e.yieldEstimate ? String(e.yieldEstimate) : ""), dt(""), F(!0);
203
206
  };
@@ -224,24 +227,24 @@ var je = (e) => {
224
227
  /* @__PURE__ */ y(a, {
225
228
  hero: !0,
226
229
  label: D("healthybowl.crops.planning.stats.loadedPlans", "Loaded Plans"),
227
- value: Et,
230
+ value: Dt,
228
231
  icon: /* @__PURE__ */ y(Se, { className: "h-5 w-5" })
229
232
  }),
230
233
  /* @__PURE__ */ y(a, {
231
234
  label: D("healthybowl.crops.planning.stats.loadedPlannedArea", "Area of Loaded Plans"),
232
- value: jt,
235
+ value: Mt,
233
236
  unit: "acres",
234
237
  icon: /* @__PURE__ */ y(Ce, { className: "h-5 w-5" })
235
238
  }),
236
239
  /* @__PURE__ */ y(a, {
237
240
  label: D("healthybowl.crops.planning.stats.loadedExpectedYield", "Yield of Loaded Plans"),
238
- value: Dt,
241
+ value: Ot,
239
242
  unit: "kg",
240
243
  icon: /* @__PURE__ */ y(De, { className: "h-5 w-5" })
241
244
  }),
242
245
  /* @__PURE__ */ y(a, {
243
246
  label: D("healthybowl.crops.planning.stats.loadedActivePlans", "Active Loaded Plans"),
244
- value: Ot,
247
+ value: kt,
245
248
  icon: /* @__PURE__ */ y(Ee, { className: "h-5 w-5" })
246
249
  })
247
250
  ]
@@ -268,7 +271,7 @@ var je = (e) => {
268
271
  }), /* @__PURE__ */ b(C, { children: [/* @__PURE__ */ y(w, {
269
272
  value: "all",
270
273
  children: D("healthybowl.crops.planning.filters.allStatuses", "All Statuses")
271
- }), At.map((e) => /* @__PURE__ */ y(w, {
274
+ }), jt.map((e) => /* @__PURE__ */ y(w, {
272
275
  value: e,
273
276
  children: (e ?? "").charAt(0).toUpperCase() + (e ?? "").slice(1)
274
277
  }, e))] })]
@@ -282,7 +285,7 @@ var je = (e) => {
282
285
  }), /* @__PURE__ */ b(C, { children: [/* @__PURE__ */ y(w, {
283
286
  value: "all",
284
287
  children: D("healthybowl.crops.planning.filters.allSeasons", "All Seasons")
285
- }), kt.map((e) => /* @__PURE__ */ y(w, {
288
+ }), At.map((e) => /* @__PURE__ */ y(w, {
286
289
  value: e,
287
290
  children: Ne(e, D)
288
291
  }, e))] })]
@@ -314,7 +317,7 @@ var je = (e) => {
314
317
  }), /* @__PURE__ */ y(s, {
315
318
  id: "planner-capacity-crop",
316
319
  value: ft,
317
- onValueChange: Pt,
320
+ onValueChange: Ft,
318
321
  options: g,
319
322
  placeholder: D("healthybowl.crops.planning.capacity.cropPlaceholder", "Select crop"),
320
323
  className: "mt-1"
@@ -412,6 +415,17 @@ var je = (e) => {
412
415
  "data-testid": "bed-geometry-notice",
413
416
  className: "mt-4 rounded-md border border-border-subtle bg-bg-sunken/60 p-3 text-sm text-text-secondary",
414
417
  children: D(ce.key, ce.defaultValue, { type: f(D, V.type) })
418
+ }) : Ct ? /* @__PURE__ */ b("div", {
419
+ role: "alert",
420
+ "data-testid": "planner-capacity-error",
421
+ className: "mt-4 rounded-md border border-border-danger bg-bg-danger-subtle p-3 text-sm text-text-danger",
422
+ children: [/* @__PURE__ */ y("p", {
423
+ className: "font-medium",
424
+ children: D("healthybowl.crops.planning.capacity.invalidGeometry.title", "Could not calculate planting capacity")
425
+ }), /* @__PURE__ */ y("p", {
426
+ className: "mt-1",
427
+ children: D("healthybowl.crops.planning.capacity.invalidGeometry.body", "These planting figures are too large to calculate. Check the spacing, bed width and field area: a misplaced decimal point is the usual cause.")
428
+ })]
415
429
  }) : W ? /* @__PURE__ */ b("div", {
416
430
  "data-testid": "planner-capacity-metrics",
417
431
  className: "mt-4 grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-6",
@@ -460,14 +474,14 @@ var je = (e) => {
460
474
  children: D("healthybowl.crops.planning.coverage.loadedDescription", "Coverage among the currently loaded crops and plans only. Use Crop Management or the searchable crop picker to browse every workspace crop.")
461
475
  })] }), /* @__PURE__ */ y(c, {
462
476
  label: D("healthybowl.crops.planning.coverage.loadedStatus", "{{planned}} / {{total}} loaded crops have a loaded plan", {
463
- planned: Nt,
477
+ planned: Pt,
464
478
  total: g.length
465
479
  }),
466
- variant: Nt === g.length && g.length > 0 ? "success" : "warning"
480
+ variant: Pt === g.length && g.length > 0 ? "success" : "warning"
467
481
  })]
468
482
  }), g.length > 0 ? /* @__PURE__ */ y("div", {
469
483
  className: "grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3",
470
- children: Mt.map(({ crop: e, activePlan: t, plans: n, capacityEstimate: r, capacityNotApplicableFor: i, growCapacityEstimate: a, awaitingGeometryFor: o }) => /* @__PURE__ */ y(Ve, {
484
+ children: Nt.map(({ crop: e, activePlan: t, plans: n, capacityEstimate: r, capacityNotApplicableFor: i, growCapacityEstimate: a, awaitingGeometryFor: o }) => /* @__PURE__ */ y(Ve, {
471
485
  crop: e,
472
486
  plan: t,
473
487
  planCount: n.length,
@@ -475,7 +489,7 @@ var je = (e) => {
475
489
  capacityNotApplicableFor: i,
476
490
  growCapacityEstimate: a,
477
491
  awaitingGeometryFor: o,
478
- onPlan: () => It(e),
492
+ onPlan: () => Lt(e),
479
493
  onViewCrop: () => O(j(`crops/${e.id}`)),
480
494
  onViewPlan: () => t && O(j(`crops/planning/${t.id}`))
481
495
  }, e.id))
@@ -484,9 +498,9 @@ var je = (e) => {
484
498
  children: D("healthybowl.crops.planning.coverage.empty", "No crops available yet. Add crops before planning.")
485
499
  })]
486
500
  }),
487
- Tt.length > 0 ? /* @__PURE__ */ y("div", {
501
+ Et.length > 0 ? /* @__PURE__ */ y("div", {
488
502
  className: "grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3",
489
- children: Tt.map((e) => /* @__PURE__ */ y(He, {
503
+ children: Et.map((e) => /* @__PURE__ */ y(He, {
490
504
  plan: e,
491
505
  onClick: () => O(j(`crops/planning/${e.id}`))
492
506
  }, e.id))
@@ -544,7 +558,7 @@ var je = (e) => {
544
558
  fertilizers: [],
545
559
  priority: nt,
546
560
  weatherRisk: "low",
547
- plantsNeeded: wt ?? void 0,
561
+ plantsNeeded: Tt ?? void 0,
548
562
  seedGrams: $?.seedGrams ?? void 0,
549
563
  seedlingsToRaise: $?.seedlingsToRaise ?? void 0,
550
564
  plantCatalogId: Y?.id
@@ -587,7 +601,7 @@ var je = (e) => {
587
601
  }), /* @__PURE__ */ y(s, {
588
602
  id: "planner-form-crop",
589
603
  value: Ze,
590
- onValueChange: Ft,
604
+ onValueChange: It,
591
605
  options: g,
592
606
  skip: !Xe,
593
607
  placeholder: D("healthybowl.crops.planning.form.fields.cropName.placeholder", "Select crop..."),
@@ -607,7 +621,7 @@ var je = (e) => {
607
621
  children: `${e.name} · ${f(D, e.type)}`
608
622
  }, e.id)) })]
609
623
  })] }),
610
- X && !Ct && d(X.type) === "NONE" && /* @__PURE__ */ y("p", {
624
+ X && !wt && d(X.type) === "NONE" && /* @__PURE__ */ y("p", {
611
625
  "data-testid": "bed-geometry-notice-form",
612
626
  className: "rounded-md border border-border-subtle bg-bg-sunken/60 p-3 text-xs text-text-secondary sm:col-span-2",
613
627
  children: D(le.key, le.defaultValue, { type: f(D, X.type) })