@burdenoff/microfe-healthybowl 2026.625.7 → 2026.625.8

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.
@@ -5,14 +5,14 @@ import { EmptyState as r } from "../../components/EmptyState.js";
5
5
  import { ToastContainer as i } from "../../components/Toast.js";
6
6
  import { useConfirm as a } from "../../components/ConfirmDialog.js";
7
7
  import { Modal as o } from "../../components/Modal.js";
8
- import { useAssignHealthyBowlConsultantMutation as s, useGetHealthyBowlConsultantAssignmentsQuery as c, useGetHealthyBowlMyAdvisoryTasksQuery as l, useGetHealthyBowlMyFarmRecommendationsQuery as u, useRevokeHealthyBowlConsultantAssignmentMutation as d } from "../../../generated/wspace-operations.js";
8
+ import { useAssignHealthyBowlConsultantMutation as s, useGetHealthyBowlConsultantAssignmentsQuery as c, useGetHealthyBowlMyAdvisoryTasksQuery as l, useGetHealthyBowlMyFarmRecommendationsQuery as ee, useRevokeHealthyBowlConsultantAssignmentMutation as u } from "../../../generated/wspace-operations.js";
9
9
  import "../../components/index.js";
10
- import { useToast as f } from "../../hooks/useToast.js";
11
- import { useState as p } from "react";
12
- import { useI18n as m } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
13
- import { AlertCircle as h, CheckCircle2 as g, ClipboardList as _, Plus as v, Trash2 as ee, UserCheck as y } from "lucide-react";
14
- import { Fragment as b, jsx as x, jsxs as S } from "react/jsx-runtime";
15
- import { Button as C, Select as te, SelectContent as ne, SelectItem as w, SelectTrigger as re, SelectValue as ie } from "@burdenoff/fe-libs/ui";
10
+ import { useToast as d } from "../../hooks/useToast.js";
11
+ import { useState as f } from "react";
12
+ import { useI18n as p } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
13
+ import { AlertCircle as m, CheckCircle2 as h, ClipboardList as g, Plus as _, Trash2 as te, UserCheck as v } from "lucide-react";
14
+ import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
15
+ import { Button as S, ResponsiveTable as C, Select as ne, SelectContent as re, SelectItem as w, SelectTrigger as ie, SelectValue as ae } from "@burdenoff/fe-libs/ui";
16
16
  //#region src/healthybowl/pages/consultant/FarmerAdvisorsPage.tsx
