@burdenoff/microfe-healthybowl 2026.1005.2 → 2026.1007.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.
- package/dist/healthybowl/components/BedLayoutGrid.js +128 -115
- package/dist/healthybowl/components/BedLayoutGrid.js.map +1 -1
- package/dist/healthybowl/components/CropPicker.js +37 -0
- package/dist/healthybowl/components/CropPicker.js.map +1 -0
- package/dist/healthybowl/components/DataTable.js +125 -108
- package/dist/healthybowl/components/DataTable.js.map +1 -1
- package/dist/healthybowl/components/FilterBar.js +9 -6
- package/dist/healthybowl/components/FilterBar.js.map +1 -1
- package/dist/healthybowl/components/PlantCatalogPicker.js +32 -0
- package/dist/healthybowl/components/PlantCatalogPicker.js.map +1 -0
- package/dist/healthybowl/components/WorkspaceRecordPicker.js +164 -0
- package/dist/healthybowl/components/WorkspaceRecordPicker.js.map +1 -0
- package/dist/healthybowl/components/index.js +3 -1
- package/dist/healthybowl/hooks/useCropPage.js +71 -0
- package/dist/healthybowl/hooks/useCropPage.js.map +1 -0
- package/dist/healthybowl/hooks/usePlantCatalog.js +133 -44
- package/dist/healthybowl/hooks/usePlantCatalog.js.map +1 -1
- package/dist/healthybowl/hooks/usePlantingEstimate.js +6 -6
- package/dist/healthybowl/hooks/usePlantingEstimate.js.map +1 -1
- package/dist/healthybowl/hooks/useWorkspaceRead.js +46 -0
- package/dist/healthybowl/hooks/useWorkspaceRead.js.map +1 -0
- package/dist/healthybowl/pages/analytics/ReportsPage.js +8 -8
- package/dist/healthybowl/pages/catalog/PlantCatalogPage.js +266 -192
- package/dist/healthybowl/pages/catalog/PlantCatalogPage.js.map +1 -1
- package/dist/healthybowl/pages/catalog/WorkspaceBrowseFilters.js +58 -0
- package/dist/healthybowl/pages/catalog/WorkspaceBrowseFilters.js.map +1 -0
- package/dist/healthybowl/pages/catalog/browsePagination.js +24 -0
- package/dist/healthybowl/pages/catalog/browsePagination.js.map +1 -0
- package/dist/healthybowl/pages/compliance/ComplianceDocumentsPage.js +6 -6
- package/dist/healthybowl/pages/crops/CropDetailsPage.js +340 -348
- package/dist/healthybowl/pages/crops/CropDetailsPage.js.map +1 -1
- package/dist/healthybowl/pages/crops/CropPlanningPage.js +468 -434
- package/dist/healthybowl/pages/crops/CropPlanningPage.js.map +1 -1
- package/dist/healthybowl/pages/crops/CropsPage.js +633 -542
- package/dist/healthybowl/pages/crops/CropsPage.js.map +1 -1
- package/dist/healthybowl/pages/crops/FieldDetailsPage.js +875 -800
- package/dist/healthybowl/pages/crops/FieldDetailsPage.js.map +1 -1
- package/dist/healthybowl/pages/crops/PlanningDetailsPage.js +459 -448
- package/dist/healthybowl/pages/crops/PlanningDetailsPage.js.map +1 -1
- package/dist/healthybowl/pages/crops/SuccessionCropLabel.js +21 -0
- package/dist/healthybowl/pages/crops/SuccessionCropLabel.js.map +1 -0
- package/dist/healthybowl/pages/crops/planningEdit.js +30 -0
- package/dist/healthybowl/pages/crops/planningEdit.js.map +1 -0
- package/dist/healthybowl/pages/fields/FieldMapPage.js +989 -941
- package/dist/healthybowl/pages/fields/FieldMapPage.js.map +1 -1
- package/dist/healthybowl/pages/financial/GeneralLedgerPage.js +6 -6
- package/dist/healthybowl/pages/financial/InvoiceManagementPage.js +7 -7
- package/dist/healthybowl/pages/financial/InvoiceManagementPage.js.map +1 -1
- package/dist/healthybowl/pages/financial/TransactionsPage.js +541 -541
- package/dist/healthybowl/pages/financial/TransactionsPage.js.map +1 -1
- package/dist/healthybowl/pages/government-schemes/ApplicationTrackingPage.js +10 -10
- package/dist/healthybowl/pages/government-schemes/CommunicationPage.js +207 -207
- package/dist/healthybowl/pages/government-schemes/CommunicationPage.js.map +1 -1
- package/dist/healthybowl/pages/government-schemes/SchemeAdminPage.js +38 -38
- package/dist/healthybowl/pages/government-schemes/SchemeAdminPage.js.map +1 -1
- package/dist/healthybowl/pages/government-schemes/TrainingProgramsPage.js +15 -15
- package/dist/healthybowl/pages/government-schemes/TrainingProgramsPage.js.map +1 -1
- package/dist/healthybowl/pages/livestock/AnimalRegistryPage.js +4 -4
- package/dist/healthybowl/pages/livestock/BreedingManagementPage.js +4 -4
- package/dist/healthybowl/pages/livestock/FeedManagementPage.js +4 -4
- package/dist/healthybowl/pages/livestock/HealthRecordsPage.js +16 -16
- package/dist/healthybowl/pages/livestock/HealthRecordsPage.js.map +1 -1
- package/dist/healthybowl/pages/livestock/ProductionTrackingPage.js +4 -4
- package/dist/healthybowl/pages/livestock/VaccinationSchedulePage.js +4 -4
- package/dist/healthybowl/pages/market/MarketPricesPage.js +305 -305
- package/dist/healthybowl/pages/market/MarketPricesPage.js.map +1 -1
- package/dist/healthybowl/pages/network/CohortsPage.js +107 -107
- package/dist/healthybowl/pages/network/CohortsPage.js.map +1 -1
- package/dist/healthybowl/pages/network/CommunityPage.js +247 -247
- package/dist/healthybowl/pages/network/CommunityPage.js.map +1 -1
- package/dist/healthybowl/pages/network/EventsPage.js +16 -16
- package/dist/healthybowl/pages/network/EventsPage.js.map +1 -1
- package/dist/healthybowl/pages/network/ExpertsPage.js +470 -470
- package/dist/healthybowl/pages/network/ExpertsPage.js.map +1 -1
- package/dist/healthybowl/pages/network/MentorsPage.js +6 -6
- package/dist/healthybowl/pages/pest-management/PestIssuesPage.js +8 -8
- package/dist/healthybowl/pages/pest-management/TreatmentLibraryPage.js +7 -7
- package/dist/healthybowl/pages/pest-management/TreatmentLibraryPage.js.map +1 -1
- package/dist/healthybowl/pages/production/ProductionBatchesPage.js +7 -7
- package/dist/healthybowl/pages/production/RecipeManagementPage.js +5 -5
- package/dist/healthybowl/pages/production/ValueAddedProductsPage.js +7 -7
- package/dist/healthybowl/pages/soil/SoilTestsPage.js +6 -6
- package/dist/healthybowl/pages/soil/SoilTestsPage.js.map +1 -1
- package/dist/healthybowl/pages/suppliers/SuppliersPage.js +10 -10
- package/dist/healthybowl/pages/sustainability/CarbonCreditLedgerPage.js +6 -6
- package/dist/healthybowl/pages/terrace/PlantingFormModal.js +151 -131
- package/dist/healthybowl/pages/terrace/PlantingFormModal.js.map +1 -1
- package/dist/healthybowl/pages/traceability/BatchTrackingPage.js +6 -6
- package/dist/healthybowl/utils/cropComparison.js +1 -1
- package/dist/healthybowl/utils/cropComparison.js.map +1 -1
- package/dist/healthybowl/utils/cropPicker.js +35 -0
- package/dist/healthybowl/utils/cropPicker.js.map +1 -0
- package/dist/healthybowl/utils/plantingCapacity.js +2 -2
- package/dist/healthybowl/utils/plantingCapacity.js.map +1 -1
- package/dist/healthybowl/utils/seedRate.js +1 -8
- package/dist/healthybowl/utils/seedRate.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { useHealthyBowl as e } from "../context/HealthyBowlContext.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
2
|
+
import { useWorkspaceRead as t } from "../hooks/useWorkspaceRead.js";
|
|
3
|
+
import { useCropDetail as n } from "../hooks/useCropPage.js";
|
|
4
|
+
import { pickerRecordLabel as r } from "../utils/cropPicker.js";
|
|
5
|
+
import { CropPicker as i } from "./CropPicker.js";
|
|
6
|
+
import { useToast as a } from "../hooks/useToast.js";
|
|
7
|
+
import { useId as o, useMemo as s, useState as c } from "react";
|
|
8
|
+
import { useI18n as l } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
9
|
+
import { LayoutGrid as u, Loader2 as d } from "lucide-react";
|
|
10
|
+
import { jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
11
|
+
import { Button as m } from "@burdenoff/fe-libs/ui";
|
|
12
|
+
import { gql as h } from "@apollo/client";
|
|
13
|
+
import { useMutation as g } from "@apollo/client/react";
|
|
10
14
|
//#region src/healthybowl/components/BedLayoutGrid.tsx
|
|
11
|
-
var
|
|
15
|
+
var _ = h`
|
|
12
16
|
query HealthyBowlFieldDetailBeds($context: ContextInput!, $fieldId: ID) {
|
|
13
17
|
healthyBowlBeds(context: $context, fieldId: $fieldId) {
|
|
14
18
|
id
|
|
@@ -21,7 +25,7 @@ var p = u`
|
|
|
21
25
|
status
|
|
22
26
|
}
|
|
23
27
|
}
|
|
24
|
-
`,
|
|
28
|
+
`, v = h`
|
|
25
29
|
mutation UpdateHealthyBowlFieldDetailBed($input: UpdateHealthyBowlBedInput!) {
|
|
26
30
|
updateHealthyBowlBed(input: $input) {
|
|
27
31
|
id
|
|
@@ -31,153 +35,162 @@ var p = u`
|
|
|
31
35
|
}
|
|
32
36
|
}
|
|
33
37
|
`;
|
|
34
|
-
function
|
|
38
|
+
function y(e, t) {
|
|
35
39
|
return e === "planted" || t ? "border-success/50 bg-success/10" : e === "fallow" ? "border-muted/50 bg-muted/10" : "border-warning/50 bg-warning/10";
|
|
36
40
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
var b = "__bed-unassigned__";
|
|
42
|
+
function x({ bed: e, crops: t, loadedCrop: a, saving: s, onAssign: c }) {
|
|
43
|
+
let { t: u } = l(), d = o(), { crop: m, loading: h, error: g } = n(e.cropId, { skip: !!a }), _ = a ?? m, v = u("healthybowl.crops.fieldDetail.beds.recordedCrop", "Recorded crop ({{id}})", { id: e.cropId ?? "" }), x = _ ? r(_) : e.cropId ? h ? u("healthybowl.crops.fieldDetail.beds.recordedLoading", "Recorded crop ({{id}}) — loading…", { id: e.cropId }) : g ? u("healthybowl.crops.fieldDetail.beds.recordedError", "Recorded crop ({{id}}) — details could not be loaded", { id: e.cropId }) : u("healthybowl.crops.fieldDetail.beds.recordedUnavailable", "Recorded crop ({{id}}) — unavailable", { id: e.cropId }) : u("healthybowl.crops.fieldDetail.beds.unassigned", "Unassigned");
|
|
44
|
+
return /* @__PURE__ */ p("article", {
|
|
45
|
+
role: "listitem",
|
|
46
|
+
className: `rounded-lg border p-4 ${y(e.status, !!e.cropId)}`,
|
|
47
|
+
children: [
|
|
48
|
+
/* @__PURE__ */ p("div", {
|
|
49
|
+
className: "flex items-start justify-between gap-2",
|
|
50
|
+
children: [/* @__PURE__ */ f("h3", {
|
|
51
|
+
className: "font-semibold text-text-primary",
|
|
52
|
+
children: e.name
|
|
53
|
+
}), /* @__PURE__ */ f("span", {
|
|
54
|
+
className: "rounded-full bg-bg-surface px-2 py-1 text-xs capitalize text-text-secondary",
|
|
55
|
+
children: e.status ?? "ready to sow"
|
|
56
|
+
})]
|
|
57
|
+
}),
|
|
58
|
+
/* @__PURE__ */ p("dl", {
|
|
59
|
+
className: "mt-3 grid grid-cols-2 gap-2 text-sm",
|
|
60
|
+
children: [
|
|
61
|
+
/* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("dt", {
|
|
62
|
+
className: "text-text-secondary",
|
|
63
|
+
children: u("healthybowl.crops.fieldDetail.beds.crop", "Crop")
|
|
64
|
+
}), /* @__PURE__ */ f("dd", {
|
|
65
|
+
className: "font-medium text-text-primary",
|
|
66
|
+
children: x
|
|
67
|
+
})] }),
|
|
68
|
+
/* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("dt", {
|
|
69
|
+
className: "text-text-secondary",
|
|
70
|
+
children: u("healthybowl.crops.fieldDetail.beds.plants", "Plants")
|
|
71
|
+
}), /* @__PURE__ */ f("dd", {
|
|
72
|
+
className: "font-medium text-text-primary",
|
|
73
|
+
children: e.plantCount ?? "—"
|
|
74
|
+
})] }),
|
|
75
|
+
/* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("dt", {
|
|
76
|
+
className: "text-text-secondary",
|
|
77
|
+
children: u("healthybowl.crops.fieldDetail.beds.area", "Area")
|
|
78
|
+
}), /* @__PURE__ */ p("dd", {
|
|
79
|
+
className: "font-medium text-text-primary",
|
|
80
|
+
children: [
|
|
81
|
+
e.area ?? "—",
|
|
82
|
+
" ",
|
|
83
|
+
e.unit ?? ""
|
|
84
|
+
]
|
|
85
|
+
})] })
|
|
86
|
+
]
|
|
87
|
+
}),
|
|
88
|
+
/* @__PURE__ */ p("div", {
|
|
89
|
+
className: "mt-4",
|
|
90
|
+
children: [/* @__PURE__ */ f("label", {
|
|
91
|
+
htmlFor: d,
|
|
92
|
+
className: "block text-xs font-medium text-text-secondary",
|
|
93
|
+
children: u("healthybowl.crops.fieldDetail.beds.assign", "Assign crop")
|
|
94
|
+
}), /* @__PURE__ */ f(i, {
|
|
95
|
+
id: d,
|
|
96
|
+
value: e.cropId ?? b,
|
|
97
|
+
onValueChange: (t) => void c(e, t === b ? "" : t),
|
|
98
|
+
options: t,
|
|
99
|
+
recordedLabel: v,
|
|
100
|
+
emptyOption: {
|
|
101
|
+
value: b,
|
|
102
|
+
label: u("healthybowl.crops.fieldDetail.beds.unassigned", "Unassigned")
|
|
103
|
+
},
|
|
104
|
+
disabled: s,
|
|
105
|
+
className: "mt-1",
|
|
106
|
+
placeholder: u("healthybowl.crops.fieldDetail.beds.assignTo", "Assign crop to {{name}}", { name: e.name })
|
|
107
|
+
})]
|
|
108
|
+
})
|
|
109
|
+
]
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
function S({ fieldId: n, crops: r }) {
|
|
113
|
+
let { t: i } = l(), { workspaceId: o } = e(), { toast: h } = a(), [y, b] = c(null), { data: S, loading: C, error: w, refetch: T } = t(_, s(() => ({
|
|
114
|
+
context: { workspaceId: o },
|
|
115
|
+
fieldId: n
|
|
116
|
+
}), [o, n]), !n), [E] = g(v), D = S?.healthyBowlBeds ?? [], O = s(() => new Map(r.map((e) => [e.id, e])), [r]), k = async (e, t) => {
|
|
117
|
+
b(e.id);
|
|
46
118
|
try {
|
|
47
119
|
await E({ variables: { input: {
|
|
48
120
|
id: e.id,
|
|
49
121
|
cropId: t || null,
|
|
50
122
|
plantCount: e.plantCount,
|
|
51
|
-
context: { workspaceId:
|
|
52
|
-
} } }), await T(),
|
|
53
|
-
title:
|
|
54
|
-
description:
|
|
123
|
+
context: { workspaceId: o }
|
|
124
|
+
} } }), await T(), h({
|
|
125
|
+
title: i("healthybowl.crops.fieldDetail.beds.saved.title", "Bed updated"),
|
|
126
|
+
description: i("healthybowl.crops.fieldDetail.beds.saved.description", "{{name}} is up to date.", { name: e.name }),
|
|
55
127
|
variant: "success"
|
|
56
128
|
});
|
|
57
129
|
} catch (e) {
|
|
58
|
-
|
|
59
|
-
title:
|
|
130
|
+
h({
|
|
131
|
+
title: i("healthybowl.crops.fieldDetail.beds.failed.title", "Could not update bed"),
|
|
60
132
|
description: String(e),
|
|
61
133
|
variant: "error"
|
|
62
134
|
});
|
|
63
135
|
} finally {
|
|
64
|
-
|
|
136
|
+
b(null);
|
|
65
137
|
}
|
|
66
138
|
};
|
|
67
|
-
return /* @__PURE__ */
|
|
139
|
+
return /* @__PURE__ */ p("section", {
|
|
68
140
|
"aria-labelledby": "healthy-bowl-bed-layout-heading",
|
|
69
141
|
className: "rounded-xl border border-border-seam bg-bg-surface p-6",
|
|
70
|
-
children: [/* @__PURE__ */
|
|
142
|
+
children: [/* @__PURE__ */ p("div", {
|
|
71
143
|
className: "mb-4 flex items-start justify-between gap-4",
|
|
72
|
-
children: [/* @__PURE__ */
|
|
144
|
+
children: [/* @__PURE__ */ p("div", { children: [/* @__PURE__ */ p("div", {
|
|
73
145
|
className: "flex items-center gap-2",
|
|
74
|
-
children: [/* @__PURE__ */
|
|
146
|
+
children: [/* @__PURE__ */ f(u, {
|
|
75
147
|
className: "h-5 w-5 text-action-primary",
|
|
76
148
|
"aria-hidden": "true"
|
|
77
|
-
}), /* @__PURE__ */
|
|
149
|
+
}), /* @__PURE__ */ f("h2", {
|
|
78
150
|
id: "healthy-bowl-bed-layout-heading",
|
|
79
151
|
className: "text-base font-semibold text-text-primary",
|
|
80
|
-
children:
|
|
152
|
+
children: i("healthybowl.crops.fieldDetail.beds.title", "Bed layout")
|
|
81
153
|
})]
|
|
82
|
-
}), /* @__PURE__ */
|
|
154
|
+
}), /* @__PURE__ */ f("p", {
|
|
83
155
|
className: "mt-1 text-sm text-text-secondary",
|
|
84
|
-
children:
|
|
85
|
-
})] }), /* @__PURE__ */
|
|
156
|
+
children: i("healthybowl.crops.fieldDetail.beds.description", "See every saved bed, its crop, status and planting capacity.")
|
|
157
|
+
})] }), /* @__PURE__ */ f(m, {
|
|
86
158
|
variant: "outline",
|
|
87
159
|
size: "sm",
|
|
88
160
|
onClick: () => void T(),
|
|
89
161
|
disabled: C,
|
|
90
|
-
children: C ? /* @__PURE__ */
|
|
162
|
+
children: C ? /* @__PURE__ */ f(d, { className: "h-4 w-4 animate-spin" }) : i("healthybowl.common.refresh", "Refresh")
|
|
91
163
|
})]
|
|
92
|
-
}), C && D.length === 0 ? /* @__PURE__ */
|
|
164
|
+
}), C && D.length === 0 ? /* @__PURE__ */ f("div", {
|
|
93
165
|
className: "py-8 text-center text-sm text-text-secondary",
|
|
94
|
-
children:
|
|
95
|
-
}) : w ? /* @__PURE__ */
|
|
166
|
+
children: i("healthybowl.common.loading", "Loading…")
|
|
167
|
+
}) : w ? /* @__PURE__ */ f("div", {
|
|
96
168
|
className: "rounded-lg border border-error/40 bg-error/10 p-4 text-sm text-error",
|
|
97
|
-
children:
|
|
98
|
-
}) : D.length === 0 ? /* @__PURE__ */
|
|
169
|
+
children: i("healthybowl.crops.fieldDetail.beds.error", "Beds could not be loaded. Try again.")
|
|
170
|
+
}) : D.length === 0 ? /* @__PURE__ */ p("div", {
|
|
99
171
|
className: "rounded-lg border border-dashed border-border-seam p-8 text-center",
|
|
100
|
-
children: [/* @__PURE__ */
|
|
172
|
+
children: [/* @__PURE__ */ f("p", {
|
|
101
173
|
className: "font-medium text-text-primary",
|
|
102
|
-
children:
|
|
103
|
-
}), /* @__PURE__ */
|
|
174
|
+
children: i("healthybowl.crops.fieldDetail.beds.empty.title", "No beds saved yet")
|
|
175
|
+
}), /* @__PURE__ */ f("p", {
|
|
104
176
|
className: "mt-1 text-sm text-text-secondary",
|
|
105
|
-
children:
|
|
177
|
+
children: i("healthybowl.crops.fieldDetail.beds.empty.description", "Generate and save a bed layout from the Field Map page.")
|
|
106
178
|
})]
|
|
107
|
-
}) : /* @__PURE__ */
|
|
179
|
+
}) : /* @__PURE__ */ f("div", {
|
|
108
180
|
className: "grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-3",
|
|
109
181
|
role: "list",
|
|
110
|
-
"aria-label":
|
|
111
|
-
children: D.map((e) => {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
className: "flex items-start justify-between gap-2",
|
|
119
|
-
children: [/* @__PURE__ */ s("h3", {
|
|
120
|
-
className: "font-semibold text-text-primary",
|
|
121
|
-
children: e.name
|
|
122
|
-
}), /* @__PURE__ */ s("span", {
|
|
123
|
-
className: "rounded-full bg-bg-surface px-2 py-1 text-xs capitalize text-text-secondary",
|
|
124
|
-
children: e.status ?? "ready to sow"
|
|
125
|
-
})]
|
|
126
|
-
}),
|
|
127
|
-
/* @__PURE__ */ c("dl", {
|
|
128
|
-
className: "mt-3 grid grid-cols-2 gap-2 text-sm",
|
|
129
|
-
children: [
|
|
130
|
-
/* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("dt", {
|
|
131
|
-
className: "text-text-secondary",
|
|
132
|
-
children: _("healthybowl.crops.fieldDetail.beds.crop", "Crop")
|
|
133
|
-
}), /* @__PURE__ */ s("dd", {
|
|
134
|
-
className: "font-medium text-text-primary",
|
|
135
|
-
children: t?.name ?? _("healthybowl.crops.fieldDetail.beds.unassigned", "Unassigned")
|
|
136
|
-
})] }),
|
|
137
|
-
/* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("dt", {
|
|
138
|
-
className: "text-text-secondary",
|
|
139
|
-
children: _("healthybowl.crops.fieldDetail.beds.plants", "Plants")
|
|
140
|
-
}), /* @__PURE__ */ s("dd", {
|
|
141
|
-
className: "font-medium text-text-primary",
|
|
142
|
-
children: e.plantCount ?? "—"
|
|
143
|
-
})] }),
|
|
144
|
-
/* @__PURE__ */ c("div", { children: [/* @__PURE__ */ s("dt", {
|
|
145
|
-
className: "text-text-secondary",
|
|
146
|
-
children: _("healthybowl.crops.fieldDetail.beds.area", "Area")
|
|
147
|
-
}), /* @__PURE__ */ c("dd", {
|
|
148
|
-
className: "font-medium text-text-primary",
|
|
149
|
-
children: [
|
|
150
|
-
e.area ?? "—",
|
|
151
|
-
" ",
|
|
152
|
-
e.unit ?? ""
|
|
153
|
-
]
|
|
154
|
-
})] })
|
|
155
|
-
]
|
|
156
|
-
}),
|
|
157
|
-
/* @__PURE__ */ c("label", {
|
|
158
|
-
className: "mt-4 block text-xs font-medium text-text-secondary",
|
|
159
|
-
children: [_("healthybowl.crops.fieldDetail.beds.assign", "Assign crop"), /* @__PURE__ */ c("select", {
|
|
160
|
-
value: e.cropId ?? "",
|
|
161
|
-
onChange: (t) => void k(e, t.target.value),
|
|
162
|
-
disabled: b === e.id,
|
|
163
|
-
className: "mt-1 w-full rounded-md border border-border-seam bg-bg-surface px-2 py-2 text-sm text-text-primary",
|
|
164
|
-
"aria-label": _("healthybowl.crops.fieldDetail.beds.assignTo", "Assign crop to {{name}}", { name: e.name }),
|
|
165
|
-
children: [/* @__PURE__ */ s("option", {
|
|
166
|
-
value: "",
|
|
167
|
-
children: _("healthybowl.crops.fieldDetail.beds.unassigned", "Unassigned")
|
|
168
|
-
}), g.map((e) => /* @__PURE__ */ s("option", {
|
|
169
|
-
value: e.id,
|
|
170
|
-
children: e.name
|
|
171
|
-
}, e.id))]
|
|
172
|
-
})]
|
|
173
|
-
})
|
|
174
|
-
]
|
|
175
|
-
}, e.id);
|
|
176
|
-
})
|
|
182
|
+
"aria-label": i("healthybowl.crops.fieldDetail.beds.listLabel", "Saved beds"),
|
|
183
|
+
children: D.map((e) => /* @__PURE__ */ f(x, {
|
|
184
|
+
bed: e,
|
|
185
|
+
crops: r,
|
|
186
|
+
loadedCrop: e.cropId ? O.get(e.cropId) : void 0,
|
|
187
|
+
saving: y === e.id,
|
|
188
|
+
onAssign: k
|
|
189
|
+
}, e.id))
|
|
177
190
|
})]
|
|
178
191
|
});
|
|
179
192
|
}
|
|
180
193
|
//#endregion
|
|
181
|
-
export {
|
|
194
|
+
export { S as BedLayoutGrid };
|
|
182
195
|
|
|
183
196
|
//# sourceMappingURL=BedLayoutGrid.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BedLayoutGrid.js","names":[],"sources":["../../../src/healthybowl/components/BedLayoutGrid.tsx"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport { gql } from '@apollo/client';\nimport { useMutation, useQuery } from '@apollo/client/react';\nimport { LayoutGrid, Loader2 } from 'lucide-react';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\nimport { useToast } from '../hooks/useToast';\nimport type { Crop } from '../types';\n\nconst BEDS_QUERY = gql`\n query HealthyBowlFieldDetailBeds($context: ContextInput!, $fieldId: ID) {\n healthyBowlBeds(context: $context, fieldId: $fieldId) {\n id\n fieldId\n name\n area\n unit\n cropId\n plantCount\n status\n }\n }\n`;\n\nconst UPDATE_BED = gql`\n mutation UpdateHealthyBowlFieldDetailBed($input: UpdateHealthyBowlBedInput!) {\n updateHealthyBowlBed(input: $input) {\n id\n cropId\n plantCount\n status\n }\n }\n`;\n\ninterface Bed {\n id: string;\n fieldId: string;\n name: string;\n area: number | null;\n unit: string | null;\n cropId: string | null;\n plantCount: number | null;\n status: string | null;\n}\n\ninterface BedsData {\n healthyBowlBeds: Bed[];\n}\n\ninterface BedsVariables {\n context: { workspaceId: string };\n fieldId: string;\n}\n\ninterface UpdateVariables {\n input: {\n id: string;\n cropId: string | null;\n plantCount: number | null;\n context: { workspaceId: string };\n };\n}\n\ninterface BedLayoutGridProps {\n fieldId: string;\n crops: Crop[];\n}\n\nfunction statusClass(status: string | null, assigned: boolean): string {\n if (status === 'planted' || assigned) return 'border-success/50 bg-success/10';\n if (status === 'fallow') return 'border-muted/50 bg-muted/10';\n return 'border-warning/50 bg-warning/10';\n}\n\nexport function BedLayoutGrid({ fieldId, crops }: BedLayoutGridProps): React.JSX.Element {\n const { t } = useI18n();\n const { workspaceId } = useHealthyBowl();\n const { toast } = useToast();\n const [savingId, setSavingId] = useState<string | null>(null);\n const { data, loading, error, refetch } = useQuery<BedsData, BedsVariables>(BEDS_QUERY, {\n variables: { context: { workspaceId }, fieldId },\n skip: !workspaceId || !fieldId,\n });\n const [updateBed] = useMutation<unknown, UpdateVariables>(UPDATE_BED);\n\n const beds = data?.healthyBowlBeds ?? [];\n const cropById = useMemo(() => new Map(crops.map((crop) => [crop.id, crop])), [crops]);\n\n const assignCrop = async (bed: Bed, cropId: string) => {\n setSavingId(bed.id);\n try {\n await updateBed({\n variables: {\n input: {\n id: bed.id,\n cropId: cropId || null,\n plantCount: bed.plantCount,\n context: { workspaceId },\n },\n },\n });\n await refetch();\n toast({\n title: t('healthybowl.crops.fieldDetail.beds.saved.title', 'Bed updated'),\n description: t('healthybowl.crops.fieldDetail.beds.saved.description', '{{name}} is up to date.', {\n name: bed.name,\n }),\n variant: 'success',\n });\n } catch (cause) {\n toast({\n title: t('healthybowl.crops.fieldDetail.beds.failed.title', 'Could not update bed'),\n description: String(cause),\n variant: 'error',\n });\n } finally {\n setSavingId(null);\n }\n };\n\n return (\n <section\n aria-labelledby=\"healthy-bowl-bed-layout-heading\"\n className=\"rounded-xl border border-border-seam bg-bg-surface p-6\"\n >\n <div className=\"mb-4 flex items-start justify-between gap-4\">\n <div>\n <div className=\"flex items-center gap-2\">\n <LayoutGrid className=\"h-5 w-5 text-action-primary\" aria-hidden=\"true\" />\n <h2 id=\"healthy-bowl-bed-layout-heading\" className=\"text-base font-semibold text-text-primary\">\n {t('healthybowl.crops.fieldDetail.beds.title', 'Bed layout')}\n </h2>\n </div>\n <p className=\"mt-1 text-sm text-text-secondary\">\n {t(\n 'healthybowl.crops.fieldDetail.beds.description',\n 'See every saved bed, its crop, status and planting capacity.'\n )}\n </p>\n </div>\n <Button variant=\"outline\" size=\"sm\" onClick={() => void refetch()} disabled={loading}>\n {loading ? <Loader2 className=\"h-4 w-4 animate-spin\" /> : t('healthybowl.common.refresh', 'Refresh')}\n </Button>\n </div>\n\n {loading && beds.length === 0 ? (\n <div className=\"py-8 text-center text-sm text-text-secondary\">\n {t('healthybowl.common.loading', 'Loading…')}\n </div>\n ) : error ? (\n <div className=\"rounded-lg border border-error/40 bg-error/10 p-4 text-sm text-error\">\n {t('healthybowl.crops.fieldDetail.beds.error', 'Beds could not be loaded. Try again.')}\n </div>\n ) : beds.length === 0 ? (\n <div className=\"rounded-lg border border-dashed border-border-seam p-8 text-center\">\n <p className=\"font-medium text-text-primary\">\n {t('healthybowl.crops.fieldDetail.beds.empty.title', 'No beds saved yet')}\n </p>\n <p className=\"mt-1 text-sm text-text-secondary\">\n {t(\n 'healthybowl.crops.fieldDetail.beds.empty.description',\n 'Generate and save a bed layout from the Field Map page.'\n )}\n </p>\n </div>\n ) : (\n <div\n className=\"grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-3\"\n role=\"list\"\n aria-label={t('healthybowl.crops.fieldDetail.beds.listLabel', 'Saved beds')}\n >\n {beds.map((bed) => {\n const crop = bed.cropId ? cropById.get(bed.cropId) : undefined;\n return (\n <article\n key={bed.id}\n role=\"listitem\"\n className={`rounded-lg border p-4 ${statusClass(bed.status, Boolean(crop))}`}\n >\n <div className=\"flex items-start justify-between gap-2\">\n <h3 className=\"font-semibold text-text-primary\">{bed.name}</h3>\n <span className=\"rounded-full bg-bg-surface px-2 py-1 text-xs capitalize text-text-secondary\">\n {bed.status ?? 'ready to sow'}\n </span>\n </div>\n <dl className=\"mt-3 grid grid-cols-2 gap-2 text-sm\">\n <div>\n <dt className=\"text-text-secondary\">{t('healthybowl.crops.fieldDetail.beds.crop', 'Crop')}</dt>\n <dd className=\"font-medium text-text-primary\">\n {crop?.name ?? t('healthybowl.crops.fieldDetail.beds.unassigned', 'Unassigned')}\n </dd>\n </div>\n <div>\n <dt className=\"text-text-secondary\">{t('healthybowl.crops.fieldDetail.beds.plants', 'Plants')}</dt>\n <dd className=\"font-medium text-text-primary\">{bed.plantCount ?? '—'}</dd>\n </div>\n <div>\n <dt className=\"text-text-secondary\">{t('healthybowl.crops.fieldDetail.beds.area', 'Area')}</dt>\n <dd className=\"font-medium text-text-primary\">\n {bed.area ?? '—'} {bed.unit ?? ''}\n </dd>\n </div>\n </dl>\n <label className=\"mt-4 block text-xs font-medium text-text-secondary\">\n {t('healthybowl.crops.fieldDetail.beds.assign', 'Assign crop')}\n <select\n value={bed.cropId ?? ''}\n onChange={(event) => void assignCrop(bed, event.target.value)}\n disabled={savingId === bed.id}\n className=\"mt-1 w-full rounded-md border border-border-seam bg-bg-surface px-2 py-2 text-sm text-text-primary\"\n aria-label={t('healthybowl.crops.fieldDetail.beds.assignTo', 'Assign crop to {{name}}', {\n name: bed.name,\n })}\n >\n <option value=\"\">{t('healthybowl.crops.fieldDetail.beds.unassigned', 'Unassigned')}</option>\n {crops.map((option) => (\n <option key={option.id} value={option.id}>\n {option.name}\n </option>\n ))}\n </select>\n </label>\n </article>\n );\n })}\n </div>\n )}\n </section>\n );\n}\n"],"mappings":";;;;;;;;;;AAUA,IAAM,IAAa,CAAG;;;;;;;;;;;;;GAehB,IAAa,CAAG;;;;;;;;;;AA6CtB,SAAS,EAAY,GAAuB,GAA2B;CAGrE,OAFI,MAAW,aAAa,IAAiB,oCACzC,MAAW,WAAiB,gCACzB;AACT;AAEA,SAAgB,EAAc,EAAE,YAAS,YAAgD;CACvF,IAAM,EAAE,SAAM,EAAQ,GAChB,EAAE,mBAAgB,EAAe,GACjC,EAAE,aAAU,EAAS,GACrB,CAAC,GAAU,KAAe,EAAwB,IAAI,GACtD,EAAE,SAAM,YAAS,UAAO,eAAY,EAAkC,GAAY;EACtF,WAAW;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C,MAAD;SAAI,WAAU;mBAAiC,EAAI,cAAc;QAAQ,CAAA,CACtE,EAAA,CAAA;QACL,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,MAAD;SAAI,WAAU;mBAAuB,EAAE,2CAA2C,MAAM;QAAM,CAAA,GAC9F,kBAAC,MAAD;SAAI,WAAU;mBAAd;UACG,EAAI,QAAQ;UAAI;UAAE,EAAI,QAAQ;SAC7B;UACD,EAAA,CAAA;OACH;;MACJ,kBAAC,SAAD;OAAO,WAAU;iBAAjB,CACG,EAAE,6CAA6C,aAAa,GAC7D,kBAAC,UAAD;QACE,OAAO,EAAI,UAAU;QACrB,WAAW,MAAU,KAAK,EAAW,GAAK,EAAM,OAAO,KAAK;QAC5D,UAAU,MAAa,EAAI;QAC3B,WAAU;QACV,cAAY,EAAE,+CAA+C,2BAA2B,EACtF,MAAM,EAAI,KACZ,CAAC;kBAPH,CASE,kBAAC,UAAD;SAAQ,OAAM;mBAAI,EAAE,iDAAiD,YAAY;QAAU,CAAA,GAC1F,EAAM,KAAK,MACV,kBAAC,UAAD;SAAwB,OAAO,EAAO;mBACnC,EAAO;QACF,GAFK,EAAO,EAEZ,CACT,CACK;SACH;;KACA;OA/CF,EAAI,EA+CF;GAEb,CAAC;EACE,CAAA,CAEA;;AAEb"}
|
|
1
|
+
{"version":3,"file":"BedLayoutGrid.js","names":[],"sources":["../../../src/healthybowl/components/BedLayoutGrid.tsx"],"sourcesContent":["import { useId, useMemo, useState } from 'react';\nimport { gql, type TypedDocumentNode } from '@apollo/client';\nimport { useMutation } from '@apollo/client/react';\nimport { LayoutGrid, Loader2 } from 'lucide-react';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\nimport { useToast } from '../hooks/useToast';\nimport type { Crop } from '../types';\nimport { useWorkspaceRead } from '../hooks/useWorkspaceRead';\nimport { useCropDetail } from '../hooks/useCropPage';\nimport { pickerRecordLabel } from '../utils/cropPicker';\nimport { CropPicker } from './CropPicker';\n\nconst BEDS_QUERY: TypedDocumentNode<BedsData, BedsVariables> = gql`\n query HealthyBowlFieldDetailBeds($context: ContextInput!, $fieldId: ID) {\n healthyBowlBeds(context: $context, fieldId: $fieldId) {\n id\n fieldId\n name\n area\n unit\n cropId\n plantCount\n status\n }\n }\n`;\n\nconst UPDATE_BED = gql`\n mutation UpdateHealthyBowlFieldDetailBed($input: UpdateHealthyBowlBedInput!) {\n updateHealthyBowlBed(input: $input) {\n id\n cropId\n plantCount\n status\n }\n }\n`;\n\ninterface Bed {\n id: string;\n fieldId: string;\n name: string;\n area: number | null;\n unit: string | null;\n cropId: string | null;\n plantCount: number | null;\n status: string | null;\n}\n\ninterface BedsData {\n healthyBowlBeds: Bed[];\n}\n\ninterface BedsVariables {\n context: { workspaceId: string };\n fieldId: string;\n}\n\ninterface UpdateBedData {\n updateHealthyBowlBed: Pick<Bed, 'id' | 'cropId' | 'plantCount' | 'status'>;\n}\n\ninterface UpdateVariables {\n input: {\n id: string;\n cropId: string | null;\n plantCount: number | null;\n context: { workspaceId: string };\n };\n}\n\ninterface BedLayoutGridProps {\n fieldId: string;\n crops: Crop[];\n}\n\nfunction statusClass(status: string | null, assigned: boolean): string {\n if (status === 'planted' || assigned) return 'border-success/50 bg-success/10';\n if (status === 'fallow') return 'border-muted/50 bg-muted/10';\n return 'border-warning/50 bg-warning/10';\n}\n\nconst UNASSIGNED_CROP = '__bed-unassigned__';\n\ninterface BedLayoutCardProps {\n bed: Bed;\n crops: Crop[];\n loadedCrop?: Crop;\n saving: boolean;\n onAssign: (bed: Bed, cropId: string) => Promise<void>;\n}\n\nfunction BedLayoutCard({ bed, crops, loadedCrop, saving, onAssign }: BedLayoutCardProps) {\n const { t } = useI18n();\n const pickerId = useId();\n const { crop: resolvedCrop, loading, error } = useCropDetail(bed.cropId, { skip: Boolean(loadedCrop) });\n const crop = loadedCrop ?? resolvedCrop;\n const recordedLabel = t('healthybowl.crops.fieldDetail.beds.recordedCrop', 'Recorded crop ({{id}})', {\n id: bed.cropId ?? '',\n });\n const cropLabel = crop\n ? pickerRecordLabel(crop)\n : bed.cropId\n ? loading\n ? t('healthybowl.crops.fieldDetail.beds.recordedLoading', 'Recorded crop ({{id}}) — loading…', {\n id: bed.cropId,\n })\n : error\n ? t(\n 'healthybowl.crops.fieldDetail.beds.recordedError',\n 'Recorded crop ({{id}}) — details could not be loaded',\n {\n id: bed.cropId,\n }\n )\n : t('healthybowl.crops.fieldDetail.beds.recordedUnavailable', 'Recorded crop ({{id}}) — unavailable', {\n id: bed.cropId,\n })\n : t('healthybowl.crops.fieldDetail.beds.unassigned', 'Unassigned');\n\n return (\n <article role=\"listitem\" className={`rounded-lg border p-4 ${statusClass(bed.status, Boolean(bed.cropId))}`}>\n <div className=\"flex items-start justify-between gap-2\">\n <h3 className=\"font-semibold text-text-primary\">{bed.name}</h3>\n <span className=\"rounded-full bg-bg-surface px-2 py-1 text-xs capitalize text-text-secondary\">\n {bed.status ?? 'ready to sow'}\n </span>\n </div>\n <dl className=\"mt-3 grid grid-cols-2 gap-2 text-sm\">\n <div>\n <dt className=\"text-text-secondary\">{t('healthybowl.crops.fieldDetail.beds.crop', 'Crop')}</dt>\n <dd className=\"font-medium text-text-primary\">{cropLabel}</dd>\n </div>\n <div>\n <dt className=\"text-text-secondary\">{t('healthybowl.crops.fieldDetail.beds.plants', 'Plants')}</dt>\n <dd className=\"font-medium text-text-primary\">{bed.plantCount ?? '—'}</dd>\n </div>\n <div>\n <dt className=\"text-text-secondary\">{t('healthybowl.crops.fieldDetail.beds.area', 'Area')}</dt>\n <dd className=\"font-medium text-text-primary\">\n {bed.area ?? '—'} {bed.unit ?? ''}\n </dd>\n </div>\n </dl>\n <div className=\"mt-4\">\n <label htmlFor={pickerId} className=\"block text-xs font-medium text-text-secondary\">\n {t('healthybowl.crops.fieldDetail.beds.assign', 'Assign crop')}\n </label>\n <CropPicker\n id={pickerId}\n value={bed.cropId ?? UNASSIGNED_CROP}\n onValueChange={(cropId) => void onAssign(bed, cropId === UNASSIGNED_CROP ? '' : cropId)}\n options={crops}\n recordedLabel={recordedLabel}\n emptyOption={{\n value: UNASSIGNED_CROP,\n label: t('healthybowl.crops.fieldDetail.beds.unassigned', 'Unassigned'),\n }}\n disabled={saving}\n className=\"mt-1\"\n placeholder={t('healthybowl.crops.fieldDetail.beds.assignTo', 'Assign crop to {{name}}', { name: bed.name })}\n />\n </div>\n </article>\n );\n}\n\nexport function BedLayoutGrid({ fieldId, crops }: BedLayoutGridProps): React.JSX.Element {\n const { t } = useI18n();\n const { workspaceId } = useHealthyBowl();\n const { toast } = useToast();\n const [savingId, setSavingId] = useState<string | null>(null);\n const variables = useMemo<BedsVariables>(() => ({ context: { workspaceId }, fieldId }), [workspaceId, fieldId]);\n const { data, loading, error, refetch } = useWorkspaceRead(BEDS_QUERY, variables, !fieldId);\n const [updateBed] = useMutation<UpdateBedData, UpdateVariables>(UPDATE_BED);\n\n const beds = data?.healthyBowlBeds ?? [];\n const cropById = useMemo(() => new Map(crops.map((crop) => [crop.id, crop])), [crops]);\n\n const assignCrop = async (bed: Bed, cropId: string) => {\n setSavingId(bed.id);\n try {\n await updateBed({\n variables: {\n input: {\n id: bed.id,\n cropId: cropId || null,\n plantCount: bed.plantCount,\n context: { workspaceId },\n },\n },\n });\n await refetch();\n toast({\n title: t('healthybowl.crops.fieldDetail.beds.saved.title', 'Bed updated'),\n description: t('healthybowl.crops.fieldDetail.beds.saved.description', '{{name}} is up to date.', {\n name: bed.name,\n }),\n variant: 'success',\n });\n } catch (cause) {\n toast({\n title: t('healthybowl.crops.fieldDetail.beds.failed.title', 'Could not update bed'),\n description: String(cause),\n variant: 'error',\n });\n } finally {\n setSavingId(null);\n }\n };\n\n return (\n <section\n aria-labelledby=\"healthy-bowl-bed-layout-heading\"\n className=\"rounded-xl border border-border-seam bg-bg-surface p-6\"\n >\n <div className=\"mb-4 flex items-start justify-between gap-4\">\n <div>\n <div className=\"flex items-center gap-2\">\n <LayoutGrid className=\"h-5 w-5 text-action-primary\" aria-hidden=\"true\" />\n <h2 id=\"healthy-bowl-bed-layout-heading\" className=\"text-base font-semibold text-text-primary\">\n {t('healthybowl.crops.fieldDetail.beds.title', 'Bed layout')}\n </h2>\n </div>\n <p className=\"mt-1 text-sm text-text-secondary\">\n {t(\n 'healthybowl.crops.fieldDetail.beds.description',\n 'See every saved bed, its crop, status and planting capacity.'\n )}\n </p>\n </div>\n <Button variant=\"outline\" size=\"sm\" onClick={() => void refetch()} disabled={loading}>\n {loading ? <Loader2 className=\"h-4 w-4 animate-spin\" /> : t('healthybowl.common.refresh', 'Refresh')}\n </Button>\n </div>\n\n {loading && beds.length === 0 ? (\n <div className=\"py-8 text-center text-sm text-text-secondary\">\n {t('healthybowl.common.loading', 'Loading…')}\n </div>\n ) : error ? (\n <div className=\"rounded-lg border border-error/40 bg-error/10 p-4 text-sm text-error\">\n {t('healthybowl.crops.fieldDetail.beds.error', 'Beds could not be loaded. Try again.')}\n </div>\n ) : beds.length === 0 ? (\n <div className=\"rounded-lg border border-dashed border-border-seam p-8 text-center\">\n <p className=\"font-medium text-text-primary\">\n {t('healthybowl.crops.fieldDetail.beds.empty.title', 'No beds saved yet')}\n </p>\n <p className=\"mt-1 text-sm text-text-secondary\">\n {t(\n 'healthybowl.crops.fieldDetail.beds.empty.description',\n 'Generate and save a bed layout from the Field Map page.'\n )}\n </p>\n </div>\n ) : (\n <div\n className=\"grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-3\"\n role=\"list\"\n aria-label={t('healthybowl.crops.fieldDetail.beds.listLabel', 'Saved beds')}\n >\n {beds.map((bed) => (\n <BedLayoutCard\n key={bed.id}\n bed={bed}\n crops={crops}\n loadedCrop={bed.cropId ? cropById.get(bed.cropId) : undefined}\n saving={savingId === bed.id}\n onAssign={assignCrop}\n />\n ))}\n </div>\n )}\n </section>\n );\n}\n"],"mappings":";;;;;;;;;;;;;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,4CAA4C,sCAAsC;EAClF,CAAA,IACH,EAAK,WAAW,IAClB,kBAAC,OAAD;GAAK,WAAU;aAAf,CACE,kBAAC,KAAD;IAAG,WAAU;cACV,EAAE,kDAAkD,mBAAmB;GACvE,CAAA,GACH,kBAAC,KAAD;IAAG,WAAU;cACV,EACC,wDACA,yDACF;GACC,CAAA,CACA;OAEL,kBAAC,OAAD;GACE,WAAU;GACV,MAAK;GACL,cAAY,EAAE,gDAAgD,YAAY;aAEzE,EAAK,KAAK,MACT,kBAAC,GAAD;IAEO;IACE;IACP,YAAY,EAAI,SAAS,EAAS,IAAI,EAAI,MAAM,IAAI,KAAA;IACpD,QAAQ,MAAa,EAAI;IACzB,UAAU;GACX,GANM,EAAI,EAMV,CACF;EACE,CAAA,CAEA;;AAEb"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useHealthyBowl as e } from "../context/HealthyBowlContext.js";
|
|
2
|
+
import { useCropDetail as t, useCropPage as n } from "../hooks/useCropPage.js";
|
|
3
|
+
import { WorkspaceRecordPicker as r, usePickerBrowseState as i } from "./WorkspaceRecordPicker.js";
|
|
4
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
5
|
+
//#region src/healthybowl/components/CropPicker.tsx
|
|
6
|
+
function o(o) {
|
|
7
|
+
let { workspaceId: s } = e(), c = i(), l = o.skip || o.disabled || !s, u = n({
|
|
8
|
+
search: c.search || void 0,
|
|
9
|
+
category: c.category || void 0,
|
|
10
|
+
uncategorized: c.uncategorized || void 0,
|
|
11
|
+
limit: 50,
|
|
12
|
+
offset: c.offset,
|
|
13
|
+
skip: !!l
|
|
14
|
+
}), d = t(o.value, { skip: !!l || o.value === o.emptyOption?.value });
|
|
15
|
+
return /* @__PURE__ */ a(r, {
|
|
16
|
+
...o,
|
|
17
|
+
placeholder: o.placeholder ?? "Choose a crop",
|
|
18
|
+
kind: "crops",
|
|
19
|
+
workspaceId: s,
|
|
20
|
+
browse: c,
|
|
21
|
+
page: u,
|
|
22
|
+
selected: {
|
|
23
|
+
entry: d.crop,
|
|
24
|
+
loading: d.loading,
|
|
25
|
+
error: d.error,
|
|
26
|
+
refetch: d.refetch
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function s(t) {
|
|
31
|
+
let { workspaceId: n } = e();
|
|
32
|
+
return /* @__PURE__ */ a(o, { ...t }, n);
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { s as CropPicker };
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=CropPicker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CropPicker.js","names":[],"sources":["../../../src/healthybowl/components/CropPicker.tsx"],"sourcesContent":["import { useHealthyBowl } from '../context/HealthyBowlContext';\nimport { useCropDetail, useCropPage } from '../hooks/useCropPage';\nimport type { Crop } from '../types';\nimport { WorkspaceRecordPicker, usePickerBrowseState, type WorkspaceRecordPickerProps } from './WorkspaceRecordPicker';\n\nexport type CropPickerProps = WorkspaceRecordPickerProps<Crop>;\n\nfunction WorkspaceCropPicker(props: CropPickerProps) {\n const { workspaceId } = useHealthyBowl();\n const browse = usePickerBrowseState();\n const inactive = props.skip || props.disabled || !workspaceId;\n const page = useCropPage({\n search: browse.search || undefined,\n category: browse.category || undefined,\n uncategorized: browse.uncategorized || undefined,\n limit: 50,\n offset: browse.offset,\n skip: Boolean(inactive),\n });\n const detail = useCropDetail(props.value, { skip: Boolean(inactive) || props.value === props.emptyOption?.value });\n return (\n <WorkspaceRecordPicker\n {...props}\n placeholder={props.placeholder ?? 'Choose a crop'}\n kind=\"crops\"\n workspaceId={workspaceId}\n browse={browse}\n page={page}\n selected={{ entry: detail.crop, loading: detail.loading, error: detail.error, refetch: detail.refetch }}\n />\n );\n}\n\n/** Operational Crop IDs only. Workspace changes remount browsing state, never reset selection. */\nexport function CropPicker(props: CropPickerProps) {\n const { workspaceId } = useHealthyBowl();\n return <WorkspaceCropPicker key={workspaceId} {...props} />;\n}\n"],"mappings":";;;;;AAOA,SAAS,EAAoB,GAAwB;CACnD,IAAM,EAAE,mBAAgB,EAAe,GACjC,IAAS,EAAqB,GAC9B,IAAW,EAAM,QAAQ,EAAM,YAAY,CAAC,GAC5C,IAAO,EAAY;EACvB,QAAQ,EAAO,UAAU,KAAA;EACzB,UAAU,EAAO,YAAY,KAAA;EAC7B,eAAe,EAAO,iBAAiB,KAAA;EACvC,OAAO;EACP,QAAQ,EAAO;EACf,MAAM,EAAQ;CAChB,CAAC,GACK,IAAS,EAAc,EAAM,OAAO,EAAE,MAAM,EAAQ,KAAa,EAAM,UAAU,EAAM,aAAa,MAAM,CAAC;CACjH,OACE,kBAAC,GAAD;EACE,GAAI;EACJ,aAAa,EAAM,eAAe;EAClC,MAAK;EACQ;EACL;EACF;EACN,UAAU;GAAE,OAAO,EAAO;GAAM,SAAS,EAAO;GAAS,OAAO,EAAO;GAAO,SAAS,EAAO;EAAQ;CACvG,CAAA;AAEL;AAGA,SAAgB,EAAW,GAAwB;CACjD,IAAM,EAAE,mBAAgB,EAAe;CACvC,OAAO,kBAAC,GAAD,EAAuC,GAAI,EAAQ,GAAzB,CAAyB;AAC5D"}
|