@burdenoff/microfe-healthybowl 2026.903.1 → 2026.903.2

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.
@@ -16,7 +16,10 @@ var o = "00000000-0000-0000-0000-000000000001", s = "\n status\n blocked\n en
16
16
  latestWeightKg
17
17
  latestWeightAt
18
18
  withdrawal { ${s} }
19
- `, u = "\n id\n animalId\n weightKg\n measuredAt\n method\n notes\n createdAt\n", d = `
19
+ `, u = `
20
+ ${l}
21
+ archived
22
+ `, d = "\n id\n animalId\n weightKg\n measuredAt\n method\n notes\n createdAt\n", f = `
20
23
  animalId
21
24
  tagNumber
22
25
  eidTag
@@ -29,17 +32,19 @@ var o = "00000000-0000-0000-0000-000000000001", s = "\n status\n blocked\n en
29
32
  bodyConditionScore
30
33
  damId
31
34
  damTag
35
+ damArchived
32
36
  sireId
33
37
  sireTag
38
+ sireArchived
34
39
  grazingPaddock
35
40
  rotationDate
36
41
  grazingNotes
37
42
  adgKgPerDay
38
43
  latestWeightKg
39
44
  latestWeightAt
40
- weightHistory { ${u} }
45
+ weightHistory { ${d} }
41
46
  withdrawal { ${s} }
42
- `, f = r`
47
+ `, p = r`
43
48
  query HealthyBowlHerdDepth($context: ContextInput!, $groupId: ID, $search: String) {
44
49
  healthyBowlHerdDepth(context: $context, groupId: $groupId, search: $search) {
45
50
  truncated
@@ -48,154 +53,205 @@ var o = "00000000-0000-0000-0000-000000000001", s = "\n status\n blocked\n en
48
53
  groups { ${c} }
49
54
  }
50
55
  }
51
- `, p = r`
56
+ `, m = r`
57
+ query HealthyBowlHerdDepthWithArchived(
58
+ $context: ContextInput!
59
+ $groupId: ID
60
+ $search: String
61
+ $includeArchived: Boolean
62
+ ) {
63
+ healthyBowlHerdDepth(context: $context, groupId: $groupId, search: $search, includeArchived: $includeArchived) {
64
+ truncated
65
+ rows { ${u} }
66
+ summary { totalAnimals animalsInWithdrawal animalsClear complianceMessage }
67
+ groups { ${c} }
68
+ }
69
+ }
70
+ `, h = "\n animalId tagNumber name type breed gender dateOfBirth generation relation archived childAnimalId\n", g = r`
71
+ query HealthyBowlAnimalPedigree($context: ContextInput!, $animalId: ID!, $ancestorDepth: Int, $offspringDepth: Int) {
72
+ healthyBowlAnimalPedigree(
73
+ context: $context
74
+ animalId: $animalId
75
+ ancestorDepth: $ancestorDepth
76
+ offspringDepth: $offspringDepth
77
+ ) {
78
+ root { ${h} }
79
+ ancestors { ${h} }
80
+ offspring { ${"\n animalId tagNumber name type gender dateOfBirth generation viaParent archived parentAnimalId parentAnimalIds\n"} }
81
+ truncated
82
+ cycleDetected
83
+ ancestorDepth
84
+ offspringDepth
85
+ }
86
+ }
87
+ `, _ = r`
52
88
  query HealthyBowlAnimalDepth($context: ContextInput!, $animalId: ID!) {
53
- healthyBowlAnimalDepth(context: $context, animalId: $animalId) { ${d} }
89
+ healthyBowlAnimalDepth(context: $context, animalId: $animalId) { ${f} }
54
90
  }
55
- `, m = r`
91
+ `, v = r`
56
92
  query HealthyBowlAnimalGroups($context: ContextInput!) {
57
93
  healthyBowlAnimalGroups(context: $context) { ${c} }
58
94
  }
59
- `, h = r`
95
+ `, y = r`
60
96
  mutation UpdateHealthyBowlAnimalDepth($input: UpdateHealthyBowlAnimalDepthInput!) {
61
- updateHealthyBowlAnimalDepth(input: $input) { ${d} }
97
+ updateHealthyBowlAnimalDepth(input: $input) { ${f} }
62
98
  }
63
- `, g = r`
99
+ `, b = r`
64
100
  mutation CreateHealthyBowlAnimalGroup($input: CreateHealthyBowlAnimalGroupInput!) {
65
101
  createHealthyBowlAnimalGroup(input: $input) { ${c} }
66
102
  }
67
- `, _ = r`
103
+ `, x = r`
68
104
  mutation UpdateHealthyBowlAnimalGroup($input: UpdateHealthyBowlAnimalGroupInput!) {
69
105
  updateHealthyBowlAnimalGroup(input: $input) { ${c} }
70
106
  }
71
- `, v = r`
107
+ `, S = r`
72
108
  mutation DeleteHealthyBowlAnimalGroup($id: ID!, $context: ContextInput!) {
73
109
  deleteHealthyBowlAnimalGroup(id: $id, context: $context)
74
110
  }
75
- `, y = r`
111
+ `, C = r`
76
112
  mutation RecordHealthyBowlAnimalWeight($input: RecordHealthyBowlAnimalWeightInput!) {
77
- recordHealthyBowlAnimalWeight(input: $input) { ${u} }
113
+ recordHealthyBowlAnimalWeight(input: $input) { ${d} }
78
114
  }
79
- `, b = r`
115
+ `, w = r`
80
116
  mutation DeleteHealthyBowlAnimalWeight($id: ID!, $context: ContextInput!) {
81
117
  deleteHealthyBowlAnimalWeight(id: $id, context: $context)
82
118
  }