17
17
  var T = (e) => e.length > 14 ? `${e.slice(0, 10)}…` : e, E = (e) => {
18
18
  switch (e.toUpperCase()) {
@@ -22,11 +22,11 @@ var T = (e) => e.length > 14 ? `${e.slice(0, 10)}…` : e, E = (e) => {
22
22
  default: return "default";
23
23
  }
24
24
  }, D = () => {
25
- let { t: D } = m(), { workspaceId: O } = e(), { toasts: k, toast: A, dismiss: j } = f(), M = a(), N = {
25
+ let { t: D } = p(), { workspaceId: O } = e(), { toasts: k, toast: A, dismiss: j } = d(), M = a(), N = {
26
26
  variables: { context: { workspaceId: O } },
27
27
  skip: !O,
28
28
  fetchPolicy: "cache-and-network"
29
- }, P = c(N), F = u(N), I = l(N), [L] = s(), [R] = d(), z = (P.data?.getHealthyBowlConsultantAssignments ?? []).filter((e) => e.status.toUpperCase() === "ACTIVE"), B = F.data?.getHealthyBowlMyFarmRecommendations ?? [], V = I.data?.getHealthyBowlMyAdvisoryTasks ?? [], [H, U] = p(!1), [W, G] = p(!1), [K, q] = p(null), [J, Y] = p(""), [X, Z] = p(""), [Q, $] = p("FULL_ADVISORY"), ae = async () => {
29
+ }, P = c(N), F = ee(N), I = l(N), [L] = s(), [R] = u(), z = (P.data?.getHealthyBowlConsultantAssignments ?? []).filter((e) => e.status.toUpperCase() === "ACTIVE"), B = F.data?.getHealthyBowlMyFarmRecommendations ?? [], V = I.data?.getHealthyBowlMyAdvisoryTasks ?? [], [H, U] = f(!1), [W, G] = f(!1), [K, q] = f(null), [J, Y] = f(""), [X, Z] = f(""), [Q, $] = f("FULL_ADVISORY"), oe = async () => {
30
30
  if (!J.trim()) {
31
31
  A({
32
32
  title: D("healthybowl.consultant.farmerAdvisors.toast.idRequired.title", "Consultant ID required"),
@@ -56,7 +56,7 @@ var T = (e) => e.length > 14 ? `${e.slice(0, 10)}…` : e, E = (e) => {
56
56
  } finally {
57
57
  G(!1);
58
58
  }
59
- }, oe = async (e) => {
59
+ }, se = async (e) => {
60
60
  if (await M({ message: D("healthybowl.consultant.farmerAdvisors.revokeConfirm", "Revoke {{name}}’s access to your farm? They will immediately lose access.", { name: e.consultantName || D("healthybowl.consultant.farmerAdvisors.thisConsultant", "this consultant") }) })) {
61
61
  q(e.id);
62
62
  try {
@@ -78,142 +78,128 @@ var T = (e) => e.length > 14 ? `${e.slice(0, 10)}…` : e, E = (e) => {
78
78
  q(null);
79
79
  }
80
80
  }
81
- };
82
- return /* @__PURE__ */ S(t, {
81
+ }, ce = [
82
+ {
83
+ key: "consultant",
84
+ header: D("healthybowl.consultant.farmerAdvisors.table.headers.consultant", "Consultant"),
85
+ priority: "primary",
86
+ cell: (e) => /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ b("p", {
87
+ className: "font-medium text-text-primary",
88
+ children: e.consultantName || D("healthybowl.consultant.farmerAdvisors.unnamedConsultant", "Unnamed consultant")
89
+ }), /* @__PURE__ */ b("p", {
90
+ className: "font-mono text-xs text-text-secondary",
91
+ title: e.consultantActorId,
92
+ children: T(e.consultantActorId)
93
+ })] })
94
+ },
95
+ {
96
+ key: "scope",
97
+ header: D("healthybowl.consultant.farmerAdvisors.table.headers.scope", "Scope"),
98
+ priority: "secondary",
99
+ cellClassName: "text-text-secondary",
100
+ cell: (e) => e.scope.replace(/_/g, " ").toLowerCase()
101
+ },
102
+ {
103
+ key: "status",
104
+ header: D("healthybowl.consultant.farmerAdvisors.table.headers.status", "Status"),
105
+ priority: "secondary",
106
+ cell: (e) => /* @__PURE__ */ b(n, {
107
+ label: e.status,
108
+ variant: "success",
109
+ dot: !0
110
+ })
111
+ },
112
+ {
113
+ key: "action",
114
+ header: D("healthybowl.consultant.farmerAdvisors.table.headers.action", "Action"),
115
+ priority: "secondary",
116
+ headerClassName: "text-right",
117
+ cellClassName: "text-right",
118
+ cell: (e) => /* @__PURE__ */ x(S, {
119
+ variant: "destructive",
120
+ size: "sm",
121
+ onClick: () => se(e),
122
+ disabled: K === e.id,
123
+ children: [
124
+ /* @__PURE__ */ b(te, { className: "h-3.5 w-3.5" }),
125
+ " ",
126
+ K === e.id ? D("healthybowl.consultant.farmerAdvisors.actions.revoking", "Revoking…") : D("healthybowl.consultant.farmerAdvisors.actions.revoke", "Revoke")
127
+ ]
128
+ })
129
+ }
130
+ ];
131
+ return /* @__PURE__ */ x(t, {
83
132
  title: D("healthybowl.consultant.farmerAdvisors.title", "My Advisors"),
84
133
  description: D("healthybowl.consultant.farmerAdvisors.description", "Assign an agricultural consultant to advise your farm, and see their recommendations — revoke access anytime"),
85
- actions: /* @__PURE__ */ S(C, {
134
+ actions: /* @__PURE__ */ x(S, {
86
135
  onClick: () => U(!0),
87
136
  children: [
88
- /* @__PURE__ */ x(v, { className: "h-4 w-4" }),
137
+ /* @__PURE__ */ b(_, { className: "h-4 w-4" }),
89
138
  " ",
90
139
  D("healthybowl.consultant.farmerAdvisors.actions.assignConsultant", "Assign Consultant")
91
140
  ]
92
141
  }),
93
142
  children: [
94
- P.loading && z.length === 0 ? /* @__PURE__ */ x("p", {
143
+ P.loading && z.length === 0 ? /* @__PURE__ */ b("p", {
95
144
  className: "text-sm text-text-secondary",
96
145
  children: D("healthybowl.consultant.farmerAdvisors.loading", "Loading your advisors…")
97
- }) : P.error && z.length === 0 ? /* @__PURE__ */ S("div", {
146
+ }) : P.error && z.length === 0 ? /* @__PURE__ */ x("div", {
98
147
  className: "flex items-center gap-2 rounded-lg border border-border-subtle bg-bg-surface p-5 text-sm text-text-secondary",
99
148
  children: [
100
- /* @__PURE__ */ x(h, { className: "h-4 w-4" }),
149
+ /* @__PURE__ */ b(m, { className: "h-4 w-4" }),
101
150
  " ",
102
151
  D("healthybowl.consultant.farmerAdvisors.loadError", "Advisor info isn’t available right now.")
103
152
  ]
104
- }) : z.length === 0 ? /* @__PURE__ */ x(r, {
153
+ }) : z.length === 0 ? /* @__PURE__ */ b(r, {
105
154
  title: D("healthybowl.consultant.farmerAdvisors.emptyState.title", "No consultant assigned"),
106
155
  description: D("healthybowl.consultant.farmerAdvisors.emptyState.description", "Assign an agricultural consultant to get expert diagnosis and advice on your farm."),
107
- icon: /* @__PURE__ */ x(y, { className: "h-12 w-12 text-text-secondary" })
108
- }) : /* @__PURE__ */ x("div", {
109
- className: "overflow-hidden rounded-lg border border-border-subtle bg-bg-surface",
110
- children: /* @__PURE__ */ S("table", {
111
- className: "w-full text-sm",
112
- children: [/* @__PURE__ */ x("thead", { children: /* @__PURE__ */ S("tr", {
113
- className: "border-b border-border-subtle text-left text-xs text-text-secondary",
114
- children: [
115
- /* @__PURE__ */ x("th", {
116
- className: "px-4 py-3 font-medium",
117
- children: D("healthybowl.consultant.farmerAdvisors.table.headers.consultant", "Consultant")
118
- }),
119
- /* @__PURE__ */ x("th", {
120
- className: "px-4 py-3 font-medium",
121
- children: D("healthybowl.consultant.farmerAdvisors.table.headers.scope", "Scope")
122
- }),
123
- /* @__PURE__ */ x("th", {
124
- className: "px-4 py-3 font-medium",
125
- children: D("healthybowl.consultant.farmerAdvisors.table.headers.status", "Status")
126
- }),
127
- /* @__PURE__ */ x("th", {
128
- className: "px-4 py-3 text-right font-medium",
129
- children: D("healthybowl.consultant.farmerAdvisors.table.headers.action", "Action")
130
- })
131
- ]
132
- }) }), /* @__PURE__ */ x("tbody", { children: z.map((e) => /* @__PURE__ */ S("tr", {
133
- className: "border-b border-border-subtle/50 last:border-0",
134
- children: [
135
- /* @__PURE__ */ S("td", {
136
- className: "px-4 py-3",
137
- children: [/* @__PURE__ */ x("p", {
138
- className: "font-medium text-text-primary",
139
- children: e.consultantName || D("healthybowl.consultant.farmerAdvisors.unnamedConsultant", "Unnamed consultant")
140
- }), /* @__PURE__ */ x("p", {
141
- className: "font-mono text-xs text-text-secondary",
142
- title: e.consultantActorId,
143
- children: T(e.consultantActorId)
144
- })]
145
- }),
146
- /* @__PURE__ */ x("td", {
147
- className: "px-4 py-3 text-text-secondary",
148
- children: e.scope.replace(/_/g, " ").toLowerCase()
149
- }),
150
- /* @__PURE__ */ x("td", {
151
- className: "px-4 py-3",
152
- children: /* @__PURE__ */ x(n, {
153
- label: e.status,
154
- variant: "success",
155
- dot: !0
156
- })
157
- }),
158
- /* @__PURE__ */ x("td", {
159
- className: "px-4 py-3 text-right",
160
- children: /* @__PURE__ */ S(C, {
161
- variant: "destructive",
162
- size: "sm",
163
- onClick: () => oe(e),
164
- disabled: K === e.id,
165
- children: [
166
- /* @__PURE__ */ x(ee, { className: "h-3.5 w-3.5" }),
167
- " ",
168
- K === e.id ? D("healthybowl.consultant.farmerAdvisors.actions.revoking", "Revoking…") : D("healthybowl.consultant.farmerAdvisors.actions.revoke", "Revoke")
169
- ]
170
- })
171
- })
172
- ]
173
- }, e.id)) })]
174
- })
156
+ icon: /* @__PURE__ */ b(v, { className: "h-12 w-12 text-text-secondary" })
157
+ }) : /* @__PURE__ */ b(C, {
158
+ columns: ce,
159
+ data: z,
160
+ rowKey: (e) => String(e.id)
175
161
  }),
176
- /* @__PURE__ */ S("div", {
162
+ /* @__PURE__ */ x("div", {
177
163
  className: "rounded-lg border border-border-subtle bg-bg-surface p-5",
178
- children: [/* @__PURE__ */ S("h3", {
164
+ children: [/* @__PURE__ */ x("h3", {
179
165
  className: "mb-3 flex items-center gap-2 text-sm font-semibold text-text-primary",
180
166
  children: [
181
- /* @__PURE__ */ x(_, { className: "h-4 w-4 text-text-secondary" }),
167
+ /* @__PURE__ */ b(g, { className: "h-4 w-4 text-text-secondary" }),
182
168
  " ",
183
169
  D("healthybowl.consultant.farmerAdvisors.recommendations.heading", "Recommendations for your farm")
184
170
  ]
185
- }), F.error && B.length === 0 ? /* @__PURE__ */ x("p", {
171
+ }), F.error && B.length === 0 ? /* @__PURE__ */ b("p", {
186
172
  className: "text-sm text-text-secondary",
187
173
  children: D("healthybowl.consultant.farmerAdvisors.recommendations.loadError", "Recommendations couldn’t be loaded.")
188
- }) : B.length === 0 ? /* @__PURE__ */ x("p", {
174
+ }) : B.length === 0 ? /* @__PURE__ */ b("p", {
189
175
  className: "text-sm text-text-secondary",
190
176
  children: D("healthybowl.consultant.farmerAdvisors.recommendations.empty", "No recommendations yet.")
191
- }) : /* @__PURE__ */ x("ul", {
177
+ }) : /* @__PURE__ */ b("ul", {
192
178
  className: "space-y-2",
193
- children: B.map((e) => /* @__PURE__ */ S("li", {
179
+ children: B.map((e) => /* @__PURE__ */ x("li", {
194
180
  className: "flex items-start justify-between gap-3 border-b border-border-subtle/50 pb-2 last:border-0 last:pb-0",
195
- children: [/* @__PURE__ */ S("div", {
181
+ children: [/* @__PURE__ */ x("div", {
196
182
  className: "min-w-0",
197
183
  children: [
198
- /* @__PURE__ */ x("p", {
184
+ /* @__PURE__ */ b("p", {
199
185
  className: "text-sm font-medium text-text-primary",
200
186
  children: e.title
201
187
  }),
202
- /* @__PURE__ */ x("p", {
188
+ /* @__PURE__ */ b("p", {
203
189
  className: "text-xs text-text-secondary",
204
190
  children: e.detail
205
191
  }),
206
- e.authorName && /* @__PURE__ */ S("p", {
192
+ e.authorName && /* @__PURE__ */ x("p", {
207
193
  className: "text-xs text-text-secondary/80",
208
194
  children: ["— ", e.authorName]
209
195
  })
210
196
  ]
211
- }), /* @__PURE__ */ S("div", {
197
+ }), /* @__PURE__ */ x("div", {
212
198
  className: "flex shrink-0 items-center gap-2",
213
- children: [/* @__PURE__ */ x(n, {
199
+ children: [/* @__PURE__ */ b(n, {
214
200
  label: e.domain,
215
201
  variant: "default"
216
- }), /* @__PURE__ */ x(n, {
202
+ }), /* @__PURE__ */ b(n, {
217
203
  label: e.priority,
218
204
  variant: E(e.priority)
219
205
  })]
@@ -221,97 +207,97 @@ var T = (e) => e.length > 14 ? `${e.slice(0, 10)}…` : e, E = (e) => {
221
207
  }, e.id))
222
208
  })]
223
209
  }),
224
- /* @__PURE__ */ S("div", {
210
+ /* @__PURE__ */ x("div", {
225
211
  className: "rounded-lg border border-border-subtle bg-bg-surface p-5",
226
- children: [/* @__PURE__ */ S("h3", {
212
+ children: [/* @__PURE__ */ x("h3", {
227
213
  className: "mb-3 flex items-center gap-2 text-sm font-semibold text-text-primary",
228
214
  children: [
229
- /* @__PURE__ */ x(g, { className: "h-4 w-4 text-text-secondary" }),
215
+ /* @__PURE__ */ b(h, { className: "h-4 w-4 text-text-secondary" }),
230
216
  " ",
231
217
  D("healthybowl.consultant.farmerAdvisors.tasks.heading", "Tasks from your consultant")
232
218
  ]
233
- }), I.error && V.length === 0 ? /* @__PURE__ */ x("p", {
219
+ }), I.error && V.length === 0 ? /* @__PURE__ */ b("p", {
234
220
  className: "text-sm text-text-secondary",
235
221
  children: D("healthybowl.consultant.farmerAdvisors.tasks.loadError", "Tasks couldn’t be loaded.")
236
- }) : V.length === 0 ? /* @__PURE__ */ x("p", {
222
+ }) : V.length === 0 ? /* @__PURE__ */ b("p", {
237
223
  className: "text-sm text-text-secondary",
238
224
  children: D("healthybowl.consultant.farmerAdvisors.tasks.empty", "No tasks yet.")
239
- }) : /* @__PURE__ */ x("ul", {
225
+ }) : /* @__PURE__ */ b("ul", {
240
226
  className: "space-y-2",
241
- children: V.map((e) => /* @__PURE__ */ S("li", {
227
+ children: V.map((e) => /* @__PURE__ */ x("li", {
242
228
  className: "flex items-start justify-between gap-3 border-b border-border-subtle/50 pb-2 last:border-0 last:pb-0",
243
- children: [/* @__PURE__ */ S("div", {
229
+ children: [/* @__PURE__ */ x("div", {
244
230
  className: "min-w-0",
245
- children: [/* @__PURE__ */ x("p", {
231
+ children: [/* @__PURE__ */ b("p", {
246
232
  className: "text-sm font-medium text-text-primary",
247
233
  children: e.title
248
- }), e.detail && /* @__PURE__ */ x("p", {
234
+ }), e.detail && /* @__PURE__ */ b("p", {
249
235
  className: "text-xs text-text-secondary",
250
236
  children: e.detail
251
237
  })]
252
- }), /* @__PURE__ */ x(n, {
238
+ }), /* @__PURE__ */ b(n, {
253
239
  label: e.status,
254
240
  variant: e.status.toUpperCase() === "DONE" ? "success" : e.status.toUpperCase() === "IN_PROGRESS" ? "warning" : "default"
255
241
  })]
256
242
  }, e.id))
257
243
  })]
258
244
  }),
259
- /* @__PURE__ */ x(o, {
245
+ /* @__PURE__ */ b(o, {
260
246
  open: H,
261
247
  onClose: () => U(!1),
262
248
  title: D("healthybowl.consultant.farmerAdvisors.modal.title", "Assign a Consultant"),
263
249
  description: D("healthybowl.consultant.farmerAdvisors.modal.description", "Give an agricultural consultant scoped access to your farm. They never join your workspace, and you can revoke anytime."),
264
- footer: /* @__PURE__ */ S(b, { children: [/* @__PURE__ */ x(C, {
250
+ footer: /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ b(S, {
265
251
  variant: "outline",
266
252
  onClick: () => U(!1),
267
253
  className: "text-text-secondary",
268
254
  children: D("healthybowl.common.cancel", "Cancel")
269
- }), /* @__PURE__ */ x(C, {
270
- onClick: ae,
255
+ }), /* @__PURE__ */ b(S, {
256
+ onClick: oe,
271
257
  disabled: W,
272
258
  children: W ? D("healthybowl.consultant.farmerAdvisors.modal.assigning", "Assigning…") : D("healthybowl.consultant.farmerAdvisors.modal.assign", "Assign")
273
259
  })] }),
274
- children: /* @__PURE__ */ S("div", {
260
+ children: /* @__PURE__ */ x("div", {
275
261
  className: "grid gap-4",
276
262
  children: [
277
- /* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("label", {
263
+ /* @__PURE__ */ x("div", { children: [/* @__PURE__ */ b("label", {
278
264
  className: "text-sm font-medium text-text-primary",
279
265
  children: D("healthybowl.consultant.farmerAdvisors.form.fields.actorId.label", "Consultant Actor ID *")
280
- }), /* @__PURE__ */ x("input", {
266
+ }), /* @__PURE__ */ b("input", {
281
267
  value: J,
282
268
  onChange: (e) => Y(e.target.value),
283
269
  placeholder: D("healthybowl.consultant.farmerAdvisors.form.fields.actorId.placeholder", "The consultant’s platform user id"),
284
270
  className: "mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 font-mono text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]"
285
271
  })] }),
286
- /* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("label", {
272
+ /* @__PURE__ */ x("div", { children: [/* @__PURE__ */ b("label", {
287
273
  className: "text-sm font-medium text-text-primary",
288
274
  children: D("healthybowl.consultant.farmerAdvisors.form.fields.name.label", "Consultant Name")
289
- }), /* @__PURE__ */ x("input", {
275
+ }), /* @__PURE__ */ b("input", {
290
276
  value: X,
291
277
  onChange: (e) => Z(e.target.value),
292
278
  placeholder: D("healthybowl.consultant.farmerAdvisors.form.fields.name.placeholder", "e.g., Dr. Priya Sharma"),
293
279
  className: "mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]"
294
280
  })] }),
295
- /* @__PURE__ */ S("div", { children: [
296
- /* @__PURE__ */ x("label", {
281
+ /* @__PURE__ */ x("div", { children: [
282
+ /* @__PURE__ */ b("label", {
297
283
  className: "text-sm font-medium text-text-primary",
298
284
  children: D("healthybowl.consultant.farmerAdvisors.form.fields.scope.label", "Access level")
299
285
  }),
300
- /* @__PURE__ */ S(te, {
286
+ /* @__PURE__ */ x(ne, {
301
287
  value: Q,
302
288
  onValueChange: $,
303
- children: [/* @__PURE__ */ x(re, {
289
+ children: [/* @__PURE__ */ b(ie, {
304
290
  className: "mt-1 w-full",
305
- children: /* @__PURE__ */ x(ie, {})
306
- }), /* @__PURE__ */ S(ne, { children: [/* @__PURE__ */ x(w, {
291
+ children: /* @__PURE__ */ b(ae, {})
292
+ }), /* @__PURE__ */ x(re, { children: [/* @__PURE__ */ b(w, {
307
293
  value: "FULL_ADVISORY",
308
294
  children: D("healthybowl.consultant.farmerAdvisors.form.fields.scope.options.fullAdvisory", "Full advisory — can diagnose and write recommendations & tasks")
309
- }), /* @__PURE__ */ x(w, {
295
+ }), /* @__PURE__ */ b(w, {
310
296
  value: "FARM_DIAGNOSIS",
311
297
  children: D("healthybowl.consultant.farmerAdvisors.form.fields.scope.options.farmDiagnosis", "Diagnosis only — read-only, cannot write back")
312
298
  })] })]
313
299
  }),
314
- /* @__PURE__ */ x("p", {
300
+ /* @__PURE__ */ b("p", {
315
301
  className: "mt-1 text-xs text-text-secondary",
316
302
  children: D("healthybowl.consultant.farmerAdvisors.form.fields.scope.helperText", "You can revoke either level at any time. Diagnosis-only consultants cannot leave recommendations.")
317
303
  })
@@ -319,7 +305,7 @@ var T = (e) => e.length > 14 ? `${e.slice(0, 10)}…` : e, E = (e) => {
319
305
  ]
320
306
  })
321
307
  }),
322
- /* @__PURE__ */ x(i, {
308
+ /* @__PURE__ */ b(i, {
323
309
  toasts: k,
324
310
  onDismiss: j
325
311
  })
@@ -1 +1 @@
1
- {"version":3,"file":"FarmerAdvisorsPage.js","names":[],"sources":["../../../../src/healthybowl/pages/consultant/FarmerAdvisorsPage.tsx"],"sourcesContent":["import { useState, type FC } from 'react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { Button, Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from '@burdenoff/fe-libs/ui';\nimport { UserCheck, Plus, Trash2, ClipboardList, CheckCircle2, AlertCircle } from 'lucide-react';\nimport { PageLayout, StatusBadge, EmptyState, Modal, useConfirm } from '../../components';\nimport { ToastContainer } from '../../components/Toast';\nimport { useToast } from '../../hooks/useToast';\nimport { useHealthyBowl } from '../../context/HealthyBowlContext';\nimport {\n useGetHealthyBowlConsultantAssignmentsQuery,\n useGetHealthyBowlMyFarmRecommendationsQuery,\n useGetHealthyBowlMyAdvisoryTasksQuery,\n useAssignHealthyBowlConsultantMutation,\n useRevokeHealthyBowlConsultantAssignmentMutation,\n} from '../../../generated/wspace-operations';\n\n/**\n * UC-16 — farmer side: manage advisors + see advisory output.\n *\n * The farmer assigns an agricultural consultant scoped access to their farm\n * (revocable anytime), and sees the recommendations + tasks the consultant has\n * written back. The consultant never becomes a workspace member.\n */\n\ninterface Assignment {\n id: string;\n consultantActorId: string;\n consultantName?: string | null;\n scope: string;\n status: string;\n assignedAt: string;\n expiresAt?: string | null;\n}\ninterface Recommendation {\n id: string;\n domain: string;\n title: string;\n detail: string;\n priority: string;\n status: string;\n authorName?: string | null;\n createdAt: string;\n}\ninterface Task {\n id: string;\n title: string;\n detail?: string | null;\n status: string;\n authorName?: string | null;\n createdAt: string;\n}\n\nconst shortActor = (id: string): string => (id.length > 14 ? `${id.slice(0, 10)}…` : id);\n\nconst priorityVariant = (p: string): 'success' | 'warning' | 'error' | 'default' => {\n switch (p.toUpperCase()) {\n case 'URGENT':\n case 'HIGH':\n return 'error';\n case 'MEDIUM':\n return 'warning';\n default:\n return 'default';\n }\n};\n\nexport const FarmerAdvisorsPage: FC = () => {\n const { t } = useI18n();\n const { workspaceId } = useHealthyBowl();\n const { toasts, toast, dismiss } = useToast();\n const confirm = useConfirm();\n\n const ctxVars = {\n variables: { context: { workspaceId } },\n skip: !workspaceId,\n fetchPolicy: 'cache-and-network' as const,\n };\n const assignmentsQuery = useGetHealthyBowlConsultantAssignmentsQuery(ctxVars);\n const recsQuery = useGetHealthyBowlMyFarmRecommendationsQuery(ctxVars);\n const tasksQuery = useGetHealthyBowlMyAdvisoryTasksQuery(ctxVars);\n const [assign] = useAssignHealthyBowlConsultantMutation();\n const [revoke] = useRevokeHealthyBowlConsultantAssignmentMutation();\n\n const assignments: Assignment[] = assignmentsQuery.data?.getHealthyBowlConsultantAssignments ?? [];\n const active = assignments.filter((a) => a.status.toUpperCase() === 'ACTIVE');\n const recommendations: Recommendation[] = recsQuery.data?.getHealthyBowlMyFarmRecommendations ?? [];\n const tasks: Task[] = tasksQuery.data?.getHealthyBowlMyAdvisoryTasks ?? [];\n\n const [showAssign, setShowAssign] = useState(false);\n const [submitting, setSubmitting] = useState(false);\n const [revokingId, setRevokingId] = useState<string | null>(null);\n const [consultantActorId, setConsultantActorId] = useState('');\n const [consultantName, setConsultantName] = useState('');\n const [scope, setScope] = useState('FULL_ADVISORY');\n\n const handleAssign = async () => {\n if (!consultantActorId.trim()) {\n toast({\n title: t('healthybowl.consultant.farmerAdvisors.toast.idRequired.title', 'Consultant ID required'),\n description: t(\n 'healthybowl.consultant.farmerAdvisors.toast.idRequired.description',\n 'Enter the consultant’s actor id.'\n ),\n variant: 'warning',\n });\n return;\n }\n setSubmitting(true);\n try {\n await assign({\n variables: {\n input: {\n consultantActorId: consultantActorId.trim(),\n consultantName: consultantName.trim() || null,\n scope,\n context: { workspaceId },\n },\n },\n });\n toast({\n title: t('healthybowl.consultant.farmerAdvisors.toast.assigned.title', 'Consultant assigned'),\n description: t(\n 'healthybowl.consultant.farmerAdvisors.toast.assigned.description',\n 'They can now diagnose and advise your farm.'\n ),\n variant: 'success',\n });\n setShowAssign(false);\n setConsultantActorId('');\n setConsultantName('');\n setScope('FULL_ADVISORY');\n await assignmentsQuery.refetch();\n } catch {\n toast({\n title: t('healthybowl.consultant.farmerAdvisors.toast.assignFailed.title', 'Assign failed'),\n description: t(\n 'healthybowl.consultant.farmerAdvisors.toast.assignFailed.description',\n 'Could not assign the consultant. Please try again.'\n ),\n variant: 'error',\n });\n } finally {\n setSubmitting(false);\n }\n };\n\n const handleRevoke = async (a: Assignment) => {\n if (\n !(await confirm({\n message: t(\n 'healthybowl.consultant.farmerAdvisors.revokeConfirm',\n 'Revoke {{name}}’s access to your farm? They will immediately lose access.',\n {\n name: a.consultantName || t('healthybowl.consultant.farmerAdvisors.thisConsultant', 'this consultant'),\n }\n ),\n }))\n ) {\n return;\n }\n setRevokingId(a.id);\n try {\n await revoke({ variables: { id: a.id, context: { workspaceId } } });\n toast({\n title: t('healthybowl.consultant.farmerAdvisors.toast.revoked.title', 'Access revoked'),\n description: t(\n 'healthybowl.consultant.farmerAdvisors.toast.revoked.description',\n '{{name}} can no longer see your farm.',\n { name: a.consultantName || t('healthybowl.consultant.farmerAdvisors.consultant', 'Consultant') }\n ),\n variant: 'success',\n });\n await assignmentsQuery.refetch();\n } catch {\n toast({\n title: t('healthybowl.consultant.farmerAdvisors.toast.revokeFailed.title', 'Revoke failed'),\n description: t(\n 'healthybowl.consultant.farmerAdvisors.toast.revokeFailed.description',\n 'Could not revoke access. Please try again.'\n ),\n variant: 'error',\n });\n } finally {\n setRevokingId(null);\n }\n };\n\n return (\n <PageLayout\n title={t('healthybowl.consultant.farmerAdvisors.title', 'My Advisors')}\n description={t(\n 'healthybowl.consultant.farmerAdvisors.description',\n 'Assign an agricultural consultant to advise your farm, and see their recommendations — revoke access anytime'\n )}\n actions={\n <Button onClick={() => setShowAssign(true)}>\n <Plus className=\"h-4 w-4\" />{' '}\n {t('healthybowl.consultant.farmerAdvisors.actions.assignConsultant', 'Assign Consultant')}\n </Button>\n }\n >\n {/* Assigned consultants */}\n {assignmentsQuery.loading && active.length === 0 ? (\n <p className=\"text-sm text-text-secondary\">\n {t('healthybowl.consultant.farmerAdvisors.loading', 'Loading your advisors…')}\n </p>\n ) : assignmentsQuery.error && active.length === 0 ? (\n <div className=\"flex items-center gap-2 rounded-lg border border-border-subtle bg-bg-surface p-5 text-sm text-text-secondary\">\n <AlertCircle className=\"h-4 w-4\" />{' '}\n {t('healthybowl.consultant.farmerAdvisors.loadError', 'Advisor info isn’t available right now.')}\n </div>\n ) : active.length === 0 ? (\n <EmptyState\n title={t('healthybowl.consultant.farmerAdvisors.emptyState.title', 'No consultant assigned')}\n description={t(\n 'healthybowl.consultant.farmerAdvisors.emptyState.description',\n 'Assign an agricultural consultant to get expert diagnosis and advice on your farm.'\n )}\n icon={<UserCheck className=\"h-12 w-12 text-text-secondary\" />}\n />\n ) : (\n <div className=\"overflow-hidden rounded-lg border border-border-subtle bg-bg-surface\">\n <table className=\"w-full text-sm\">\n <thead>\n <tr className=\"border-b border-border-subtle text-left text-xs text-text-secondary\">\n <th className=\"px-4 py-3 font-medium\">\n {t('healthybowl.consultant.farmerAdvisors.table.headers.consultant', 'Consultant')}\n </th>\n <th className=\"px-4 py-3 font-medium\">\n {t('healthybowl.consultant.farmerAdvisors.table.headers.scope', 'Scope')}\n </th>\n <th className=\"px-4 py-3 font-medium\">\n {t('healthybowl.consultant.farmerAdvisors.table.headers.status', 'Status')}\n </th>\n <th className=\"px-4 py-3 text-right font-medium\">\n {t('healthybowl.consultant.farmerAdvisors.table.headers.action', 'Action')}\n </th>\n </tr>\n </thead>\n <tbody>\n {active.map((a) => (\n <tr key={a.id} className=\"border-b border-border-subtle/50 last:border-0\">\n <td className=\"px-4 py-3\">\n <p className=\"font-medium text-text-primary\">\n {a.consultantName ||\n t('healthybowl.consultant.farmerAdvisors.unnamedConsultant', 'Unnamed consultant')}\n </p>\n <p className=\"font-mono text-xs text-text-secondary\" title={a.consultantActorId}>\n {shortActor(a.consultantActorId)}\n </p>\n </td>\n <td className=\"px-4 py-3 text-text-secondary\">{a.scope.replace(/_/g, ' ').toLowerCase()}</td>\n <td className=\"px-4 py-3\">\n <StatusBadge label={a.status} variant=\"success\" dot />\n </td>\n <td className=\"px-4 py-3 text-right\">\n <Button\n variant=\"destructive\"\n size=\"sm\"\n onClick={() => handleRevoke(a)}\n disabled={revokingId === a.id}\n >\n <Trash2 className=\"h-3.5 w-3.5\" />{' '}\n {revokingId === a.id\n ? t('healthybowl.consultant.farmerAdvisors.actions.revoking', 'Revoking…')\n : t('healthybowl.consultant.farmerAdvisors.actions.revoke', 'Revoke')}\n </Button>\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n )}\n\n {/* Recommendations from consultants */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-5\">\n <h3 className=\"mb-3 flex items-center gap-2 text-sm font-semibold text-text-primary\">\n <ClipboardList className=\"h-4 w-4 text-text-secondary\" />{' '}\n {t('healthybowl.consultant.farmerAdvisors.recommendations.heading', 'Recommendations for your farm')}\n </h3>\n {recsQuery.error && recommendations.length === 0 ? (\n <p className=\"text-sm text-text-secondary\">\n {t(\n 'healthybowl.consultant.farmerAdvisors.recommendations.loadError',\n 'Recommendations couldn’t be loaded.'\n )}\n </p>\n ) : recommendations.length === 0 ? (\n <p className=\"text-sm text-text-secondary\">\n {t('healthybowl.consultant.farmerAdvisors.recommendations.empty', 'No recommendations yet.')}\n </p>\n ) : (\n <ul className=\"space-y-2\">\n {recommendations.map((r) => (\n <li\n key={r.id}\n className=\"flex items-start justify-between gap-3 border-b border-border-subtle/50 pb-2 last:border-0 last:pb-0\"\n >\n <div className=\"min-w-0\">\n <p className=\"text-sm font-medium text-text-primary\">{r.title}</p>\n <p className=\"text-xs text-text-secondary\">{r.detail}</p>\n {r.authorName && <p className=\"text-xs text-text-secondary/80\">— {r.authorName}</p>}\n </div>\n <div className=\"flex shrink-0 items-center gap-2\">\n <StatusBadge label={r.domain} variant=\"default\" />\n <StatusBadge label={r.priority} variant={priorityVariant(r.priority)} />\n </div>\n </li>\n ))}\n </ul>\n )}\n </div>\n\n {/* Tasks from consultants */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-5\">\n <h3 className=\"mb-3 flex items-center gap-2 text-sm font-semibold text-text-primary\">\n <CheckCircle2 className=\"h-4 w-4 text-text-secondary\" />{' '}\n {t('healthybowl.consultant.farmerAdvisors.tasks.heading', 'Tasks from your consultant')}\n </h3>\n {tasksQuery.error && tasks.length === 0 ? (\n <p className=\"text-sm text-text-secondary\">\n {t('healthybowl.consultant.farmerAdvisors.tasks.loadError', 'Tasks couldn’t be loaded.')}\n </p>\n ) : tasks.length === 0 ? (\n <p className=\"text-sm text-text-secondary\">\n {t('healthybowl.consultant.farmerAdvisors.tasks.empty', 'No tasks yet.')}\n </p>\n ) : (\n <ul className=\"space-y-2\">\n {tasks.map((t) => (\n <li\n key={t.id}\n className=\"flex items-start justify-between gap-3 border-b border-border-subtle/50 pb-2 last:border-0 last:pb-0\"\n >\n <div className=\"min-w-0\">\n <p className=\"text-sm font-medium text-text-primary\">{t.title}</p>\n {t.detail && <p className=\"text-xs text-text-secondary\">{t.detail}</p>}\n </div>\n <StatusBadge\n label={t.status}\n variant={\n t.status.toUpperCase() === 'DONE'\n ? 'success'\n : t.status.toUpperCase() === 'IN_PROGRESS'\n ? 'warning'\n : 'default'\n }\n />\n </li>\n ))}\n </ul>\n )}\n </div>\n\n {/* Assign modal */}\n <Modal\n open={showAssign}\n onClose={() => setShowAssign(false)}\n title={t('healthybowl.consultant.farmerAdvisors.modal.title', 'Assign a Consultant')}\n description={t(\n 'healthybowl.consultant.farmerAdvisors.modal.description',\n 'Give an agricultural consultant scoped access to your farm. They never join your workspace, and you can revoke anytime.'\n )}\n footer={\n <>\n <Button variant=\"outline\" onClick={() => setShowAssign(false)} className=\"text-text-secondary\">\n {t('healthybowl.common.cancel', 'Cancel')}\n </Button>\n <Button onClick={handleAssign} disabled={submitting}>\n {submitting\n ? t('healthybowl.consultant.farmerAdvisors.modal.assigning', 'Assigning…')\n : t('healthybowl.consultant.farmerAdvisors.modal.assign', 'Assign')}\n </Button>\n </>\n }\n >\n <div className=\"grid gap-4\">\n <div>\n <label className=\"text-sm font-medium text-text-primary\">\n {t('healthybowl.consultant.farmerAdvisors.form.fields.actorId.label', 'Consultant Actor ID *')}\n </label>\n <input\n value={consultantActorId}\n onChange={(e) => setConsultantActorId(e.target.value)}\n placeholder={t(\n 'healthybowl.consultant.farmerAdvisors.form.fields.actorId.placeholder',\n 'The consultant’s platform user id'\n )}\n className=\"mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 font-mono text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]\"\n />\n </div>\n <div>\n <label className=\"text-sm font-medium text-text-primary\">\n {t('healthybowl.consultant.farmerAdvisors.form.fields.name.label', 'Consultant Name')}\n </label>\n <input\n value={consultantName}\n onChange={(e) => setConsultantName(e.target.value)}\n placeholder={t(\n 'healthybowl.consultant.farmerAdvisors.form.fields.name.placeholder',\n 'e.g., Dr. Priya Sharma'\n )}\n className=\"mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]\"\n />\n </div>\n <div>\n <label className=\"text-sm font-medium text-text-primary\">\n {t('healthybowl.consultant.farmerAdvisors.form.fields.scope.label', 'Access level')}\n </label>\n <Select value={scope} onValueChange={setScope}>\n <SelectTrigger className=\"mt-1 w-full\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value=\"FULL_ADVISORY\">\n {t(\n 'healthybowl.consultant.farmerAdvisors.form.fields.scope.options.fullAdvisory',\n 'Full advisory — can diagnose and write recommendations & tasks'\n )}\n </SelectItem>\n <SelectItem value=\"FARM_DIAGNOSIS\">\n {t(\n 'healthybowl.consultant.farmerAdvisors.form.fields.scope.options.farmDiagnosis',\n 'Diagnosis only — read-only, cannot write back'\n )}\n </SelectItem>\n </SelectContent>\n </Select>\n <p className=\"mt-1 text-xs text-text-secondary\">\n {t(\n 'healthybowl.consultant.farmerAdvisors.form.fields.scope.helperText',\n 'You can revoke either level at any time. Diagnosis-only consultants cannot leave recommendations.'\n )}\n </p>\n </div>\n </div>\n </Modal>\n\n <ToastContainer toasts={toasts} onDismiss={dismiss} />\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAoDA,IAAM,KAAc,MAAwB,EAAG,SAAS,KAAK,GAAG,EAAG,MAAM,GAAG,GAAG,CAAC,KAAK,GAE/E,KAAmB,MAA2D;AAClF,SAAQ,EAAE,aAAa,EAAvB;EACE,KAAK;EACL,KAAK,OACH,QAAO;EACT,KAAK,SACH,QAAO;EACT,QACE,QAAO;;GAIA,UAA+B;CAC1C,IAAM,EAAE,SAAM,GAAS,EACjB,EAAE,mBAAgB,GAAgB,EAClC,EAAE,WAAQ,UAAO,eAAY,GAAU,EACvC,IAAU,GAAY,EAEtB,IAAU;EACd,WAAW,EAAE,SAAS,EAAE,gBAAa,EAAE;EACvC,MAAM,CAAC;EACP,aAAa;EACd,EACK,IAAmB,EAA4C,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,EACR,kBAAC,SAAD;OACE,OAAO;OACP,WAAW,MAAM,EAAkB,EAAE,OAAO,MAAM;OAClD,aAAa,EACX,sEACA,yBACD;OACD,WAAU;OACV,CAAA,CACE,EAAA,CAAA;MACN,kBAAC,OAAD,EAAA,UAAA;OACE,kBAAC,SAAD;QAAO,WAAU;kBACd,EAAE,iEAAiE,eAAe;QAC7E,CAAA;OACR,kBAAC,IAAD;QAAQ,OAAO;QAAO,eAAe;kBAArC,CACE,kBAAC,IAAD;SAAe,WAAU;mBACvB,kBAAC,IAAD,EAAe,CAAA;SACD,CAAA,EAChB,kBAAC,IAAD,EAAA,UAAA,CACE,kBAAC,GAAD;SAAY,OAAM;mBACf,EACC,gFACA,iEACD;SACU,CAAA,EACb,kBAAC,GAAD;SAAY,OAAM;mBACf,EACC,iFACA,gDACD;SACU,CAAA,CACC,EAAA,CAAA,CACT;;OACT,kBAAC,KAAD;QAAG,WAAU;kBACV,EACC,sEACA,oGACD;QACC,CAAA;OACA,EAAA,CAAA;MACF;;IACA,CAAA;GAER,kBAAC,GAAD;IAAwB;IAAQ,WAAW;IAAW,CAAA;GAC3C"}
1
+ {"version":3,"file":"FarmerAdvisorsPage.js","names":[],"sources":["../../../../src/healthybowl/pages/consultant/FarmerAdvisorsPage.tsx"],"sourcesContent":["import { useState, type FC } from 'react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport {\n Button,\n Select,\n SelectTrigger,\n SelectValue,\n SelectContent,\n SelectItem,\n ResponsiveTable,\n type ResponsiveTableColumn,\n} from '@burdenoff/fe-libs/ui';\nimport { UserCheck, Plus, Trash2, ClipboardList, CheckCircle2, AlertCircle } from 'lucide-react';\nimport { PageLayout, StatusBadge, EmptyState, Modal, useConfirm } from '../../components';\nimport { ToastContainer } from '../../components/Toast';\nimport { useToast } from '../../hooks/useToast';\nimport { useHealthyBowl } from '../../context/HealthyBowlContext';\nimport {\n useGetHealthyBowlConsultantAssignmentsQuery,\n useGetHealthyBowlMyFarmRecommendationsQuery,\n useGetHealthyBowlMyAdvisoryTasksQuery,\n useAssignHealthyBowlConsultantMutation,\n useRevokeHealthyBowlConsultantAssignmentMutation,\n} from '../../../generated/wspace-operations';\n\n/**\n * UC-16 — farmer side: manage advisors + see advisory output.\n *\n * The farmer assigns an agricultural consultant scoped access to their farm\n * (revocable anytime), and sees the recommendations + tasks the consultant has\n * written back. The consultant never becomes a workspace member.\n */\n\ninterface Assignment {\n id: string;\n consultantActorId: string;\n consultantName?: string | null;\n scope: string;\n status: string;\n assignedAt: string;\n expiresAt?: string | null;\n}\ninterface Recommendation {\n id: string;\n domain: string;\n title: string;\n detail: string;\n priority: string;\n status: string;\n authorName?: string | null;\n createdAt: string;\n}\ninterface Task {\n id: string;\n title: string;\n detail?: string | null;\n status: string;\n authorName?: string | null;\n createdAt: string;\n}\n\nconst shortActor = (id: string): string => (id.length > 14 ? `${id.slice(0, 10)}…` : id);\n\nconst priorityVariant = (p: string): 'success' | 'warning' | 'error' | 'default' => {\n switch (p.toUpperCase()) {\n case 'URGENT':\n case 'HIGH':\n return 'error';\n case 'MEDIUM':\n return 'warning';\n default:\n return 'default';\n }\n};\n\nexport const FarmerAdvisorsPage: FC = () => {\n const { t } = useI18n();\n const { workspaceId } = useHealthyBowl();\n const { toasts, toast, dismiss } = useToast();\n const confirm = useConfirm();\n\n const ctxVars = {\n variables: { context: { workspaceId } },\n skip: !workspaceId,\n fetchPolicy: 'cache-and-network' as const,\n };\n const assignmentsQuery = useGetHealthyBowlConsultantAssignmentsQuery(ctxVars);\n const recsQuery = useGetHealthyBowlMyFarmRecommendationsQuery(ctxVars);\n const tasksQuery = useGetHealthyBowlMyAdvisoryTasksQuery(ctxVars);\n const [assign] = useAssignHealthyBowlConsultantMutation();\n const [revoke] = useRevokeHealthyBowlConsultantAssignmentMutation();\n\n const assignments: Assignment[] = assignmentsQuery.data?.getHealthyBowlConsultantAssignments ?? [];\n const active = assignments.filter((a) => a.status.toUpperCase() === 'ACTIVE');\n const recommendations: Recommendation[] = recsQuery.data?.getHealthyBowlMyFarmRecommendations ?? [];\n const tasks: Task[] = tasksQuery.data?.getHealthyBowlMyAdvisoryTasks ?? [];\n\n const [showAssign, setShowAssign] = useState(false);\n const [submitting, setSubmitting] = useState(false);\n const [revokingId, setRevokingId] = useState<string | null>(null);\n const [consultantActorId, setConsultantActorId] = useState('');\n const [consultantName, setConsultantName] = useState('');\n const [scope, setScope] = useState('FULL_ADVISORY');\n\n const handleAssign = async () => {\n if (!consultantActorId.trim()) {\n toast({\n title: t('healthybowl.consultant.farmerAdvisors.toast.idRequired.title', 'Consultant ID required'),\n description: t(\n 'healthybowl.consultant.farmerAdvisors.toast.idRequired.description',\n 'Enter the consultant’s actor id.'\n ),\n variant: 'warning',\n });\n return;\n }\n setSubmitting(true);\n try {\n await assign({\n variables: {\n input: {\n consultantActorId: consultantActorId.trim(),\n consultantName: consultantName.trim() || null,\n scope,\n context: { workspaceId },\n },\n },\n });\n toast({\n title: t('healthybowl.consultant.farmerAdvisors.toast.assigned.title', 'Consultant assigned'),\n description: t(\n 'healthybowl.consultant.farmerAdvisors.toast.assigned.description',\n 'They can now diagnose and advise your farm.'\n ),\n variant: 'success',\n });\n setShowAssign(false);\n setConsultantActorId('');\n setConsultantName('');\n setScope('FULL_ADVISORY');\n await assignmentsQuery.refetch();\n } catch {\n toast({\n title: t('healthybowl.consultant.farmerAdvisors.toast.assignFailed.title', 'Assign failed'),\n description: t(\n 'healthybowl.consultant.farmerAdvisors.toast.assignFailed.description',\n 'Could not assign the consultant. Please try again.'\n ),\n variant: 'error',\n });\n } finally {\n setSubmitting(false);\n }\n };\n\n const handleRevoke = async (a: Assignment) => {\n if (\n !(await confirm({\n message: t(\n 'healthybowl.consultant.farmerAdvisors.revokeConfirm',\n 'Revoke {{name}}’s access to your farm? They will immediately lose access.',\n {\n name: a.consultantName || t('healthybowl.consultant.farmerAdvisors.thisConsultant', 'this consultant'),\n }\n ),\n }))\n ) {\n return;\n }\n setRevokingId(a.id);\n try {\n await revoke({ variables: { id: a.id, context: { workspaceId } } });\n toast({\n title: t('healthybowl.consultant.farmerAdvisors.toast.revoked.title', 'Access revoked'),\n description: t(\n 'healthybowl.consultant.farmerAdvisors.toast.revoked.description',\n '{{name}} can no longer see your farm.',\n { name: a.consultantName || t('healthybowl.consultant.farmerAdvisors.consultant', 'Consultant') }\n ),\n variant: 'success',\n });\n await assignmentsQuery.refetch();\n } catch {\n toast({\n title: t('healthybowl.consultant.farmerAdvisors.toast.revokeFailed.title', 'Revoke failed'),\n description: t(\n 'healthybowl.consultant.farmerAdvisors.toast.revokeFailed.description',\n 'Could not revoke access. Please try again.'\n ),\n variant: 'error',\n });\n } finally {\n setRevokingId(null);\n }\n };\n\n const assignmentColumns: ResponsiveTableColumn<Assignment>[] = [\n {\n key: 'consultant',\n header: t('healthybowl.consultant.farmerAdvisors.table.headers.consultant', 'Consultant'),\n priority: 'primary',\n cell: (a) => (\n <>\n <p className=\"font-medium text-text-primary\">\n {a.consultantName || t('healthybowl.consultant.farmerAdvisors.unnamedConsultant', 'Unnamed consultant')}\n </p>\n <p className=\"font-mono text-xs text-text-secondary\" title={a.consultantActorId}>\n {shortActor(a.consultantActorId)}\n </p>\n </>\n ),\n },\n {\n key: 'scope',\n header: t('healthybowl.consultant.farmerAdvisors.table.headers.scope', 'Scope'),\n priority: 'secondary',\n cellClassName: 'text-text-secondary',\n cell: (a) => a.scope.replace(/_/g, ' ').toLowerCase(),\n },\n {\n key: 'status',\n header: t('healthybowl.consultant.farmerAdvisors.table.headers.status', 'Status'),\n priority: 'secondary',\n cell: (a) => <StatusBadge label={a.status} variant=\"success\" dot />,\n },\n {\n key: 'action',\n header: t('healthybowl.consultant.farmerAdvisors.table.headers.action', 'Action'),\n priority: 'secondary',\n headerClassName: 'text-right',\n cellClassName: 'text-right',\n cell: (a) => (\n <Button variant=\"destructive\" size=\"sm\" onClick={() => handleRevoke(a)} disabled={revokingId === a.id}>\n <Trash2 className=\"h-3.5 w-3.5\" />{' '}\n {revokingId === a.id\n ? t('healthybowl.consultant.farmerAdvisors.actions.revoking', 'Revoking…')\n : t('healthybowl.consultant.farmerAdvisors.actions.revoke', 'Revoke')}\n </Button>\n ),\n },\n ];\n\n return (\n <PageLayout\n title={t('healthybowl.consultant.farmerAdvisors.title', 'My Advisors')}\n description={t(\n 'healthybowl.consultant.farmerAdvisors.description',\n 'Assign an agricultural consultant to advise your farm, and see their recommendations — revoke access anytime'\n )}\n actions={\n <Button onClick={() => setShowAssign(true)}>\n <Plus className=\"h-4 w-4\" />{' '}\n {t('healthybowl.consultant.farmerAdvisors.actions.assignConsultant', 'Assign Consultant')}\n </Button>\n }\n >\n {/* Assigned consultants */}\n {assignmentsQuery.loading && active.length === 0 ? (\n <p className=\"text-sm text-text-secondary\">\n {t('healthybowl.consultant.farmerAdvisors.loading', 'Loading your advisors…')}\n </p>\n ) : assignmentsQuery.error && active.length === 0 ? (\n <div className=\"flex items-center gap-2 rounded-lg border border-border-subtle bg-bg-surface p-5 text-sm text-text-secondary\">\n <AlertCircle className=\"h-4 w-4\" />{' '}\n {t('healthybowl.consultant.farmerAdvisors.loadError', 'Advisor info isn’t available right now.')}\n </div>\n ) : active.length === 0 ? (\n <EmptyState\n title={t('healthybowl.consultant.farmerAdvisors.emptyState.title', 'No consultant assigned')}\n description={t(\n 'healthybowl.consultant.farmerAdvisors.emptyState.description',\n 'Assign an agricultural consultant to get expert diagnosis and advice on your farm.'\n )}\n icon={<UserCheck className=\"h-12 w-12 text-text-secondary\" />}\n />\n ) : (\n <ResponsiveTable<Assignment> columns={assignmentColumns} data={active} rowKey={(a) => String(a.id)} />\n )}\n\n {/* Recommendations from consultants */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-5\">\n <h3 className=\"mb-3 flex items-center gap-2 text-sm font-semibold text-text-primary\">\n <ClipboardList className=\"h-4 w-4 text-text-secondary\" />{' '}\n {t('healthybowl.consultant.farmerAdvisors.recommendations.heading', 'Recommendations for your farm')}\n </h3>\n {recsQuery.error && recommendations.length === 0 ? (\n <p className=\"text-sm text-text-secondary\">\n {t(\n 'healthybowl.consultant.farmerAdvisors.recommendations.loadError',\n 'Recommendations couldn’t be loaded.'\n )}\n </p>\n ) : recommendations.length === 0 ? (\n <p className=\"text-sm text-text-secondary\">\n {t('healthybowl.consultant.farmerAdvisors.recommendations.empty', 'No recommendations yet.')}\n </p>\n ) : (\n <ul className=\"space-y-2\">\n {recommendations.map((r) => (\n <li\n key={r.id}\n className=\"flex items-start justify-between gap-3 border-b border-border-subtle/50 pb-2 last:border-0 last:pb-0\"\n >\n <div className=\"min-w-0\">\n <p className=\"text-sm font-medium text-text-primary\">{r.title}</p>\n <p className=\"text-xs text-text-secondary\">{r.detail}</p>\n {r.authorName && <p className=\"text-xs text-text-secondary/80\">— {r.authorName}</p>}\n </div>\n <div className=\"flex shrink-0 items-center gap-2\">\n <StatusBadge label={r.domain} variant=\"default\" />\n <StatusBadge label={r.priority} variant={priorityVariant(r.priority)} />\n </div>\n </li>\n ))}\n </ul>\n )}\n </div>\n\n {/* Tasks from consultants */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-5\">\n <h3 className=\"mb-3 flex items-center gap-2 text-sm font-semibold text-text-primary\">\n <CheckCircle2 className=\"h-4 w-4 text-text-secondary\" />{' '}\n {t('healthybowl.consultant.farmerAdvisors.tasks.heading', 'Tasks from your consultant')}\n </h3>\n {tasksQuery.error && tasks.length === 0 ? (\n <p className=\"text-sm text-text-secondary\">\n {t('healthybowl.consultant.farmerAdvisors.tasks.loadError', 'Tasks couldn’t be loaded.')}\n </p>\n ) : tasks.length === 0 ? (\n <p className=\"text-sm text-text-secondary\">\n {t('healthybowl.consultant.farmerAdvisors.tasks.empty', 'No tasks yet.')}\n </p>\n ) : (\n <ul className=\"space-y-2\">\n {tasks.map((t) => (\n <li\n key={t.id}\n className=\"flex items-start justify-between gap-3 border-b border-border-subtle/50 pb-2 last:border-0 last:pb-0\"\n >\n <div className=\"min-w-0\">\n <p className=\"text-sm font-medium text-text-primary\">{t.title}</p>\n {t.detail && <p className=\"text-xs text-text-secondary\">{t.detail}</p>}\n </div>\n <StatusBadge\n label={t.status}\n variant={\n t.status.toUpperCase() === 'DONE'\n ? 'success'\n : t.status.toUpperCase() === 'IN_PROGRESS'\n ? 'warning'\n : 'default'\n }\n />\n </li>\n ))}\n </ul>\n )}\n </div>\n\n {/* Assign modal */}\n <Modal\n open={showAssign}\n onClose={() => setShowAssign(false)}\n title={t('healthybowl.consultant.farmerAdvisors.modal.title', 'Assign a Consultant')}\n description={t(\n 'healthybowl.consultant.farmerAdvisors.modal.description',\n 'Give an agricultural consultant scoped access to your farm. They never join your workspace, and you can revoke anytime.'\n )}\n footer={\n <>\n <Button variant=\"outline\" onClick={() => setShowAssign(false)} className=\"text-text-secondary\">\n {t('healthybowl.common.cancel', 'Cancel')}\n </Button>\n <Button onClick={handleAssign} disabled={submitting}>\n {submitting\n ? t('healthybowl.consultant.farmerAdvisors.modal.assigning', 'Assigning…')\n : t('healthybowl.consultant.farmerAdvisors.modal.assign', 'Assign')}\n </Button>\n </>\n }\n >\n <div className=\"grid gap-4\">\n <div>\n <label className=\"text-sm font-medium text-text-primary\">\n {t('healthybowl.consultant.farmerAdvisors.form.fields.actorId.label', 'Consultant Actor ID *')}\n </label>\n <input\n value={consultantActorId}\n onChange={(e) => setConsultantActorId(e.target.value)}\n placeholder={t(\n 'healthybowl.consultant.farmerAdvisors.form.fields.actorId.placeholder',\n 'The consultant’s platform user id'\n )}\n className=\"mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 font-mono text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]\"\n />\n </div>\n <div>\n <label className=\"text-sm font-medium text-text-primary\">\n {t('healthybowl.consultant.farmerAdvisors.form.fields.name.label', 'Consultant Name')}\n </label>\n <input\n value={consultantName}\n onChange={(e) => setConsultantName(e.target.value)}\n placeholder={t(\n 'healthybowl.consultant.farmerAdvisors.form.fields.name.placeholder',\n 'e.g., Dr. Priya Sharma'\n )}\n className=\"mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]\"\n />\n </div>\n <div>\n <label className=\"text-sm font-medium text-text-primary\">\n {t('healthybowl.consultant.farmerAdvisors.form.fields.scope.label', 'Access level')}\n </label>\n <Select value={scope} onValueChange={setScope}>\n <SelectTrigger className=\"mt-1 w-full\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value=\"FULL_ADVISORY\">\n {t(\n 'healthybowl.consultant.farmerAdvisors.form.fields.scope.options.fullAdvisory',\n 'Full advisory — can diagnose and write recommendations & tasks'\n )}\n </SelectItem>\n <SelectItem value=\"FARM_DIAGNOSIS\">\n {t(\n 'healthybowl.consultant.farmerAdvisors.form.fields.scope.options.farmDiagnosis',\n 'Diagnosis only — read-only, cannot write back'\n )}\n </SelectItem>\n </SelectContent>\n </Select>\n <p className=\"mt-1 text-xs text-text-secondary\">\n {t(\n 'healthybowl.consultant.farmerAdvisors.form.fields.scope.helperText',\n 'You can revoke either level at any time. Diagnosis-only consultants cannot leave recommendations.'\n )}\n </p>\n </div>\n </div>\n </Modal>\n\n <ToastContainer toasts={toasts} onDismiss={dismiss} />\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;AA6DA,IAAM,KAAc,MAAwB,EAAG,SAAS,KAAK,GAAG,EAAG,MAAM,GAAG,GAAG,CAAC,KAAK,GAE/E,KAAmB,MAA2D;AAClF,SAAQ,EAAE,aAAa,EAAvB;EACE,KAAK;EACL,KAAK,OACH,QAAO;EACT,KAAK,SACH,QAAO;EACT,QACE,QAAO;;GAIA,UAA+B;CAC1C,IAAM,EAAE,SAAM,GAAS,EACjB,EAAE,mBAAgB,GAAgB,EAClC,EAAE,WAAQ,UAAO,eAAY,GAAU,EACvC,IAAU,GAA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CAAA,CACE,EAAA,CAAA;MACN,kBAAC,OAAD,EAAA,UAAA;OACE,kBAAC,SAAD;QAAO,WAAU;kBACd,EAAE,iEAAiE,eAAe;QAC7E,CAAA;OACR,kBAAC,IAAD;QAAQ,OAAO;QAAO,eAAe;kBAArC,CACE,kBAAC,IAAD;SAAe,WAAU;mBACvB,kBAAC,IAAD,EAAe,CAAA;SACD,CAAA,EAChB,kBAAC,IAAD,EAAA,UAAA,CACE,kBAAC,GAAD;SAAY,OAAM;mBACf,EACC,gFACA,iEACD;SACU,CAAA,EACb,kBAAC,GAAD;SAAY,OAAM;mBACf,EACC,iFACA,gDACD;SACU,CAAA,CACC,EAAA,CAAA,CACT;;OACT,kBAAC,KAAD;QAAG,WAAU;kBACV,EACC,sEACA,oGACD;QACC,CAAA;OACA,EAAA,CAAA;MACF;;IACA,CAAA;GAER,kBAAC,GAAD;IAAwB;IAAQ,WAAW;IAAW,CAAA;GAC3C"}
@@ -120,7 +120,7 @@ var b = (e) => {
120
120
  ]
121
121
  }),
122
122
  /* @__PURE__ */ p(m, {
123
- variant: "ghost",
123
+ variant: "outline",
124
124
  size: "sm",
125
125
  onClick: () => O(k("crops/planning")),
126
126
  children: [