83
119
  `;
84
- function x(r = {}) {
85
- let { workspaceId: s } = e(), c = s || o, l = n(() => ({ workspaceId: c }), [c]), u = r.herd === !0, d = r.groups === !0, x = r.animalId ?? null, S = a(f, {
86
- variables: {
120
+ function T(r = {}) {
121
+ let { workspaceId: s } = e(), c = s || o, l = n(() => ({ workspaceId: c }), [c]), u = r.herd === !0, d = r.groups === !0, f = r.animalId ?? null, h = r.herdGroupId ?? null, T = r.herdSearch ?? null, E = r.herdIncludeArchived ?? !1, D = a(E ? m : p, {
122
+ variables: E ? {
87
123
  context: l,
88
- groupId: r.herdGroupId ?? null,
89
- search: r.herdSearch ?? null
124
+ groupId: h,
125
+ search: T,
126
+ includeArchived: !0
127
+ } : {
128
+ context: l,
129
+ groupId: h,
130
+ search: T
90
131
  },
91
132
  fetchPolicy: "cache-and-network",
92
133
  skip: !u
93
- }), C = a(m, {
134
+ }), O = a(v, {
94
135
  variables: { context: l },
95
136
  fetchPolicy: "cache-and-network",
96
137
  skip: !d
97
- }), w = a(p, {
138
+ }), k = a(_, {
98
139
  variables: {
99
140
  context: l,
100
- animalId: x ?? ""
141
+ animalId: f ?? ""
101
142
  },
102
143
  fetchPolicy: "cache-and-network",
103
- skip: !x
104
- }), [T] = i(h), [E] = i(g), [D] = i(_), [O] = i(v), [k] = i(y), [A] = i(b), j = t(() => S.refetch(), [S]), M = t(() => C.refetch(), [C]), N = t(() => w.refetch(), [w]), P = t(async () => {
144
+ skip: !f
145
+ }), A = a(g, {
146
+ variables: {
147
+ context: l,
148
+ animalId: f ?? "",
149
+ ancestorDepth: r.pedigreeAncestorDepth ?? null,
150
+ offspringDepth: null
151
+ },
152
+ fetchPolicy: "cache-and-network",
153
+ skip: !f || r.pedigree !== !0
154
+ }), [j] = i(y), [M] = i(b), [N] = i(x), [P] = i(S), [F] = i(C), [I] = i(w), L = t(() => D.refetch(), [D]), R = t(() => O.refetch(), [O]), z = t(() => k.refetch(), [k]), B = t(() => A.refetch(), [A]), V = r.pedigree === !0, H = t(async () => {
105
155
  let e = [];
106
- u && e.push(j().catch(() => void 0)), d && e.push(M().catch(() => void 0)), x && e.push(N().catch(() => void 0)), await Promise.all(e);
156
+ u && e.push(L().catch(() => void 0)), d && e.push(R().catch(() => void 0)), f && e.push(z().catch(() => void 0)), f && V && e.push(B().catch(() => void 0)), await Promise.all(e);
107
157
  }, [
108
158
  u,
109
159
  d,
110
- x,
111
- j,
112
- M,
113
- N
114
- ]), F = t(async (e) => {
115
- let t = await T({ variables: { input: {
160
+ f,
161
+ V,
162
+ L,
163
+ R,
164
+ z,
165
+ B
166
+ ]), U = t(async (e) => {
167
+ let t = await j({ variables: { input: {
116
168
  ...e,
117
169
  context: l
118
170
  } } });
119
- return await P(), t.data?.updateHealthyBowlAnimalDepth;
171
+ return await H(), t.data?.updateHealthyBowlAnimalDepth;
120
172
  }, [
121
- T,
173
+ j,
122
174
  l,
123
- P
124
- ]), I = t(async (e) => {
125
- let t = await E({ variables: { input: {
175
+ H
176
+ ]), W = t(async (e) => {
177
+ let t = await M({ variables: { input: {
126
178
  ...e,
127
179
  context: l
128
180
  } } });
129
- return await P(), t.data?.createHealthyBowlAnimalGroup;
181
+ return await H(), t.data?.createHealthyBowlAnimalGroup;
130
182
  }, [
131
- E,
183
+ M,
132
184
  l,
133
- P
134
- ]), L = t(async (e) => {
135
- let t = await D({ variables: { input: {
185
+ H
186
+ ]), G = t(async (e) => {
187
+ let t = await N({ variables: { input: {
136
188
  ...e,
137
189
  context: l
138
190
  } } });
139
- return await P(), t.data?.updateHealthyBowlAnimalGroup;
191
+ return await H(), t.data?.updateHealthyBowlAnimalGroup;
140
192
  }, [
141
- D,
193
+ N,
142
194
  l,
143
- P
144
- ]), R = t(async (e) => {
145
- await O({ variables: {
195
+ H
196
+ ]), K = t(async (e) => {
197
+ await P({ variables: {
146
198
  id: e,
147
199
  context: l
148
- } }), await P();
200
+ } }), await H();
149
201
  }, [
150
- O,
202
+ P,
151
203
  l,
152
- P
153
- ]), z = t(async (e) => {
154
- let t = await k({ variables: { input: {
204
+ H
205
+ ]), q = t(async (e) => {
206
+ let t = await F({ variables: { input: {
155
207
  ...e,
156
208
  context: l
157
209
  } } });
158
- return await P(), t.data?.recordHealthyBowlAnimalWeight;
210
+ return await H(), t.data?.recordHealthyBowlAnimalWeight;
159
211
  }, [
160
- k,
212
+ F,
161
213
  l,
162
- P
163
- ]), B = t(async (e) => {
164
- await A({ variables: {
214
+ H
215
+ ]), J = t(async (e) => {
216
+ await I({ variables: {
165
217
  id: e,
166
218
  context: l
167
- } }), await P();
219
+ } }), await H();
168
220
  }, [
169
- A,
221
+ I,
170
222
  l,
171
- P
223
+ H
172
224
  ]);
173
225
  return {
174
- herd: S.data?.healthyBowlHerdDepth ?? null,
175
- groups: C.data?.healthyBowlAnimalGroups ?? S.data?.healthyBowlHerdDepth?.groups ?? [],
176
- animalDepth: w.data?.healthyBowlAnimalDepth ?? null,
226
+ herd: D.data?.healthyBowlHerdDepth ?? null,
227
+ groups: O.data?.healthyBowlAnimalGroups ?? D.data?.healthyBowlHerdDepth?.groups ?? [],
228
+ animalDepth: k.data?.healthyBowlAnimalDepth ?? null,
229
+ pedigree: A.data?.healthyBowlAnimalPedigree ?? null,
177
230
  loading: {
178
- herd: S.loading,
179
- groups: C.loading,
180
- animal: w.loading
231
+ herd: D.loading,
232
+ groups: O.loading,
233
+ animal: k.loading,
234
+ pedigree: A.loading
181
235
  },
182
236
  errors: {
183
- herd: S.error ?? null,
184
- groups: C.error ?? null,
185
- animal: w.error ?? null
237
+ herd: D.error ?? null,
238
+ groups: O.error ?? null,
239
+ animal: k.error ?? null,
240
+ pedigree: A.error ?? null
186
241
  },
187
- refetchHerd: j,
188
- refetchGroups: M,
189
- refetchAnimal: N,
190
- updateAnimalDepth: F,
191
- createGroup: I,
192
- updateGroup: L,
193
- deleteGroup: R,
194
- recordWeight: z,
195
- deleteWeight: B
242
+ refetchHerd: L,
243
+ refetchGroups: R,
244
+ refetchAnimal: z,
245
+ refetchPedigree: B,
246
+ updateAnimalDepth: U,
247
+ createGroup: W,
248
+ updateGroup: G,
249
+ deleteGroup: K,
250
+ recordWeight: q,
251
+ deleteWeight: J
196
252
  };
197
253
  }
198
254
  //#endregion
199
- export { x as useHealthyBowlLivestockDepth };
255
+ export { T as useHealthyBowlLivestockDepth };
200
256
 
201
257
  //# sourceMappingURL=useHealthyBowlLivestockDepth.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useHealthyBowlLivestockDepth.js","names":[],"sources":["../../../src/healthybowl/hooks/useHealthyBowlLivestockDepth.ts"],"sourcesContent":["/**\n * Deep livestock records — data hook.\n * Roadmap 18 · BOFF-2890 · gap L-1.\n *\n * Broadens the animal record with EID/RFID, body-condition score, manual/smart groups, dam/sire\n * genealogy, grazing/rotation, and a weight history that yields ADG. The medication-withdrawal\n * end-date + \"do not sell\" compliance flag are REUSED from the shipped withdrawal sub-domain\n * (BOFF-2885) and surfaced here on the deep herd view. Documents are declared inline with `gql`\n * (the same escape hatch `useHealthyBowlWithdrawal`/`useHealthyBowlDistribution` use) because\n * codegen validates against the committed `graphql/wspace.graphql` snapshot. Types mirror\n * `wspace-healthybowl-svc/src/modules/healthybowl/schema/livestock-depth.gql`.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport { gql } from '@apollo/client';\nimport { useMutation, useQuery } from '@apollo/client/react';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\n\nconst FALLBACK_WORKSPACE_ID = '00000000-0000-0000-0000-000000000001';\n\n// ── types (mirror livestock-depth.gql) ─────────────────────────────────────────\n\nexport interface AnimalWithdrawalBadge {\n status: string;\n blocked: boolean;\n endDate: string | null;\n daysLeft: number;\n milkClearDate: string | null;\n meatClearDate: string | null;\n eggsClearDate: string | null;\n}\n\nexport interface HerdDepthRow {\n animalId: string;\n tagNumber: string;\n eidTag: string | null;\n name: string;\n type: string;\n groupId: string | null;\n groupName: string | null;\n bodyConditionScore: number | null;\n adgKgPerDay: number | null;\n latestWeightKg: number | null;\n latestWeightAt: string | null;\n withdrawal: AnimalWithdrawalBadge;\n}\n\nexport interface AnimalGroup {\n id: string;\n name: string;\n description: string | null;\n kind: string;\n smartRule: Record<string, unknown> | null;\n color: string | null;\n animalCount: number;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface HerdComplianceSummary {\n totalAnimals: number;\n animalsInWithdrawal: number;\n animalsClear: number;\n complianceMessage: string;\n}\n\nexport interface HerdDepthView {\n rows: HerdDepthRow[];\n summary: HerdComplianceSummary;\n groups: AnimalGroup[];\n /**\n * True when the server hit a row cap, so `rows` is a page of the herd rather than the herd\n * (BOFF-6012). `summary.totalAnimals` counts the rows returned; `groups[].animalCount` still\n * counts the whole herd.\n */\n truncated: boolean;\n}\n\nexport interface WeightRecord {\n id: string;\n animalId: string;\n weightKg: number;\n measuredAt: string;\n method: string | null;\n notes: string | null;\n createdAt: string;\n}\n\nexport interface AnimalDepthRecord {\n animalId: string;\n tagNumber: string;\n eidTag: string | null;\n name: string;\n type: string;\n breed: string | null;\n status: string;\n groupId: string | null;\n groupName: string | null;\n bodyConditionScore: number | null;\n damId: string | null;\n damTag: string | null;\n sireId: string | null;\n sireTag: string | null;\n grazingPaddock: string | null;\n rotationDate: string | null;\n grazingNotes: string | null;\n adgKgPerDay: number | null;\n latestWeightKg: number | null;\n latestWeightAt: string | null;\n weightHistory: WeightRecord[];\n withdrawal: AnimalWithdrawalBadge;\n}\n\ninterface HbContext {\n workspaceId: string;\n}\n\n// ── field fragments ─────────────────────────────────────────────────────────\n\nconst WITHDRAWAL_FIELDS = `\n status\n blocked\n endDate\n daysLeft\n milkClearDate\n meatClearDate\n eggsClearDate\n`;\n\nconst GROUP_FIELDS = `\n id\n name\n description\n kind\n smartRule\n color\n animalCount\n createdAt\n updatedAt\n`;\n\nconst HERD_ROW_FIELDS = `\n animalId\n tagNumber\n eidTag\n name\n type\n groupId\n groupName\n bodyConditionScore\n adgKgPerDay\n latestWeightKg\n latestWeightAt\n withdrawal { ${WITHDRAWAL_FIELDS} }\n`;\n\nconst WEIGHT_FIELDS = `\n id\n animalId\n weightKg\n measuredAt\n method\n notes\n createdAt\n`;\n\nconst ANIMAL_DEPTH_FIELDS = `\n animalId\n tagNumber\n eidTag\n name\n type\n breed\n status\n groupId\n groupName\n bodyConditionScore\n damId\n damTag\n sireId\n sireTag\n grazingPaddock\n rotationDate\n grazingNotes\n adgKgPerDay\n latestWeightKg\n latestWeightAt\n weightHistory { ${WEIGHT_FIELDS} }\n withdrawal { ${WITHDRAWAL_FIELDS} }\n`;\n\n// ── documents ─────────────────────────────────────────────────────────────\n\nconst GET_HERD_DEPTH = gql`\n query HealthyBowlHerdDepth($context: ContextInput!, $groupId: ID, $search: String) {\n healthyBowlHerdDepth(context: $context, groupId: $groupId, search: $search) {\n truncated\n rows { ${HERD_ROW_FIELDS} }\n summary { totalAnimals animalsInWithdrawal animalsClear complianceMessage }\n groups { ${GROUP_FIELDS} }\n }\n }\n`;\n\nconst GET_ANIMAL_DEPTH = gql`\n query HealthyBowlAnimalDepth($context: ContextInput!, $animalId: ID!) {\n healthyBowlAnimalDepth(context: $context, animalId: $animalId) { ${ANIMAL_DEPTH_FIELDS} }\n }\n`;\n\nconst GET_GROUPS = gql`\n query HealthyBowlAnimalGroups($context: ContextInput!) {\n healthyBowlAnimalGroups(context: $context) { ${GROUP_FIELDS} }\n }\n`;\n\nconst UPDATE_ANIMAL_DEPTH = gql`\n mutation UpdateHealthyBowlAnimalDepth($input: UpdateHealthyBowlAnimalDepthInput!) {\n updateHealthyBowlAnimalDepth(input: $input) { ${ANIMAL_DEPTH_FIELDS} }\n }\n`;\n\nconst CREATE_GROUP = gql`\n mutation CreateHealthyBowlAnimalGroup($input: CreateHealthyBowlAnimalGroupInput!) {\n createHealthyBowlAnimalGroup(input: $input) { ${GROUP_FIELDS} }\n }\n`;\n\nconst UPDATE_GROUP = gql`\n mutation UpdateHealthyBowlAnimalGroup($input: UpdateHealthyBowlAnimalGroupInput!) {\n updateHealthyBowlAnimalGroup(input: $input) { ${GROUP_FIELDS} }\n }\n`;\n\nconst DELETE_GROUP = gql`\n mutation DeleteHealthyBowlAnimalGroup($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlAnimalGroup(id: $id, context: $context)\n }\n`;\n\nconst RECORD_WEIGHT = gql`\n mutation RecordHealthyBowlAnimalWeight($input: RecordHealthyBowlAnimalWeightInput!) {\n recordHealthyBowlAnimalWeight(input: $input) { ${WEIGHT_FIELDS} }\n }\n`;\n\nconst DELETE_WEIGHT = gql`\n mutation DeleteHealthyBowlAnimalWeight($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlAnimalWeight(id: $id, context: $context)\n }\n`;\n\n// ── hook ─────────────────────────────────────────────────────────────────────\n\nexport interface UseLivestockDepthOptions {\n /** Fetch the deep herd view (rows + compliance summary + groups). */\n herd?: boolean;\n /** Optional group filter for the herd view. */\n herdGroupId?: string | null;\n /** Optional free-text search (tag / name / EID) for the herd view. */\n herdSearch?: string | null;\n /** Fetch the animal groups list. */\n groups?: boolean;\n /** Fetch a single animal's deep record. */\n animalId?: string | null;\n}\n\nexport function useHealthyBowlLivestockDepth(options: UseLivestockDepthOptions = {}) {\n const { workspaceId } = useHealthyBowl();\n const effectiveWorkspaceId = workspaceId || FALLBACK_WORKSPACE_ID;\n const ctx = useMemo<HbContext>(() => ({ workspaceId: effectiveWorkspaceId }), [effectiveWorkspaceId]);\n\n const enableHerd = options.herd === true;\n const enableGroups = options.groups === true;\n const animalId = options.animalId ?? null;\n const herdGroupId = options.herdGroupId ?? null;\n const herdSearch = options.herdSearch ?? null;\n\n const herdQuery = useQuery<\n { healthyBowlHerdDepth: HerdDepthView },\n { context: HbContext; groupId: string | null; search: string | null }\n >(GET_HERD_DEPTH, {\n variables: { context: ctx, groupId: herdGroupId, search: herdSearch },\n fetchPolicy: 'cache-and-network',\n skip: !enableHerd,\n });\n\n const groupsQuery = useQuery<{ healthyBowlAnimalGroups: AnimalGroup[] }, { context: HbContext }>(GET_GROUPS, {\n variables: { context: ctx },\n fetchPolicy: 'cache-and-network',\n skip: !enableGroups,\n });\n\n const animalQuery = useQuery<{ healthyBowlAnimalDepth: AnimalDepthRecord }, { context: HbContext; animalId: string }>(\n GET_ANIMAL_DEPTH,\n { variables: { context: ctx, animalId: animalId ?? '' }, fetchPolicy: 'cache-and-network', skip: !animalId }\n );\n\n const [updateAnimalDepthMutation] = useMutation(UPDATE_ANIMAL_DEPTH);\n const [createGroupMutation] = useMutation(CREATE_GROUP);\n const [updateGroupMutation] = useMutation(UPDATE_GROUP);\n const [deleteGroupMutation] = useMutation(DELETE_GROUP);\n const [recordWeightMutation] = useMutation(RECORD_WEIGHT);\n const [deleteWeightMutation] = useMutation(DELETE_WEIGHT);\n\n const refetchHerd = useCallback(() => herdQuery.refetch(), [herdQuery]);\n const refetchGroups = useCallback(() => groupsQuery.refetch(), [groupsQuery]);\n const refetchAnimal = useCallback(() => animalQuery.refetch(), [animalQuery]);\n\n const reconcile = useCallback(async () => {\n const runners: Array<Promise<unknown>> = [];\n if (enableHerd) runners.push(refetchHerd().catch(() => undefined));\n if (enableGroups) runners.push(refetchGroups().catch(() => undefined));\n if (animalId) runners.push(refetchAnimal().catch(() => undefined));\n await Promise.all(runners);\n }, [enableHerd, enableGroups, animalId, refetchHerd, refetchGroups, refetchAnimal]);\n\n const updateAnimalDepth = useCallback(\n async (input: Record<string, unknown>): Promise<AnimalDepthRecord | undefined> => {\n const res = await updateAnimalDepthMutation({ variables: { input: { ...input, context: ctx } } });\n await reconcile();\n return (res.data as { updateHealthyBowlAnimalDepth?: AnimalDepthRecord } | null)?.updateHealthyBowlAnimalDepth;\n },\n [updateAnimalDepthMutation, ctx, reconcile]\n );\n\n const createGroup = useCallback(\n async (input: Record<string, unknown>): Promise<AnimalGroup | undefined> => {\n const res = await createGroupMutation({ variables: { input: { ...input, context: ctx } } });\n await reconcile();\n return (res.data as { createHealthyBowlAnimalGroup?: AnimalGroup } | null)?.createHealthyBowlAnimalGroup;\n },\n [createGroupMutation, ctx, reconcile]\n );\n\n const updateGroup = useCallback(\n async (input: Record<string, unknown>): Promise<AnimalGroup | undefined> => {\n const res = await updateGroupMutation({ variables: { input: { ...input, context: ctx } } });\n await reconcile();\n return (res.data as { updateHealthyBowlAnimalGroup?: AnimalGroup } | null)?.updateHealthyBowlAnimalGroup;\n },\n [updateGroupMutation, ctx, reconcile]\n );\n\n const deleteGroup = useCallback(\n async (id: string): Promise<void> => {\n await deleteGroupMutation({ variables: { id, context: ctx } });\n await reconcile();\n },\n [deleteGroupMutation, ctx, reconcile]\n );\n\n const recordWeight = useCallback(\n async (input: Record<string, unknown>): Promise<WeightRecord | undefined> => {\n const res = await recordWeightMutation({ variables: { input: { ...input, context: ctx } } });\n await reconcile();\n return (res.data as { recordHealthyBowlAnimalWeight?: WeightRecord } | null)?.recordHealthyBowlAnimalWeight;\n },\n [recordWeightMutation, ctx, reconcile]\n );\n\n const deleteWeight = useCallback(\n async (id: string): Promise<void> => {\n await deleteWeightMutation({ variables: { id, context: ctx } });\n await reconcile();\n },\n [deleteWeightMutation, ctx, reconcile]\n );\n\n return {\n herd: herdQuery.data?.healthyBowlHerdDepth ?? null,\n groups: groupsQuery.data?.healthyBowlAnimalGroups ?? herdQuery.data?.healthyBowlHerdDepth?.groups ?? [],\n animalDepth: animalQuery.data?.healthyBowlAnimalDepth ?? null,\n loading: {\n herd: herdQuery.loading,\n groups: groupsQuery.loading,\n animal: animalQuery.loading,\n },\n errors: {\n herd: herdQuery.error ?? null,\n groups: groupsQuery.error ?? null,\n animal: animalQuery.error ?? null,\n },\n refetchHerd,\n refetchGroups,\n refetchAnimal,\n updateAnimalDepth,\n createGroup,\n updateGroup,\n deleteGroup,\n recordWeight,\n deleteWeight,\n };\n}\n"],"mappings":";;;;;AAkBA,IAAM,IAAwB,wCAqGxB,IAAoB,qGAUpB,IAAe,0GAYf,IAAkB;;;;;;;;;;;;iBAYP,EAAkB;GAG7B,IAAgB,kFAUhB,IAAsB;;;;;;;;;;;;;;;;;;;;;oBAqBR,EAAc;iBACjB,EAAkB;GAK7B,IAAiB,CAAG;;;;eAIX,EAAgB;;iBAEd,EAAa;;;GAKxB,IAAmB,CAAG;;uEAE2C,EAAoB;;GAIrF,IAAa,CAAG;;mDAE6B,EAAa;;GAI1D,IAAsB,CAAG;;oDAEqB,EAAoB;;GAIlE,IAAe,CAAG;;oDAE4B,EAAa;;GAI3D,IAAe,CAAG;;oDAE4B,EAAa;;GAI3D,IAAe,CAAG;;;;GAMlB,IAAgB,CAAG;;qDAE4B,EAAc;;GAI7D,IAAgB,CAAG;;;;;AAqBzB,SAAgB,EAA6B,IAAoC,CAAC,GAAG;CACnF,IAAM,EAAE,mBAAgB,EAAe,GACjC,IAAuB,KAAe,GACtC,IAAM,SAA0B,EAAE,aAAa,EAAqB,IAAI,CAAC,CAAoB,CAAC,GAE9F,IAAa,EAAQ,SAAS,IAC9B,IAAe,EAAQ,WAAW,IAClC,IAAW,EAAQ,YAAY,MAI/B,IAAY,EAGhB,GAAgB;EAChB,WAAW;GAAE,SAAS;GAAK,SAPT,EAAQ,eAAe;GAOQ,QANhC,EAAQ,cAAc;EAM6B;EACpE,aAAa;EACb,MAAM,CAAC;CACT,CAAC,GAEK,IAAc,EAA6E,GAAY;EAC3G,WAAW,EAAE,SAAS,EAAI;EAC1B,aAAa;EACb,MAAM,CAAC;CACT,CAAC,GAEK,IAAc,EAClB,GACA;EAAE,WAAW;GAAE,SAAS;GAA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AAqE;EAC1E,IAAM,IAAM,MAAM,EAAoB,EAAE,WAAW,EAAE,OAAO;GAAE,GAAG;GAAO,SAAS;EAAI,EAAE,EAAE,CAAC;EAE1F,OADA,MAAM,EAAU,GACR,EAAI,MAAgE;CAC9E,GACA;EAAC;EAAqB;EAAK;CAAS,CACtC,GAEM,IAAc,EAClB,OAAO,MAA8B;EAEnC,AADA,MAAM,EAAoB,EAAE,WAAW;GAAE;GAAI,SAAS;EAAI,EAAE,CAAC,GAC7D,MAAM,EAAU;CAClB,GACA;EAAC;EAAqB;EAAK;CAAS,CACtC,GAEM,IAAe,EACnB,OAAO,MAAsE;EAC3E,IAAM,IAAM,MAAM,EAAqB,EAAE,WAAW,EAAE,OAAO;GAAE,GAAG;GAAO,SAAS;EAAI,EAAE,EAAE,CAAC;EAE3F,OADA,MAAM,EAAU,GACR,EAAI,MAAkE;CAChF,GACA;EAAC;EAAsB;EAAK;CAAS,CACvC,GAEM,IAAe,EACnB,OAAO,MAA8B;EAEnC,AADA,MAAM,EAAqB,EAAE,WAAW;GAAE;GAAI,SAAS;EAAI,EAAE,CAAC,GAC9D,MAAM,EAAU;CAClB,GACA;EAAC;EAAsB;EAAK;CAAS,CACvC;CAEA,OAAO;EACL,MAAM,EAAU,MAAM,wBAAwB;EAC9C,QAAQ,EAAY,MAAM,2BAA2B,EAAU,MAAM,sBAAsB,UAAU,CAAC;EACtG,aAAa,EAAY,MAAM,0BAA0B;EACzD,SAAS;GACP,MAAM,EAAU;GAChB,QAAQ,EAAY;GACpB,QAAQ,EAAY;EACtB;EACA,QAAQ;GACN,MAAM,EAAU,SAAS;GACzB,QAAQ,EAAY,SAAS;GAC7B,QAAQ,EAAY,SAAS;EAC/B;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
1
+ {"version":3,"file":"useHealthyBowlLivestockDepth.js","names":[],"sources":["../../../src/healthybowl/hooks/useHealthyBowlLivestockDepth.ts"],"sourcesContent":["/**\n * Deep livestock records — data hook.\n * Roadmap 18 · BOFF-2890 · gap L-1.\n *\n * Broadens the animal record with EID/RFID, body-condition score, manual/smart groups, dam/sire\n * genealogy, grazing/rotation, and a weight history that yields ADG. The medication-withdrawal\n * end-date + \"do not sell\" compliance flag are REUSED from the shipped withdrawal sub-domain\n * (BOFF-2885) and surfaced here on the deep herd view. Documents are declared inline with `gql`\n * (the same escape hatch `useHealthyBowlWithdrawal`/`useHealthyBowlDistribution` use) because\n * codegen validates against the committed `graphql/wspace.graphql` snapshot. Types mirror\n * `wspace-healthybowl-svc/src/modules/healthybowl/schema/livestock-depth.gql`.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport { gql } from '@apollo/client';\nimport { useMutation, useQuery } from '@apollo/client/react';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\n\nconst FALLBACK_WORKSPACE_ID = '00000000-0000-0000-0000-000000000001';\n\n// ── types (mirror livestock-depth.gql) ─────────────────────────────────────────\n\nexport interface AnimalWithdrawalBadge {\n status: string;\n blocked: boolean;\n endDate: string | null;\n daysLeft: number;\n milkClearDate: string | null;\n meatClearDate: string | null;\n eggsClearDate: string | null;\n}\n\nexport interface HerdDepthRow {\n animalId: string;\n tagNumber: string;\n eidTag: string | null;\n name: string;\n type: string;\n groupId: string | null;\n groupName: string | null;\n bodyConditionScore: number | null;\n adgKgPerDay: number | null;\n latestWeightKg: number | null;\n latestWeightAt: string | null;\n /**\n * True when the animal has left the herd. Only present at all when `herdIncludeArchived` was set —\n * the default document does not select it, so it is `undefined` on every other caller's rows.\n */\n archived?: boolean;\n withdrawal: AnimalWithdrawalBadge;\n}\n\nexport interface AnimalGroup {\n id: string;\n name: string;\n description: string | null;\n kind: string;\n smartRule: Record<string, unknown> | null;\n color: string | null;\n animalCount: number;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface HerdComplianceSummary {\n totalAnimals: number;\n animalsInWithdrawal: number;\n animalsClear: number;\n complianceMessage: string;\n}\n\nexport interface HerdDepthView {\n rows: HerdDepthRow[];\n summary: HerdComplianceSummary;\n groups: AnimalGroup[];\n /**\n * True when the server hit a row cap, so `rows` is a page of the herd rather than the herd\n * (BOFF-6012). `summary.totalAnimals` counts the rows returned; `groups[].animalCount` still\n * counts the whole herd.\n */\n truncated: boolean;\n}\n\nexport interface WeightRecord {\n id: string;\n animalId: string;\n weightKg: number;\n measuredAt: string;\n method: string | null;\n notes: string | null;\n createdAt: string;\n}\n\nexport interface AnimalDepthRecord {\n animalId: string;\n tagNumber: string;\n eidTag: string | null;\n name: string;\n type: string;\n breed: string | null;\n status: string;\n groupId: string | null;\n groupName: string | null;\n bodyConditionScore: number | null;\n damId: string | null;\n damTag: string | null;\n /** True when the dam has left the herd (BOFF-6011). Drives the \"(archived)\" suffix. */\n damArchived: boolean;\n sireId: string | null;\n sireTag: string | null;\n /** True when the sire has left the herd. See `damArchived`. */\n sireArchived: boolean;\n grazingPaddock: string | null;\n rotationDate: string | null;\n grazingNotes: string | null;\n adgKgPerDay: number | null;\n latestWeightKg: number | null;\n latestWeightAt: string | null;\n weightHistory: WeightRecord[];\n withdrawal: AnimalWithdrawalBadge;\n}\n\ninterface HbContext {\n workspaceId: string;\n}\n\n// ── field fragments ─────────────────────────────────────────────────────────\n\nconst WITHDRAWAL_FIELDS = `\n status\n blocked\n endDate\n daysLeft\n milkClearDate\n meatClearDate\n eggsClearDate\n`;\n\nconst GROUP_FIELDS = `\n id\n name\n description\n kind\n smartRule\n color\n animalCount\n createdAt\n updatedAt\n`;\n\nconst HERD_ROW_FIELDS = `\n animalId\n tagNumber\n eidTag\n name\n type\n groupId\n groupName\n bodyConditionScore\n adgKgPerDay\n latestWeightKg\n latestWeightAt\n withdrawal { ${WITHDRAWAL_FIELDS} }\n`;\n\n/** The herd row plus the archived marker. Only the genealogy picker asks for this — see the note\n * above `GET_HERD_DEPTH_WITH_ARCHIVED`. */\nconst HERD_ROW_FIELDS_WITH_ARCHIVED = `\n ${HERD_ROW_FIELDS}\n archived\n`;\n\nconst WEIGHT_FIELDS = `\n id\n animalId\n weightKg\n measuredAt\n method\n notes\n createdAt\n`;\n\nconst ANIMAL_DEPTH_FIELDS = `\n animalId\n tagNumber\n eidTag\n name\n type\n breed\n status\n groupId\n groupName\n bodyConditionScore\n damId\n damTag\n damArchived\n sireId\n sireTag\n sireArchived\n grazingPaddock\n rotationDate\n grazingNotes\n adgKgPerDay\n latestWeightKg\n latestWeightAt\n weightHistory { ${WEIGHT_FIELDS} }\n withdrawal { ${WITHDRAWAL_FIELDS} }\n`;\n\n// ── documents ─────────────────────────────────────────────────────────────\n\nconst GET_HERD_DEPTH = gql`\n query HealthyBowlHerdDepth($context: ContextInput!, $groupId: ID, $search: String) {\n healthyBowlHerdDepth(context: $context, groupId: $groupId, search: $search) {\n truncated\n rows { ${HERD_ROW_FIELDS} }\n summary { totalAnimals animalsInWithdrawal animalsClear complianceMessage }\n groups { ${GROUP_FIELDS} }\n }\n }\n`;\n\n/**\n * The archived-aware variant, used ONLY when a caller sets `herdIncludeArchived` (BOFF-6195).\n *\n * Deliberately a second document rather than one document with an optional argument. The herd list\n * and the grazing move modal do not want archived rows and have no reason to carry the risk: a\n * single shared document would send `includeArchived` and select `archived` on every read, so a\n * supergraph that has not yet composed those — a stale prod Hive CDN edge lasts ~30–40 min after a\n * publish — would fail validation on `/livestock/records` and `/livestock/grazing` too, not just on\n * the one page that needs the feature. The blast radius is now exactly the caller that opted in.\n *\n * The operation name differs so Apollo treats it as a distinct operation.\n */\nconst GET_HERD_DEPTH_WITH_ARCHIVED = gql`\n query HealthyBowlHerdDepthWithArchived(\n $context: ContextInput!\n $groupId: ID\n $search: String\n $includeArchived: Boolean\n ) {\n healthyBowlHerdDepth(context: $context, groupId: $groupId, search: $search, includeArchived: $includeArchived) {\n truncated\n rows { ${HERD_ROW_FIELDS_WITH_ARCHIVED} }\n summary { totalAnimals animalsInWithdrawal animalsClear complianceMessage }\n groups { ${GROUP_FIELDS} }\n }\n }\n`;\n\nexport interface PedigreeNode {\n animalId: string;\n tagNumber: string;\n name: string;\n type: string;\n breed: string | null;\n gender: string;\n dateOfBirth: string | null;\n generation: number;\n /** DAM | SIRE — which side of this node's own child it sits on. SELF on the root. */\n relation: string;\n archived: boolean;\n /** ONE of the animals a generation closer to the root that this node parents. */\n childAnimalId: string | null;\n}\n\nexport interface OffspringNode {\n animalId: string;\n tagNumber: string;\n name: string;\n type: string;\n gender: string;\n dateOfBirth: string | null;\n generation: number;\n /** DAM | SIRE | BOTH — the parent link followed from the preceding node in the pedigree walk. */\n viaParent: string;\n archived: boolean;\n /** One matching preceding parent for compatibility; parentAnimalIds retains every matching edge. */\n parentAnimalId: string | null;\n /** All immediately preceding parents matched in the walk; empty for direct offspring. */\n parentAnimalIds: string[];\n}\n\nexport interface AnimalPedigree {\n root: PedigreeNode;\n ancestors: PedigreeNode[];\n offspring: OffspringNode[];\n /** A depth or node cap stopped the walk, so the tree shown is incomplete. */\n truncated: boolean;\n /** The walk re-entered an animal it had already visited — reachable on undated rows. */\n cycleDetected: boolean;\n ancestorDepth: number;\n offspringDepth: number;\n}\n\nconst PEDIGREE_NODE_FIELDS = `\n animalId tagNumber name type breed gender dateOfBirth generation relation archived childAnimalId\n`;\nconst OFFSPRING_NODE_FIELDS = `\n animalId tagNumber name type gender dateOfBirth generation viaParent archived parentAnimalId parentAnimalIds\n`;\n\nconst GET_PEDIGREE = gql`\n query HealthyBowlAnimalPedigree($context: ContextInput!, $animalId: ID!, $ancestorDepth: Int, $offspringDepth: Int) {\n healthyBowlAnimalPedigree(\n context: $context\n animalId: $animalId\n ancestorDepth: $ancestorDepth\n offspringDepth: $offspringDepth\n ) {\n root { ${PEDIGREE_NODE_FIELDS} }\n ancestors { ${PEDIGREE_NODE_FIELDS} }\n offspring { ${OFFSPRING_NODE_FIELDS} }\n truncated\n cycleDetected\n ancestorDepth\n offspringDepth\n }\n }\n`;\n\nconst GET_ANIMAL_DEPTH = gql`\n query HealthyBowlAnimalDepth($context: ContextInput!, $animalId: ID!) {\n healthyBowlAnimalDepth(context: $context, animalId: $animalId) { ${ANIMAL_DEPTH_FIELDS} }\n }\n`;\n\nconst GET_GROUPS = gql`\n query HealthyBowlAnimalGroups($context: ContextInput!) {\n healthyBowlAnimalGroups(context: $context) { ${GROUP_FIELDS} }\n }\n`;\n\nconst UPDATE_ANIMAL_DEPTH = gql`\n mutation UpdateHealthyBowlAnimalDepth($input: UpdateHealthyBowlAnimalDepthInput!) {\n updateHealthyBowlAnimalDepth(input: $input) { ${ANIMAL_DEPTH_FIELDS} }\n }\n`;\n\nconst CREATE_GROUP = gql`\n mutation CreateHealthyBowlAnimalGroup($input: CreateHealthyBowlAnimalGroupInput!) {\n createHealthyBowlAnimalGroup(input: $input) { ${GROUP_FIELDS} }\n }\n`;\n\nconst UPDATE_GROUP = gql`\n mutation UpdateHealthyBowlAnimalGroup($input: UpdateHealthyBowlAnimalGroupInput!) {\n updateHealthyBowlAnimalGroup(input: $input) { ${GROUP_FIELDS} }\n }\n`;\n\nconst DELETE_GROUP = gql`\n mutation DeleteHealthyBowlAnimalGroup($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlAnimalGroup(id: $id, context: $context)\n }\n`;\n\nconst RECORD_WEIGHT = gql`\n mutation RecordHealthyBowlAnimalWeight($input: RecordHealthyBowlAnimalWeightInput!) {\n recordHealthyBowlAnimalWeight(input: $input) { ${WEIGHT_FIELDS} }\n }\n`;\n\nconst DELETE_WEIGHT = gql`\n mutation DeleteHealthyBowlAnimalWeight($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlAnimalWeight(id: $id, context: $context)\n }\n`;\n\n// ── hook ─────────────────────────────────────────────────────────────────────\n\nexport interface UseLivestockDepthOptions {\n /** Fetch the deep herd view (rows + compliance summary + groups). */\n herd?: boolean;\n /** Optional group filter for the herd view. */\n herdGroupId?: string | null;\n /** Optional free-text search (tag / name / EID) for the herd view. */\n herdSearch?: string | null;\n /**\n * Include archived (soft-deleted) animals in the herd rows. Off by default — only the genealogy\n * picker wants them, and they must never appear in a herd LIST. `summary` and\n * `groups[].animalCount` stay live-only whatever this is set to (BOFF-6195).\n */\n herdIncludeArchived?: boolean;\n /** Fetch the animal groups list. */\n groups?: boolean;\n /** Fetch a single animal's deep record. */\n animalId?: string | null;\n /** Fetch the animal's pedigree (ancestors + offspring). Requires `animalId` (BOFF-6097). */\n pedigree?: boolean;\n /** Generations of ancestors to walk. The server clamps to 1..8; default 4. */\n pedigreeAncestorDepth?: number | null;\n}\n\nexport function useHealthyBowlLivestockDepth(options: UseLivestockDepthOptions = {}) {\n const { workspaceId } = useHealthyBowl();\n const effectiveWorkspaceId = workspaceId || FALLBACK_WORKSPACE_ID;\n const ctx = useMemo<HbContext>(() => ({ workspaceId: effectiveWorkspaceId }), [effectiveWorkspaceId]);\n\n const enableHerd = options.herd === true;\n const enableGroups = options.groups === true;\n const animalId = options.animalId ?? null;\n const herdGroupId = options.herdGroupId ?? null;\n const herdSearch = options.herdSearch ?? null;\n const herdIncludeArchived = options.herdIncludeArchived ?? false;\n\n const herdQuery = useQuery<\n { healthyBowlHerdDepth: HerdDepthView },\n { context: HbContext; groupId: string | null; search: string | null; includeArchived?: boolean }\n >(herdIncludeArchived ? GET_HERD_DEPTH_WITH_ARCHIVED : GET_HERD_DEPTH, {\n variables: herdIncludeArchived\n ? { context: ctx, groupId: herdGroupId, search: herdSearch, includeArchived: true }\n : { context: ctx, groupId: herdGroupId, search: herdSearch },\n fetchPolicy: 'cache-and-network',\n skip: !enableHerd,\n });\n\n const groupsQuery = useQuery<{ healthyBowlAnimalGroups: AnimalGroup[] }, { context: HbContext }>(GET_GROUPS, {\n variables: { context: ctx },\n fetchPolicy: 'cache-and-network',\n skip: !enableGroups,\n });\n\n const animalQuery = useQuery<{ healthyBowlAnimalDepth: AnimalDepthRecord }, { context: HbContext; animalId: string }>(\n GET_ANIMAL_DEPTH,\n { variables: { context: ctx, animalId: animalId ?? '' }, fetchPolicy: 'cache-and-network', skip: !animalId }\n );\n\n const pedigreeQuery = useQuery<\n { healthyBowlAnimalPedigree: AnimalPedigree },\n { context: HbContext; animalId: string; ancestorDepth: number | null; offspringDepth: number | null }\n >(GET_PEDIGREE, {\n variables: {\n context: ctx,\n animalId: animalId ?? '',\n ancestorDepth: options.pedigreeAncestorDepth ?? null,\n offspringDepth: null,\n },\n fetchPolicy: 'cache-and-network',\n skip: !animalId || options.pedigree !== true,\n });\n\n const [updateAnimalDepthMutation] = useMutation(UPDATE_ANIMAL_DEPTH);\n const [createGroupMutation] = useMutation(CREATE_GROUP);\n const [updateGroupMutation] = useMutation(UPDATE_GROUP);\n const [deleteGroupMutation] = useMutation(DELETE_GROUP);\n const [recordWeightMutation] = useMutation(RECORD_WEIGHT);\n const [deleteWeightMutation] = useMutation(DELETE_WEIGHT);\n\n const refetchHerd = useCallback(() => herdQuery.refetch(), [herdQuery]);\n const refetchGroups = useCallback(() => groupsQuery.refetch(), [groupsQuery]);\n const refetchAnimal = useCallback(() => animalQuery.refetch(), [animalQuery]);\n const refetchPedigree = useCallback(() => pedigreeQuery.refetch(), [pedigreeQuery]);\n const enablePedigree = options.pedigree === true;\n\n const reconcile = useCallback(async () => {\n const runners: Array<Promise<unknown>> = [];\n if (enableHerd) runners.push(refetchHerd().catch(() => undefined));\n if (enableGroups) runners.push(refetchGroups().catch(() => undefined));\n if (animalId) runners.push(refetchAnimal().catch(() => undefined));\n // An edit that changes dam/sire changes the tree — without this the panel keeps showing the\n // pre-edit ancestry until a hard reload (BOFF-6097).\n if (animalId && enablePedigree) runners.push(refetchPedigree().catch(() => undefined));\n await Promise.all(runners);\n }, [enableHerd, enableGroups, animalId, enablePedigree, refetchHerd, refetchGroups, refetchAnimal, refetchPedigree]);\n\n const updateAnimalDepth = useCallback(\n async (input: Record<string, unknown>): Promise<AnimalDepthRecord | undefined> => {\n const res = await updateAnimalDepthMutation({ variables: { input: { ...input, context: ctx } } });\n await reconcile();\n return (res.data as { updateHealthyBowlAnimalDepth?: AnimalDepthRecord } | null)?.updateHealthyBowlAnimalDepth;\n },\n [updateAnimalDepthMutation, ctx, reconcile]\n );\n\n const createGroup = useCallback(\n async (input: Record<string, unknown>): Promise<AnimalGroup | undefined> => {\n const res = await createGroupMutation({ variables: { input: { ...input, context: ctx } } });\n await reconcile();\n return (res.data as { createHealthyBowlAnimalGroup?: AnimalGroup } | null)?.createHealthyBowlAnimalGroup;\n },\n [createGroupMutation, ctx, reconcile]\n );\n\n const updateGroup = useCallback(\n async (input: Record<string, unknown>): Promise<AnimalGroup | undefined> => {\n const res = await updateGroupMutation({ variables: { input: { ...input, context: ctx } } });\n await reconcile();\n return (res.data as { updateHealthyBowlAnimalGroup?: AnimalGroup } | null)?.updateHealthyBowlAnimalGroup;\n },\n [updateGroupMutation, ctx, reconcile]\n );\n\n const deleteGroup = useCallback(\n async (id: string): Promise<void> => {\n await deleteGroupMutation({ variables: { id, context: ctx } });\n await reconcile();\n },\n [deleteGroupMutation, ctx, reconcile]\n );\n\n const recordWeight = useCallback(\n async (input: Record<string, unknown>): Promise<WeightRecord | undefined> => {\n const res = await recordWeightMutation({ variables: { input: { ...input, context: ctx } } });\n await reconcile();\n return (res.data as { recordHealthyBowlAnimalWeight?: WeightRecord } | null)?.recordHealthyBowlAnimalWeight;\n },\n [recordWeightMutation, ctx, reconcile]\n );\n\n const deleteWeight = useCallback(\n async (id: string): Promise<void> => {\n await deleteWeightMutation({ variables: { id, context: ctx } });\n await reconcile();\n },\n [deleteWeightMutation, ctx, reconcile]\n );\n\n return {\n herd: herdQuery.data?.healthyBowlHerdDepth ?? null,\n groups: groupsQuery.data?.healthyBowlAnimalGroups ?? herdQuery.data?.healthyBowlHerdDepth?.groups ?? [],\n animalDepth: animalQuery.data?.healthyBowlAnimalDepth ?? null,\n pedigree: pedigreeQuery.data?.healthyBowlAnimalPedigree ?? null,\n loading: {\n herd: herdQuery.loading,\n groups: groupsQuery.loading,\n animal: animalQuery.loading,\n pedigree: pedigreeQuery.loading,\n },\n errors: {\n herd: herdQuery.error ?? null,\n groups: groupsQuery.error ?? null,\n animal: animalQuery.error ?? null,\n pedigree: pedigreeQuery.error ?? null,\n },\n refetchHerd,\n refetchGroups,\n refetchAnimal,\n refetchPedigree,\n updateAnimalDepth,\n createGroup,\n updateGroup,\n deleteGroup,\n recordWeight,\n deleteWeight,\n };\n}\n"],"mappings":";;;;;AAkBA,IAAM,IAAwB,wCA8GxB,IAAoB,qGAUpB,IAAe,0GAYf,IAAkB;;;;;;;;;;;;iBAYP,EAAkB;GAK7B,IAAgC;IAClC,EAAgB;;GAId,IAAgB,kFAUhB,IAAsB;;;;;;;;;;;;;;;;;;;;;;;oBAuBR,EAAc;iBACjB,EAAkB;GAK7B,IAAiB,CAAG;;;;eAIX,EAAgB;;iBAEd,EAAa;;;GAiBxB,IAA+B,CAAG;;;;;;;;;eASzB,EAA8B;;iBAE5B,EAAa;;;GAkDxB,IAAuB,0GAOvB,IAAe,CAAG;;;;;;;;eAQT,EAAqB;oBAChB,EAAqB;oBACrB,qHAAsB;;;;;;;GASpC,IAAmB,CAAG;;uEAE2C,EAAoB;;GAIrF,IAAa,CAAG;;mDAE6B,EAAa;;GAI1D,IAAsB,CAAG;;oDAEqB,EAAoB;;GAIlE,IAAe,CAAG;;oDAE4B,EAAa;;GAI3D,IAAe,CAAG;;oDAE4B,EAAa;;GAI3D,IAAe,CAAG;;;;GAMlB,IAAgB,CAAG;;qDAE4B,EAAc;;GAI7D,IAAgB,CAAG;;;;;AA+BzB,SAAgB,EAA6B,IAAoC,CAAC,GAAG;CACnF,IAAM,EAAE,mBAAgB,EAAe,GACjC,IAAuB,KAAe,GACtC,IAAM,SAA0B,EAAE,aAAa,EAAqB,IAAI,CAAC,CAAoB,CAAC,GAE9F,IAAa,EAAQ,SAAS,IAC9B,IAAe,EAAQ,WAAW,IAClC,IAAW,EAAQ,YAAY,MAC/B,IAAc,EAAQ,eAAe,MACrC,IAAa,EAAQ,cAAc,MACnC,IAAsB,EAAQ,uBAAuB,IAErD,IAAY,EAGhB,IAAsB,IAA+B,GAAgB;EACr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,GAEM,IAAe,EACnB,OAAO,MAA8B;EAEnC,AADA,MAAM,EAAqB,EAAE,WAAW;GAAE;GAAI,SAAS;EAAI,EAAE,CAAC,GAC9D,MAAM,EAAU;CAClB,GACA;EAAC;EAAsB;EAAK;CAAS,CACvC;CAEA,OAAO;EACL,MAAM,EAAU,MAAM,wBAAwB;EAC9C,QAAQ,EAAY,MAAM,2BAA2B,EAAU,MAAM,sBAAsB,UAAU,CAAC;EACtG,aAAa,EAAY,MAAM,0BAA0B;EACzD,UAAU,EAAc,MAAM,6BAA6B;EAC3D,SAAS;GACP,MAAM,EAAU;GAChB,QAAQ,EAAY;GACpB,QAAQ,EAAY;GACpB,UAAU,EAAc;EAC1B;EACA,QAAQ;GACN,MAAM,EAAU,SAAS;GACzB,QAAQ,EAAY,SAAS;GAC7B,QAAQ,EAAY,SAAS;GAC7B,UAAU,EAAc,SAAS;EACnC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
@@ -24,7 +24,7 @@ var _ = "__none__", v = {
24
24
  r(() => {
25
25
  x && (q(null), k(C.eidTag ?? ""), j(C.bodyConditionScore === null ? "" : String(C.bodyConditionScore)), N(C.groupId ?? _), F(C.damId ?? _), L(C.sireId ?? _), z(C.grazingPaddock ?? ""), V(C.rotationDate ? C.rotationDate.slice(0, 10) : ""), U(C.grazingNotes ?? ""));
26
26
  }, [x, C]);
27
- let J = T.filter((e) => e.animalId !== C.animalId), Y = async () => {
27
+ let J = T.filter((e) => e.animalId !== C.animalId).sort((e, t) => Number(e.archived) - Number(t.archived)), Y = async () => {
28
28
  if (W) return;
29
29
  let e = A.trim() === "" ? null : Number(A);
30
30
  if (e !== null && (Number.isNaN(e) || e < 0 || e > 5)) {
@@ -64,13 +64,17 @@ var _ = "__none__", v = {
64
64
  children: [/* @__PURE__ */ s(m, { children: /* @__PURE__ */ s(h, {}) }), /* @__PURE__ */ c(f, { children: [/* @__PURE__ */ s(p, {
65
65
  value: _,
66
66
  children: D("healthybowl.livestock.depth.edit.none", "None")
67
- }), J.map((e) => /* @__PURE__ */ c(p, {
67
+ }), J.map((e) => /* @__PURE__ */ s(p, {
68
68
  value: e.animalId,
69
- children: [
70
- e.tagNumber,
71
- " · ",
72
- e.name
73
- ]
69
+ children: /* @__PURE__ */ c("span", {
70
+ className: e.archived ? "text-text-secondary" : void 0,
71
+ children: [
72
+ e.tagNumber,
73
+ " · ",
74
+ e.name,
75
+ e.archived ? ` · ${D("healthybowl.livestock.depth.edit.archivedOption", "archived")}` : ""
76
+ ]
77
+ })
74
78
  }, e.animalId))] })]
75
79
  })] });
76
80
  return /* @__PURE__ */ s(e, {
@@ -1 +1 @@
1
- {"version":3,"file":"AnimalDepthFormModal.js","names":[],"sources":["../../../../src/healthybowl/pages/livestock/AnimalDepthFormModal.tsx"],"sourcesContent":["/**\n * Edit an animal's deep record (BOFF-2890 · L-1): EID/RFID, body-condition score, group,\n * dam/sire genealogy, grazing/rotation. Dam & sire are picked from the workspace's own animals\n * (loose links). No fabricated data — every field maps to a real column.\n */\nimport { useEffect, useState } from 'react';\nimport {\n Button,\n Input,\n Textarea,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@burdenoff/fe-libs/ui';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { Modal } from '../../components';\nimport type { AnimalDepthRecord, AnimalGroup } from '../../hooks/useHealthyBowlLivestockDepth';\nimport { type EidTagRejection, readMutationErrorMessage, validateEidTagInput } from './eidTagInput';\n\nexport interface AnimalOption {\n animalId: string;\n tagNumber: string;\n name: string;\n}\n\ninterface AnimalDepthFormModalProps {\n open: boolean;\n onClose: () => void;\n animal: AnimalDepthRecord;\n groups: AnimalGroup[];\n animalOptions: AnimalOption[];\n onSubmit: (input: Record<string, unknown>) => Promise<void>;\n}\n\nconst NONE = '__none__';\n\n/**\n * Why the EID can be rejected, in the operator's words (BOFF-6050). Keyed by the reason\n * `validateEidTagInput` returns so the copy and the rule cannot drift apart.\n */\nconst EID_REJECTION_COPY: Record<EidTagRejection, { key: string; fallback: string }> = {\n tooLong: {\n key: 'healthybowl.livestock.depth.edit.eidTooLong',\n fallback: 'The EID / RFID tag must be 100 characters or fewer.',\n },\n charset: {\n key: 'healthybowl.livestock.depth.edit.eidCharset',\n fallback: 'The EID / RFID tag may contain only letters, digits, spaces, hyphens and underscores.',\n },\n noAlphanumeric: {\n key: 'healthybowl.livestock.depth.edit.eidNoAlphanumeric',\n fallback: 'The EID / RFID tag must contain at least one letter or digit.',\n },\n};\n\nconst fieldLabel = 'mb-1 block text-sm font-medium text-text-primary';\nconst dateInput =\n 'w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]';\n\nexport const AnimalDepthFormModal = ({\n open,\n onClose,\n animal,\n groups,\n animalOptions,\n onSubmit,\n}: AnimalDepthFormModalProps) => {\n const { t } = useI18n();\n const [eidTag, setEidTag] = useState('');\n const [bcs, setBcs] = useState('');\n const [groupId, setGroupId] = useState(NONE);\n const [damId, setDamId] = useState(NONE);\n const [sireId, setSireId] = useState(NONE);\n const [grazingPaddock, setGrazingPaddock] = useState('');\n const [rotationDate, setRotationDate] = useState('');\n const [grazingNotes, setGrazingNotes] = useState('');\n const [submitting, setSubmitting] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n useEffect(() => {\n if (!open) return;\n setError(null);\n setEidTag(animal.eidTag ?? '');\n setBcs(animal.bodyConditionScore === null ? '' : String(animal.bodyConditionScore));\n setGroupId(animal.groupId ?? NONE);\n setDamId(animal.damId ?? NONE);\n setSireId(animal.sireId ?? NONE);\n setGrazingPaddock(animal.grazingPaddock ?? '');\n setRotationDate(animal.rotationDate ? animal.rotationDate.slice(0, 10) : '');\n setGrazingNotes(animal.grazingNotes ?? '');\n }, [open, animal]);\n\n const parents = animalOptions.filter((o) => o.animalId !== animal.animalId);\n\n const handleSubmit = async () => {\n if (submitting) return;\n const bcsNum = bcs.trim() === '' ? null : Number(bcs);\n if (bcsNum !== null && (Number.isNaN(bcsNum) || bcsNum < 0 || bcsNum > 5)) {\n setError(t('healthybowl.livestock.depth.edit.bcsError', 'Body condition score must be between 0 and 5.'));\n return;\n }\n // BOFF-6050: reject client-side what the server would reject, so an obviously-bad tag never\n // costs a round-trip. The server stays the authority — including on uniqueness, which only it\n // can decide.\n const eid = validateEidTagInput(eidTag);\n if (!eid.ok) {\n const copy = EID_REJECTION_COPY[eid.reason];\n setError(t(copy.key, copy.fallback));\n return;\n }\n setSubmitting(true);\n setError(null);\n try {\n await onSubmit({\n animalId: animal.animalId,\n eidTag: eid.value,\n bodyConditionScore: bcsNum,\n groupId: groupId === NONE ? null : groupId,\n damId: damId === NONE ? null : damId,\n sireId: sireId === NONE ? null : sireId,\n grazingPaddock: grazingPaddock.trim() || null,\n rotationDate: rotationDate || null,\n grazingNotes: grazingNotes.trim() || null,\n });\n onClose();\n } catch (err) {\n // The modal deliberately stays open — `onClose()` above is inside the try, after the await —\n // so the operator can correct a duplicate EID without retyping the whole record. The backend's\n // CONFLICT names the animal that already holds the tag; that text lives in\n // `extensions.userMessage`, not in `err.message`.\n setError(\n readMutationErrorMessage(\n err,\n t('healthybowl.livestock.depth.edit.saveFailed', 'Could not save the animal record.')\n )\n );\n } finally {\n setSubmitting(false);\n }\n };\n\n const parentSelect = (value: string, setValue: (v: string) => void, label: string) => (\n <div>\n <label className={fieldLabel}>{label}</label>\n <Select value={value} onValueChange={setValue}>\n <SelectTrigger>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value={NONE}>{t('healthybowl.livestock.depth.edit.none', 'None')}</SelectItem>\n {parents.map((o) => (\n <SelectItem key={o.animalId} value={o.animalId}>\n {o.tagNumber} · {o.name}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n );\n\n return (\n <Modal\n open={open}\n onClose={onClose}\n title={t('healthybowl.livestock.depth.edit.title', 'Edit animal record')}\n description={`${animal.tagNumber} · ${animal.name}`}\n size=\"lg\"\n footer={\n <>\n <Button variant=\"outline\" onClick={onClose} disabled={submitting}>\n {t('common.cancel', 'Cancel')}\n </Button>\n <Button onClick={() => void handleSubmit()} disabled={submitting}>\n {t('healthybowl.livestock.depth.edit.save', 'Save changes')}\n </Button>\n </>\n }\n >\n <div className=\"space-y-3\">\n {error ? (\n <div className=\"rounded-md border border-status-error-border bg-status-error-bg px-3 py-2 text-sm text-status-error-text\">\n {error}\n </div>\n ) : null}\n <div className=\"grid grid-cols-2 gap-3\">\n <div>\n <label className={fieldLabel}>{t('healthybowl.livestock.depth.edit.eid', 'EID / RFID tag')}</label>\n <Input value={eidTag} onChange={(e) => setEidTag(e.target.value)} placeholder=\"982 000123456789\" />\n </div>\n <div>\n <label className={fieldLabel}>{t('healthybowl.livestock.depth.edit.bcs', 'Body condition (0–5)')}</label>\n <Input type=\"number\" min=\"0\" max=\"5\" step=\"0.25\" value={bcs} onChange={(e) => setBcs(e.target.value)} />\n </div>\n </div>\n <div>\n <label className={fieldLabel}>{t('healthybowl.livestock.depth.edit.group', 'Group')}</label>\n <Select value={groupId} onValueChange={setGroupId}>\n <SelectTrigger>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value={NONE}>{t('healthybowl.livestock.depth.edit.none', 'None')}</SelectItem>\n {groups.map((g) => (\n <SelectItem key={g.id} value={g.id}>\n {g.name}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n <div className=\"grid grid-cols-2 gap-3\">\n {parentSelect(damId, setDamId, t('healthybowl.livestock.depth.edit.dam', 'Genealogy — Dam'))}\n {parentSelect(sireId, setSireId, t('healthybowl.livestock.depth.edit.sire', 'Sire'))}\n </div>\n {/* LEGACY (BOFF-2890). These two columns are not what the Grazing page reads and saving\n them does not move an animal — `rotationDate` is one scalar, so it has no time in, no\n time out and no history. Said here because the form is where the stale value gets\n written back. */}\n <div className=\"grid grid-cols-2 gap-3\">\n <div>\n <label className={fieldLabel}>\n {t('healthybowl.livestock.depth.edit.paddock', 'Grazing paddock (legacy)')}\n </label>\n <Input value={grazingPaddock} onChange={(e) => setGrazingPaddock(e.target.value)} placeholder=\"Paddock 4\" />\n </div>\n <div>\n <label className={fieldLabel}>\n {t('healthybowl.livestock.depth.edit.rotation', 'Rotates on (legacy)')}\n </label>\n <input\n type=\"date\"\n className={dateInput}\n value={rotationDate}\n onChange={(e) => setRotationDate(e.target.value)}\n />\n </div>\n <p className=\"col-span-2 text-xs text-text-secondary\">\n {t(\n 'healthybowl.livestock.depth.edit.grazingLegacyHint',\n 'These two carry a single paddock name and one date, with no time in or out, so saving them does not move an animal and does not change rest or stocking rate. Record the move on the Grazing page instead.'\n )}\n </p>\n </div>\n <div>\n <label className={fieldLabel}>\n {t('healthybowl.livestock.depth.edit.grazingNotes', 'Grazing / rotation notes')}\n </label>\n <Textarea value={grazingNotes} onChange={(e) => setGrazingNotes(e.target.value)} rows={2} />\n </div>\n </div>\n </Modal>\n );\n};\n"],"mappings":";;;;;;;;AAoCA,IAAM,IAAO,YAMP,IAAiF;CACrF,SAAS;EACP,KAAK;EACL,UAAU;CACZ;CACA,SAAS;EACP,KAAK;EACL,UAAU;CACZ;CACA,gBAAgB;EACd,KAAK;EACL,UAAU;CACZ;AACF,GAEM,IAAa,oDACb,IACJ,wKAEW,KAAwB,EACnC,SACA,YACA,WACA,WACA,kBACA,kBAC+B;CAC/B,IAAM,EAAE,SAAM,EAAQ,GAChB,CAAC,GAAQ,KAAa,EAAS,EAAE,GACjC,CAAC,GAAK,KAAU,EAAS,EAAE,GAC3B,CAAC,GAAS,KAAc,EAAS,CAAI,GACrC,CAAC,GAAO,KAAY,EAAS,CAAI,GACjC,CAAC,GAAQ,KAAa,EAAS,CAAI,GACnC,CAAC,GAAgB,KAAqB,EAAS,EAAE,GACjD,CAAC,GAAc,KAAmB,EAAS,EAAE,GAC7C,CAAC,GAAc,KAAmB,EAAS,EAAE,GAC7C,CAAC,GAAY,KAAiB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ACf,EAAE,6CAA6C,qBAAqB;MAChE,CAAA,GACP,kBAAC,SAAD;OACE,MAAK;OACL,WAAW;OACX,OAAO;OACP,WAAW,MAAM,EAAgB,EAAE,OAAO,KAAK;MAChD,CAAA,CACE,EAAA,CAAA;MACL,kBAAC,KAAD;OAAG,WAAU;iBACV,EACC,sDACA,4MACF;MACC,CAAA;KACA;;IACL,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,SAAD;KAAO,WAAW;eACf,EAAE,iDAAiD,0BAA0B;IACzE,CAAA,GACP,kBAAC,GAAD;KAAU,OAAO;KAAc,WAAW,MAAM,EAAgB,EAAE,OAAO,KAAK;KAAG,MAAM;IAAI,CAAA,CACxF,EAAA,CAAA;GACF;;CACA,CAAA;AAEX"}
1
+ {"version":3,"file":"AnimalDepthFormModal.js","names":[],"sources":["../../../../src/healthybowl/pages/livestock/AnimalDepthFormModal.tsx"],"sourcesContent":["/**\n * Edit an animal's deep record (BOFF-2890 · L-1): EID/RFID, body-condition score, group,\n * dam/sire genealogy, grazing/rotation. Dam & sire are picked from the workspace's own animals\n * (loose links). No fabricated data — every field maps to a real column.\n */\nimport { useEffect, useState } from 'react';\nimport {\n Button,\n Input,\n Textarea,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@burdenoff/fe-libs/ui';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { Modal } from '../../components';\nimport type { AnimalDepthRecord, AnimalGroup } from '../../hooks/useHealthyBowlLivestockDepth';\nimport { type EidTagRejection, readMutationErrorMessage, validateEidTagInput } from './eidTagInput';\n\nexport interface AnimalOption {\n animalId: string;\n tagNumber: string;\n name: string;\n /** Has left the herd. Still pickable — a culled or sold parent is still the parent (BOFF-6011). */\n archived: boolean;\n}\n\ninterface AnimalDepthFormModalProps {\n open: boolean;\n onClose: () => void;\n animal: AnimalDepthRecord;\n groups: AnimalGroup[];\n animalOptions: AnimalOption[];\n onSubmit: (input: Record<string, unknown>) => Promise<void>;\n}\n\nconst NONE = '__none__';\n\n/**\n * Why the EID can be rejected, in the operator's words (BOFF-6050). Keyed by the reason\n * `validateEidTagInput` returns so the copy and the rule cannot drift apart.\n */\nconst EID_REJECTION_COPY: Record<EidTagRejection, { key: string; fallback: string }> = {\n tooLong: {\n key: 'healthybowl.livestock.depth.edit.eidTooLong',\n fallback: 'The EID / RFID tag must be 100 characters or fewer.',\n },\n charset: {\n key: 'healthybowl.livestock.depth.edit.eidCharset',\n fallback: 'The EID / RFID tag may contain only letters, digits, spaces, hyphens and underscores.',\n },\n noAlphanumeric: {\n key: 'healthybowl.livestock.depth.edit.eidNoAlphanumeric',\n fallback: 'The EID / RFID tag must contain at least one letter or digit.',\n },\n};\n\nconst fieldLabel = 'mb-1 block text-sm font-medium text-text-primary';\nconst dateInput =\n 'w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary focus:outline-none focus:ring-2 focus:ring-[var(--color-focus-ring)]';\n\nexport const AnimalDepthFormModal = ({\n open,\n onClose,\n animal,\n groups,\n animalOptions,\n onSubmit,\n}: AnimalDepthFormModalProps) => {\n const { t } = useI18n();\n const [eidTag, setEidTag] = useState('');\n const [bcs, setBcs] = useState('');\n const [groupId, setGroupId] = useState(NONE);\n const [damId, setDamId] = useState(NONE);\n const [sireId, setSireId] = useState(NONE);\n const [grazingPaddock, setGrazingPaddock] = useState('');\n const [rotationDate, setRotationDate] = useState('');\n const [grazingNotes, setGrazingNotes] = useState('');\n const [submitting, setSubmitting] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n useEffect(() => {\n if (!open) return;\n setError(null);\n setEidTag(animal.eidTag ?? '');\n setBcs(animal.bodyConditionScore === null ? '' : String(animal.bodyConditionScore));\n setGroupId(animal.groupId ?? NONE);\n setDamId(animal.damId ?? NONE);\n setSireId(animal.sireId ?? NONE);\n setGrazingPaddock(animal.grazingPaddock ?? '');\n setRotationDate(animal.rotationDate ? animal.rotationDate.slice(0, 10) : '');\n setGrazingNotes(animal.grazingNotes ?? '');\n }, [open, animal]);\n\n // Archived animals stay pickable, but sort after every live one so the common case is not buried\n // under years of retired stock. `Array.prototype.sort` is stable, so the backend's tagNumber\n // ordering survives inside each half.\n const parents = animalOptions\n .filter((o) => o.animalId !== animal.animalId)\n .sort((x, y) => Number(x.archived) - Number(y.archived));\n\n const handleSubmit = async () => {\n if (submitting) return;\n const bcsNum = bcs.trim() === '' ? null : Number(bcs);\n if (bcsNum !== null && (Number.isNaN(bcsNum) || bcsNum < 0 || bcsNum > 5)) {\n setError(t('healthybowl.livestock.depth.edit.bcsError', 'Body condition score must be between 0 and 5.'));\n return;\n }\n // BOFF-6050: reject client-side what the server would reject, so an obviously-bad tag never\n // costs a round-trip. The server stays the authority — including on uniqueness, which only it\n // can decide.\n const eid = validateEidTagInput(eidTag);\n if (!eid.ok) {\n const copy = EID_REJECTION_COPY[eid.reason];\n setError(t(copy.key, copy.fallback));\n return;\n }\n setSubmitting(true);\n setError(null);\n try {\n await onSubmit({\n animalId: animal.animalId,\n eidTag: eid.value,\n bodyConditionScore: bcsNum,\n groupId: groupId === NONE ? null : groupId,\n damId: damId === NONE ? null : damId,\n sireId: sireId === NONE ? null : sireId,\n grazingPaddock: grazingPaddock.trim() || null,\n rotationDate: rotationDate || null,\n grazingNotes: grazingNotes.trim() || null,\n });\n onClose();\n } catch (err) {\n // The modal deliberately stays open — `onClose()` above is inside the try, after the await —\n // so the operator can correct a duplicate EID without retyping the whole record. The backend's\n // CONFLICT names the animal that already holds the tag; that text lives in\n // `extensions.userMessage`, not in `err.message`.\n setError(\n readMutationErrorMessage(\n err,\n t('healthybowl.livestock.depth.edit.saveFailed', 'Could not save the animal record.')\n )\n );\n } finally {\n setSubmitting(false);\n }\n };\n\n const parentSelect = (value: string, setValue: (v: string) => void, label: string) => (\n <div>\n <label className={fieldLabel}>{label}</label>\n <Select value={value} onValueChange={setValue}>\n <SelectTrigger>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value={NONE}>{t('healthybowl.livestock.depth.edit.none', 'None')}</SelectItem>\n {parents.map((o) => (\n <SelectItem key={o.animalId} value={o.animalId}>\n {/* The word carries the meaning; the muted colour is decoration only, because a state\n a user must act on may never be signalled by colour alone. */}\n <span className={o.archived ? 'text-text-secondary' : undefined}>\n {o.tagNumber} · {o.name}\n {o.archived ? ` · ${t('healthybowl.livestock.depth.edit.archivedOption', 'archived')}` : ''}\n </span>\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n );\n\n return (\n <Modal\n open={open}\n onClose={onClose}\n title={t('healthybowl.livestock.depth.edit.title', 'Edit animal record')}\n description={`${animal.tagNumber} · ${animal.name}`}\n size=\"lg\"\n footer={\n <>\n <Button variant=\"outline\" onClick={onClose} disabled={submitting}>\n {t('common.cancel', 'Cancel')}\n </Button>\n <Button onClick={() => void handleSubmit()} disabled={submitting}>\n {t('healthybowl.livestock.depth.edit.save', 'Save changes')}\n </Button>\n </>\n }\n >\n <div className=\"space-y-3\">\n {error ? (\n <div className=\"rounded-md border border-status-error-border bg-status-error-bg px-3 py-2 text-sm text-status-error-text\">\n {error}\n </div>\n ) : null}\n <div className=\"grid grid-cols-2 gap-3\">\n <div>\n <label className={fieldLabel}>{t('healthybowl.livestock.depth.edit.eid', 'EID / RFID tag')}</label>\n <Input value={eidTag} onChange={(e) => setEidTag(e.target.value)} placeholder=\"982 000123456789\" />\n </div>\n <div>\n <label className={fieldLabel}>{t('healthybowl.livestock.depth.edit.bcs', 'Body condition (0–5)')}</label>\n <Input type=\"number\" min=\"0\" max=\"5\" step=\"0.25\" value={bcs} onChange={(e) => setBcs(e.target.value)} />\n </div>\n </div>\n <div>\n <label className={fieldLabel}>{t('healthybowl.livestock.depth.edit.group', 'Group')}</label>\n <Select value={groupId} onValueChange={setGroupId}>\n <SelectTrigger>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value={NONE}>{t('healthybowl.livestock.depth.edit.none', 'None')}</SelectItem>\n {groups.map((g) => (\n <SelectItem key={g.id} value={g.id}>\n {g.name}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n <div className=\"grid grid-cols-2 gap-3\">\n {parentSelect(damId, setDamId, t('healthybowl.livestock.depth.edit.dam', 'Genealogy — Dam'))}\n {parentSelect(sireId, setSireId, t('healthybowl.livestock.depth.edit.sire', 'Sire'))}\n </div>\n {/* LEGACY (BOFF-2890). These two columns are not what the Grazing page reads and saving\n them does not move an animal — `rotationDate` is one scalar, so it has no time in, no\n time out and no history. Said here because the form is where the stale value gets\n written back. */}\n <div className=\"grid grid-cols-2 gap-3\">\n <div>\n <label className={fieldLabel}>\n {t('healthybowl.livestock.depth.edit.paddock', 'Grazing paddock (legacy)')}\n </label>\n <Input value={grazingPaddock} onChange={(e) => setGrazingPaddock(e.target.value)} placeholder=\"Paddock 4\" />\n </div>\n <div>\n <label className={fieldLabel}>\n {t('healthybowl.livestock.depth.edit.rotation', 'Rotates on (legacy)')}\n </label>\n <input\n type=\"date\"\n className={dateInput}\n value={rotationDate}\n onChange={(e) => setRotationDate(e.target.value)}\n />\n </div>\n <p className=\"col-span-2 text-xs text-text-secondary\">\n {t(\n 'healthybowl.livestock.depth.edit.grazingLegacyHint',\n 'These two carry a single paddock name and one date, with no time in or out, so saving them does not move an animal and does not change rest or stocking rate. Record the move on the Grazing page instead.'\n )}\n </p>\n </div>\n <div>\n <label className={fieldLabel}>\n {t('healthybowl.livestock.depth.edit.grazingNotes', 'Grazing / rotation notes')}\n </label>\n <Textarea value={grazingNotes} onChange={(e) => setGrazingNotes(e.target.value)} rows={2} />\n </div>\n </div>\n </Modal>\n );\n};\n"],"mappings":";;;;;;;;AAsCA,IAAM,IAAO,YAMP,IAAiF;CACrF,SAAS;EACP,KAAK;EACL,UAAU;CACZ;CACA,SAAS;EACP,KAAK;EACL,UAAU;CACZ;CACA,gBAAgB;EACd,KAAK;EACL,UAAU;CACZ;AACF,GAEM,IAAa,oDACb,IACJ,wKAEW,KAAwB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